Skip to content

Add ScalerBuilder::hint_target to select the hinting target - #137

Open
showier-drastic wants to merge 1 commit into
dfrg:mainfrom
showier-drastic:main
Open

Add ScalerBuilder::hint_target to select the hinting target#137
showier-drastic wants to merge 1 commit into
dfrg:mainfrom
showier-drastic:main

Conversation

@showier-drastic

Copy link
Copy Markdown

Please see the commit message for the rationale of this change.

Please feel free to edit my branch directly if change is needed. One uncertainty is that I'm not sure if we should even add an option here, or just change the default to be greyscale.

Note: this will be used in a Pull Request to Slint's software renderer, which will demonstrate this PR's usefulness.

The hinting mode was hardcoded to HintingMode::Smooth with
lcd_subpixel: Some(LcdLayout::Horizontal), which maps to skrifa's
SmoothMode::Lcd. That target is only correct when the mask is
rasterized for subpixel (LCD) output. swash consumers (e.g. Slint) that render
Format::Alpha (grayscale) masks get LCD-tuned grid fitting instead:
skrifa documents that this mode widens horizontal stems in
ClearType-hinted fonts and 'may lead to blurry images when rendered
with an analytical area rasterizer' (skrifa src/outline/hint.rs,
Target::Smooth docs).

Add a HintingTarget enum and a ScalerBuilder::hint_target() knob so
grayscale renderers can request SmoothMode::Normal grid fitting. The
default remains HorizontalLcd, so existing users are unaffected.
preserve_linear_metrics stays true for both targets: hinting never
changes advance widths either way.

The hinting instance cache key now includes the target so the same
font/size/coords can be hinted for different targets without
thrashing a single entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant