Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8328896: Fontmetrics for large Fonts has zero width #18703

Closed
wants to merge 3 commits into from

Conversation

prrace
Copy link
Contributor

@prrace prrace commented Apr 9, 2024

The main problem here is that we do not curate what font point size we passed to freetype,
and would pass in one larger than freetype's maximum of FT_USHORT_MAX which is USHRT_MAX.
This isn't documented, SFAICS, and is checked a couple of calls deep from the specific API we use.
But generally anywhere near that size seems to cause freetype to choke as it uses signed 16.16
values, so 32767 is really the max.
But we have no need to go anywhere near that - 16384 seems like a plenty large enough pt size.
And we can request bigger sizes than that by making use of the transform.
At normal size ranges we use that just to account for rotation and decompose the glyph transform
into point size and that rotation.

But at large sizes - which are not usefully rendered anyway - there are no hints etc to be lost
from not specifying the target point size. So we can extend the range of sizes we allow.

If this is still too large to be held decomposed into a pt size in the range less than 16384 and a scale of up to 32766 then we substitute the null scaler, as we generally do when values are out of range, such
a for a NaN transform.

These extreme values aren't useful.

In looking at this I did find that getGlyphPixelBounds doesn't follow the maximum image size we use
for rendering. Which is not useful and could lead to inconsistent results. I fixed that.

Also whilst macOS didn't have these problems it could be cleaned up a bit for consistency in the reported sizes for some cases.

The test is mainly around making sure that "sensible" things are returned for not sensible input.
There's no 100% right answer to these extreme unrenderable sizes.


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-8328896: Fontmetrics for large Fonts has zero width (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18703

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 9, 2024

👋 Welcome back prr! 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 Apr 9, 2024

@prrace This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8328896: Fontmetrics for large Fonts has zero width

Reviewed-by: tr, serb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 164 new commits pushed to the master branch:

  • 57ebd04: 8330153: C2: dump barrier information for all Mach nodes
  • 58ad399: 8330821: Rename UnsafeCopyMemory
  • 1d52234: 8330704: Clean up non-standard use of /** comments in some langtools tests
  • 83c74d7: 8329717: Missing @since tags in elements in DocumentationTool and Taglet
  • 0b9350e: 8322992: Javac fails with StackOverflowError when compiling deeply nested synchronized blocks
  • 20be5e0: 8314846: Do not store Klass::_secondary_super_cache in CDS archive
  • 7e421ce: 8330585: Refactor/rename forwardee handling
  • 3e65d90: 8330820: Remove remnants of operator_new.cpp in build system
  • 936a47d: 8330607: Deprecate -XX:+UseEmptySlotsInSupers
  • ee7b2e9: 8330051: Small ObjectMonitor spinning code cleanups
  • ... and 154 more: https://git.openjdk.org/jdk/compare/b80ba0851841a8490e61371ac4ef3514dc6eddf5...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title 8328896 8328896: Fontmetrics for large Fonts has zero width Apr 9, 2024
@openjdk
Copy link

openjdk bot commented Apr 9, 2024

@prrace 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 client client-libs-dev@openjdk.org label Apr 9, 2024
if (obds.isEmpty()) {
Rectangle bds = getGlyphOutline(glyphCode, pt.x, pt.y).getBounds();
result.setBounds(bds);
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} else {
} else {

@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 9, 2024
@mlbridge
Copy link

mlbridge bot commented Apr 9, 2024

Webrevs

Copy link
Contributor

@TejeshR13 TejeshR13 left a comment

Choose a reason for hiding this comment

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

Can you please update the copywrite year for updated files.

context->ptsz = (int)(ptsz * 64);
if (TOO_LARGE(dmat[0], ptsz) || TOO_LARGE(dmat[1], ptsz) ||
TOO_LARGE(dmat[2], ptsz) || TOO_LARGE(dmat[3], ptsz))
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{
TOO_LARGE(dmat[2], ptsz) || TOO_LARGE(dmat[3], ptsz)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that was deliberate. We generally prefer the { on a new line if the conditional is multi-line.

Still looking for an actual "reviewer" review here.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 23, 2024
Copy link
Contributor

@TejeshR13 TejeshR13 left a comment

Choose a reason for hiding this comment

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

LGTM.

@prrace
Copy link
Contributor Author

prrace commented Apr 24, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Apr 24, 2024

Going to push as commit 25871af.
Since your change was applied there have been 206 commits pushed to the master branch:

  • 1d06170: 8300148: Consider using a StoreStore barrier instead of Release barrier on ctor exit
  • f1d0e71: 8324577: [REDO] - [IMPROVE] OPEN_MAX is no longer the max limit on macOS >= 10.6 for RLIMIT_NOFILE
  • 74b11cc: 8331004: Serial: Remove unused GenClosure
  • 45ed97f: 8330464: hserr generic events - add entry for the before_exit calls
  • e311ba3: 8330626: ZGC: Windows address space placeholders not managed correctly
  • e923dfe: 8314592: Add shortcut to SymbolLookup::find
  • 1519081: 8330303: Crash: assert(_target_jt == nullptr || _target_jt->vthread() == target_h()) failed
  • 2bb5cf5: 8330155: Serial: Remove TenuredSpace
  • 7bb59dc: 8330670: Obsolete ScavengeBeforeFullGC
  • 174d626: 8328741: serviceability/jvmti/ObjectMonitorUsage/ObjectMonitorUsage.java failed with unexpected owner
  • ... and 196 more: https://git.openjdk.org/jdk/compare/b80ba0851841a8490e61371ac4ef3514dc6eddf5...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 24, 2024
@openjdk openjdk bot closed this Apr 24, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 24, 2024
@openjdk
Copy link

openjdk bot commented Apr 24, 2024

@prrace Pushed as commit 25871af.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants