Try harder to succeed at fall-backing to a Monospace font

A combination of some ideas:

 * Try all Monospace fonts before giving up.
 * Relax exact weight restriction on font matching when trying Monospace
   fall-back. Try smaller weights if needed.
 * Make the fall-back try order weight-offset aware, AND script-aware.
 * And finally, add the option to adjust the font size of glyphs using
   fall-back Monospace fonts, so the width of them matches the default
   font width.

   For my use-case, the current fall-back attempt always fails with
   Arabic script. And none of the Arabic-supporting Monospace fonts in
   my system also support medium weight. So, if my default font is set
   to medium weight, script-aware fall-back alone will still not work.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
Mohammad AlSaleh 2024-01-17 12:32:33 +03:00 committed by Jeremy Soller
parent 054b7da828
commit 329941c4a6
8 changed files with 177 additions and 39 deletions

View file

@ -177,7 +177,8 @@ impl<'a> Attrs<'a> {
//TODO: smarter way of including emoji
face.post_script_name.contains("Emoji")
|| (face.style == self.style
&& face.weight == self.weight
// Relax exact weight matching for the Monospace fallback use-case
&& face.weight <= self.weight
&& face.stretch == self.stretch)
}