Skip to content

Fix baseline rounding to match GDI/BMFont (issue #67)#69

Open
kaltinril wants to merge 2 commits into
mainfrom
fix/issue-67-baseline-rounding
Open

Fix baseline rounding to match GDI/BMFont (issue #67)#69
kaltinril wants to merge 2 commits into
mainfrom
fix/issue-67-baseline-rounding

Conversation

@kaltinril

Copy link
Copy Markdown
Owner

BmFontModelBuilder Tier 2 used Math.Ceiling for lineHeight and base, but Windows GDI computes tmAscent with Math.Round. This made x-height glyphs appear 1px lower than ascender glyphs within the same text run, causing the inconsistent vertical alignment reported in issue #67.

Change both Ceiling calls to Math.Round(…, AwayFromZero) so FreeType and DirectWrite produce the same base/lineHeight as GDI and BMFont's reference output. Adds a gum-em-height.bmfc comparison config (fontSize=-36) to test the Gum integration path, and cross-backend tests that assert FreeType and DirectWrite match GDI without hardcoding specific pixel values.

BmFontModelBuilder Tier 2 used Math.Ceiling for lineHeight and base, but
Windows GDI computes tmAscent with Math.Round. This made x-height glyphs
appear 1px lower than ascender glyphs within the same text run, causing
the inconsistent vertical alignment reported in issue #67.

Change both Ceiling calls to Math.Round(…, AwayFromZero) so FreeType and
DirectWrite produce the same base/lineHeight as GDI and BMFont's reference
output. Adds a gum-em-height.bmfc comparison config (fontSize=-36) to test
the Gum integration path, and cross-backend tests that assert FreeType and
DirectWrite match GDI without hardcoding specific pixel values.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kaltinril kaltinril requested a review from vchelaru May 25, 2026 20:48
BaselineAlignmentTests ran InlineData(DirectWrite) on net8.0-windows
where the rasterizer isn't referenced, causing InvalidOperationException.
Guard both DirectWrite InlineData attributes with #if DIRECTWRITE so they
only compile and run on net10.0-windows where the backend is available.

Also reads the pre-existing updatingSyntheticChecks guard flag in
EffectsPanel.cs (it was written but never read, producing CS0219 warnings
in the build output). Adds the missing if-checks to synBoldCheck.Checked
and synItalicCheck.Checked — the handlers that are re-entered during
programmatic IsChecked changes.
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