Skip to content

Removes outdated baseline/y-offset correction in adjustFont#20

Open
uguraslan wants to merge 1 commit into
mainfrom
fix/redundant-baseline-correction
Open

Removes outdated baseline/y-offset correction in adjustFont#20
uguraslan wants to merge 1 commit into
mainfrom
fix/redundant-baseline-correction

Conversation

@uguraslan

@uguraslan uguraslan commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This fixes a silent but real bug affecting the vertical alignment of every font this tool has generated since October 2025 (v1.2.0 through the current v1.3.0). Text is currently sitting slightly too low and this PR corrects it.

Background

  • [April 2024] : @frank-weindel noticed that msdf-bmfont-xml had a bug: it was placing the baseline and every character's vertical position slightly wrong. He added a small correction for it here, in adjustFont.ts. At the same time, he also opened this (Fix baseline alignment soimy/msdf-bmfont-xml#93) to fix the actual bug at its source.

He also added a @remark in the source code:

* A bug in the msdf-bmfont-xml package causes both the baseline and y-offsets
* of every character to be incorrect which results in the text being rendered
* out of intended alignment. This function corrects that data.
*
* See the following GitHub issue for more information:
* https://github.com/soimy/msdf-bmfont-xml/pull/93

  • [February 2025] : that upstream PR was merged. From this point on, any new version of msdf-bmfont-xml built from their main branch no longer has the bug.

  • [October 2025] : PR #14 updated our dependency to msdf-bmfont-xml@2.8.0, which includes that upstream fix. This was a good and necessary update. But after that point our own adjustFont.ts correction (written for the old, broken version) has started to double fix something that was already fixed.

Changes

This PR removes the redundant correction in adjustFont.ts. The function still does its other job (extracting and writing font metrics), only the baseline/y-offset math is removed.

Verification

  1. Shows the baseline error with the old, unfixed msdf-bmfont-xml, before our adjustFont.ts correction is applied.
  2. Shows what happens after applying our adjustFont.ts correction on top of that old, unfixed library.
  3. Shows that the new msdf-bmfont-xml fixes the baseline issue on its own, without our correction.
  4. The current shipped state, with the double correction applied.

So by removing the extra adjustment, we are returning to state 3.

baseline

Visual impact of this fix

This fix will visibly shift text in every app that uses this package, by a small amount (a couple of pixels based on the text configuration). It's not dramatic and that's exactly why this went unnoticed for months. But it is a real, visible change to existing layouts. Anyone relying on the current (incorrect) text position may notice things shift slightly, to the correct baseline.

@suresh-gangumalla suresh-gangumalla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

2 participants