RFR: 8167268: StandardGlyphVector.getGlyphMetrics creates metrics with erroneous bounds for characters with no outline (e.g., the space character ' ')

Daniel Gredler dgredler at openjdk.org
Tue Sep 30 14:33:27 UTC 2025


`GlyphMetrics` objects returned by `StandardGlyphVector.getGlyphMetrics(int)` contain bounds that are calculated by taking the glyph’s visual bounds and normalizing them by subtracting the glyph’s position.

However, some glyphs (e.g., the glyph for the space character) do not have visual bounds. Their outline is an empty shape. In such a case the bounds in the metrics should not be normalized by the glyph’s position. The code erroneously ignores this special case, thus producing bounds with inconsistent negative x-positions.

-------------

Commit messages:
 - Correct glyph bounds for glyphs with no outline

Changes: https://git.openjdk.org/jdk/pull/27580/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27580&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8167268
  Stats: 79 lines in 2 files changed: 73 ins; 0 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/27580.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27580/head:pull/27580

PR: https://git.openjdk.org/jdk/pull/27580


More information about the client-libs-dev mailing list