Skip to content

Conversation

gredler
Copy link
Contributor

@gredler gredler commented Sep 30, 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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8167268: StandardGlyphVector.getGlyphMetrics creates metrics with erroneous bounds for characters with no outline (e.g., the space character ' ') (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27580/head:pull/27580
$ git checkout pull/27580

Update a local copy of the PR:
$ git checkout pull/27580
$ git pull https://git.openjdk.org/jdk.git pull/27580/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27580

View PR using the GUI difftool:
$ git pr show -t 27580

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27580.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 30, 2025

👋 Welcome back dgredler! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 30, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Sep 30, 2025

@gredler The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 30, 2025
@mlbridge
Copy link

mlbridge bot commented Sep 30, 2025

Webrevs

}
}

private static void assertEqual(double d1, double d2, double variance, String scenario, int index) {
Copy link
Member

Choose a reason for hiding this comment

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

please split the long line to have 80 chars

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, let me know if that looks good.

vb.getMinY() - pt.getY(),
vb.getWidth(),
vb.getHeight());
if (!vb.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

Just to double check: do we want to skip glyphs only when the bounds are empty, or we also want to skip them when the bounds are flipped (negative width/height)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you know when that might happen? This code gets its values (after a few layers of abstraction) from StandardGlyphVector$GlyphStrike.getGlyphOutlineBounds(int, float, float), which has a similar isEmpty check.

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if it is possible, but I would like to make sure we did not introduce any issues, since isEmpty() will skip ‘flipped’ bounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants