-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Before this change, a font is considered monospace if `fontdb` flags it as such. `fontdb` checks the `post` table for this property. But some fonts don't set that property there. Most notably, "Noto Sans Mono" is among these fonts. Monospace as a property is said to be communicated in other places like `OS/2`'s `panose`, but that's not set in the Noto font either. Loosely based on a `fontconfig` function called `FcFreeTypeSpacing()`, this commit adds an additional check against fonts that are not set as `monospaced` by `fontdb`. The horizontal advances of all glyphs of a cmap unicode table are checked to see if they are monospace. Proportionality with double-width and treble-width advances is taken into consideration. Treble width advances exist in the aforementioned Noto font. The checks should be efficient, but the overhead is not in the noise. So these extra checks are only run if the "monospace_fallback" crate feature is enabled. This change also requires library users to check monospacity with `FontSystem::is_monospace()` instead of `FaceInfo::monospaced` from `fontdb` to be in-sync with cosmic-text's view. This requirement was probably coming in the future anyway for when cosmic-text adds support for variable fonts. Signed-off-by: Mohammad AlSaleh <[email protected]>
- Loading branch information
Showing
3 changed files
with
107 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters