alacritty: hintfull setting is not respected

I’ve configured hintfull in fontconfig:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintfull</const>
  </edit>
 </match>
</fontconfig>

This is recognized by alacritty. I’ve not disabled antialiasing for any font. Therefore alacritty uses the following code path:

https://github.com/alacritty/alacritty/blob/fde2424b398dadd2310686b365041189decd1d63/font/src/ft/mod.rs#L491

hintfull is not applied in this case.

Disabling antialiasing via fontconfig makes the font ragged in alacritty and other programs and is therefore not an option.

This problem is specific to alacritty. Hinting works as expected in all other programs I’m using.

The following patch fixes the problem:

diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs
index d393b63..76b0dc7 100644
--- a/font/src/ft/mod.rs
+++ b/font/src/ft/mod.rs
@@ -453,7 +453,7 @@ impl FreeTypeRasterizer {
     }
 
     fn ft_load_flags(pattern: &PatternRef) -> freetype::face::LoadFlag {
-        let antialias = pattern.antialias().next().unwrap_or(true);
+        let antialias = pattern.antialias().next().unwrap_or(false);
         let hinting = pattern.hintstyle().next().unwrap_or(fc::HintStyle::Slight);
         let rgba = pattern.rgba().next().unwrap_or(fc::Rgba::Unknown);
         let embedded_bitmaps = pattern.embeddedbitmap().next().unwrap_or(true);

Current master with antialiasing enabled: 2020-03-30-094447_412x159_scrot Current master with the patch applied and antialiasing enabled: 2020-03-30-094529_371x156_scrot Current master with antialiasing disabled: 2020-03-30-094617_345x151_scrot

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

All 3 screenshots are different for me tbh.

Yes that is the point. The second screenshot (Current master with the patch applied and antialiasing enabled) is the desired result. This is how fonts are rendered in all other programs and how I want them to be rendered.

The following patch doesn’t make any sense, since AA shouldn’t be turned off.

Of course I’m not saying that this patch should be applied. It merely shows that alacritty’s decision to use the antialiasing configuration in fontconfig to make hinting decisions leads to inconsistent results.

All 3 screenshots are different for me tbh. The following patch doesn’t make any sense, since AA shouldn’t be turned off. I feel like our FreeType loading flags are not optimal in some cases.

Funnily enough, the FT_Set_Default_Properties API was added to freetype in 2017 because I reported to the freetype developers that hinting was broken in chromium: https://savannah.nongnu.org/bugs/?49187.

Like freetype-rs, chromium also uses FT_New_Library instead of FT_Init_Freetype (via skia.) After calling FT_New_Library, skia calls FT_Set_Default_Properties. Whether freetype-rs should call FT_Set_Default_Properties for you is unclear. But it should certainly expose the API.

The following patch doesn’t make any sense, since AA shouldn’t be turned off.

And of course AA isn’t turned off even with the patch applied as you can see from my screenshots.