Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Deep-check for monospacity #317

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Sep 30, 2024

  1. Deep-check for monospacity

     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]>
    MoSal committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    badd73f View commit details
    Browse the repository at this point in the history
  2. Apply cargo fmt to fix unrelated code

    Signed-off-by: Mohammad AlSaleh <[email protected]>
    MoSal committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    f57270b View commit details
    Browse the repository at this point in the history