Add ScalerBuilder::hint_target to select the hinting target - #137
Open
showier-drastic wants to merge 1 commit into
Open
Add ScalerBuilder::hint_target to select the hinting target#137showier-drastic wants to merge 1 commit into
showier-drastic wants to merge 1 commit into
Conversation
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.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.