fonts: speculative fix for Monaco.dfont bitmap/render error
The error message in this issue sounds a lot like the freetype regression that caused bitmap fonts to fail to render in a recent freetype release. Our workaround for that is to used our understanding of whether a font is a bitmap font or not to avoid calling render. What we normally see for bitmap TTFs is that setting the scale fails and we then fall back to using a bitmap. For Monaco.dfont it appears as though setting the scale succeeds. This commit introduces some skepticism and prefers to use bitmaps when available. This might potentially cause problems in the future if there are fonts that legitimately have both scaled and bitmap fonts, but lets see if this helps for now. refs: https://github.com/wez/wezterm/issues/1419
This commit is contained in:
1 parent
e9f1297b45
commit
48dd57ab9f
1 file changed
+12
-2
@@ -555,6 +555,12 @@ impl Face {
|
||||
if (*self.face).height == 0 {
|
||||
anyhow::bail!("font has 0 height, fallback to bitmaps");
|
||||
}
|
||||
if (*self.face).num_fixed_sizes > 0 {
|
||||
anyhow::bail!(
|
||||
"font has bitmaps but also allowed FT_Set_Char_Size to succeed... \
|
||||
not trusting it and falling back to bitmaps"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -612,8 +618,12 @@ impl Face {
|
||||
}
|
||||
}
|
||||
|
||||
ft_result(FT_Render_Glyph(slot, render_mode), ())
|
||||
.context("load_and_render_glyph: FT_Render_Glyph")?;
|
||||
ft_result(FT_Render_Glyph(slot, render_mode), ()).with_context(|| {
|
||||
format!(
|
||||
"load_and_render_glyph: FT_Render_Glyph render_mode={:?}",
|
||||
render_mode
|
||||
)
|
||||
})?;
|
||||
Ok(slot)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user