Skip to content

8165943: LineBreakMeasurer does not measure correctly if TextAttribute.TRACKING is set.#10289

Closed
omikhaltsova wants to merge 10 commits intoopenjdk:masterfrom
omikhaltsova:JDK-6598756
Closed

8165943: LineBreakMeasurer does not measure correctly if TextAttribute.TRACKING is set.#10289
omikhaltsova wants to merge 10 commits intoopenjdk:masterfrom
omikhaltsova:JDK-6598756

Conversation

@omikhaltsova
Copy link

@omikhaltsova omikhaltsova commented Sep 15, 2022

This is a fix for LineBreakMeasurer. It takes into account the TextAttribute.TRACKING value (not eq 0) while calculating the line breaks.

Tested on Linux x64, Windows x64, macOS x64 with the reproducer (LineBreakSample.java) attached to JDK-8165943 and the following group of tests:
$JTREG_HOME/bin/jtreg -jdk:$BUILD_HOME ./test/jdk/java/awt/font


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-8165943: LineBreakMeasurer does not measure correctly if TextAttribute.TRACKING is set.

Reviewers

Contributors

  • Jason Fordham <jclf@azul.com>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10289

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 15, 2022

👋 Welcome back omikhaltcova! 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.

@omikhaltsova
Copy link
Author

/contributor add Jason Fordham jclf@azul.com

@openjdk
Copy link

openjdk bot commented Sep 15, 2022

@omikhaltsova
Contributor Jason Fordham <jclf@azul.com> successfully added.

@openjdk
Copy link

openjdk bot commented Sep 15, 2022

@omikhaltsova 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 Sep 15, 2022
@omikhaltsova omikhaltsova marked this pull request as ready for review September 15, 2022 19:56
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 15, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 15, 2022

Webrevs

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 13, 2022

@omikhaltsova This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@omikhaltsova
Copy link
Author

gentle ping; pls review this pr!

@omikhaltsova
Copy link
Author

@prrace Could you please take a look at the proposed changes! Is this fix needed or not? It fixes JDK-8165943/JDK-6598756. I opened PR on JDK-8165943 because it had more active conversation. But maybe I made a mistake and it should be opened on JDK-6598756 (created by you) because it was created earlier then JDK-8165943?

@prrace
Copy link
Contributor

prrace commented Nov 20, 2022

I haven't had time to look at this. Maybe I can look at it some time in the 1st week of December. Ping me then.

@omikhaltsova
Copy link
Author

Thanks! I'll ping you in 1,5 weeks.

@azul-jf
Copy link
Contributor

azul-jf commented Nov 21, 2022

Hi @prrace, this came to our attention as a customer issue. The reproducer we used was the one from JDK-8165943.

As a reminder of the issue and an illustration of the desired outcome, here are some screen captures.

Existing code, TRACKING = 0.0:

image

Existing code, TRACKING = 0.1:

image

Submitted code, TRACKING = 0.1:

image

@mlbridge
Copy link

mlbridge bot commented Nov 22, 2022

Mailing list message from Patrick Chen on client-libs-dev:

I think it is good
reviewed

Le lun. 21 nov. 2022 ? 16:08, azul-jf <duke at openjdk.org> a ?crit :

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/client-libs-dev/attachments/20221122/c90ebeb2/attachment.htm>

@jayathirthrao
Copy link
Member

jayathirthrao commented Nov 23, 2022

Change looks okay to me.
Verified the fix locally and line break works properly with tracking now.

Attached image with tracking 0.1 before and after fix.

Before fix :

BeforeFix

After fix :
AfterFix

Also client test run in our CI with this fix is green.
Let's wait for Phil's review also.

@jayathirthrao
Copy link
Member

Its better if we can add jtreg(regression) test along with fix.
It can be a manual test, if we can't automate it.

@prrace
Copy link
Contributor

prrace commented Nov 29, 2022

I'm sure an automated test is possible - it should be easy enough to adjust the tracking and verify the breaks are different.
The code paths here don't do complex text. Tracking doesn't really work for things like Arabic .. but it would be good to
verify that Arabic measures as it lays out with tracking - ignoring it I expect, but I could be surprised if there's something I am overlooking. Hence why a test of that would be good.

/*
@test
@key headful
@bug 8165943
Copy link
Contributor

Choose a reason for hiding this comment

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

headful isn't needed on manual tests.

Also whilst you can keep this manual test, I still think an automated test that verifies tracking is making a difference to the advance should be provided.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

if (lineMeasurer == null) {
Float regular = new Float(16.0);
Float big = new Float(24.0);

Copy link
Contributor

Choose a reason for hiding this comment

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

LineBreakWithTracking.java:74: warning: [removal] Float(double) in Float has been deprecated and marked for removal
Float regular = new Float(16.0);
^
LineBreakWithTracking.java:75: warning: [removal] Float(double) in Float has been deprecated and marked for removal
Float big = new Float(24.0);

Use Float.valueOf(float) instead

Copy link
Author

Choose a reason for hiding this comment

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

fixed

JButton btn = new JButton("Pass");
btn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not call System.exit() in jtreg tests - even manual ones or ones that run in their own VM.
Instead dispose() the UI and then either let main() exit normally or throw RuntimeException() to indicate failure.

Also be sure that ALL exit paths clean up windows.

You may want to use PassFailJFrame.java to help you avoid writing the boilerplate and to get some of these things right

https://github.com/openjdk/jdk/blob/master/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@openjdk openjdk bot removed the rfr Pull request is ready for review label Dec 6, 2022
@omikhaltsova
Copy link
Author

The following fixes are made:

  • fixed the lines breaks calculation for the negative tracking values;
  • included an epsilon for floating point operation;
  • fixed the manual test according to the above comments;
  • added a simple automated test similar to TestLineBreakWithFontSub.

@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 6, 2022
class LineBreakPanel extends JPanel implements ActionListener {

private float textTracking = 0.0f;
private static String fontName = "Bitstream Cyberbit";
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you previously use this font ? I must have over-looked that.
Do not use fonts that aren't available on the OS .. no SQE person will ever install - or even know a test uses it - and JDK will just use Dialog instead and people will get confused over why their experience is different than yours.
And of course each OS (desktop) will have different fonts. Overall best to just pick a logical font. If you want to know if the font supports all your code points you can iterate over your text using Font.canDisplay(int codePoint)

I'll submit a test job using your automated test.

Copy link
Author

Choose a reason for hiding this comment

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

I noticed the usage of this font "Bitstream Cyberbit" in TestJustification.java that was added by you. I used the test string from there because it includes Latin, Arabic, CJK and Hebrew. "Bitstream Cyberbit" has all nessesary symbols used in the test string. At the moment I have no idea what font I can use instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure it wasn't me who created that.
I may have updated it at some point (actually I suspect what you see is that I moved
it from closed to open) but that test was created by someone else 23 years ago (1999).
Different world back then. Likely it should not use the font either.

Your best best is to use Dialog. On all platforms where a decent set of fonts is installed then all those scripts will be supported by Dialog.

Copy link
Contributor

@prrace prrace left a comment

Choose a reason for hiding this comment

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

This now is fine by me. It didn't break any of our automated tests.

@openjdk
Copy link

openjdk bot commented Dec 7, 2022

@omikhaltsova 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:

8165943: LineBreakMeasurer does not measure correctly if TextAttribute.TRACKING is set.

Co-authored-by: Jason Fordham <jclf@azul.com>
Reviewed-by: prr

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 1191 new commits pushed to the master branch:

  • 3934484: 8298205: Prefer Member Initialization Lists for JFR classes in os_perf.hpp
  • 389b8f4: 8297298: SequenceInputStream should override transferTo
  • dd7385d: 8298202: [AIX] Dead code elimination removed jfr constructor used by AIX
  • 29f1c3c: 8298274: Problem list TestSPISigned on Windows
  • 3de7750: 8298177: Various java.lang.invoke cleanups
  • 6ed3683: 8297209: Serial: Refactor GenCollectedHeap::full_process_roots
  • 86270e3: 8269820: C2 PhaseIdealLoop::do_unroll get wrong opaque node
  • cf63f2e: 8298184: Incorrect record component type in record patterns
  • 58170f6: 8298035: Provide better descriptions for JIT compiler JFR events
  • bfcc238: 8297964: Jetty.java fails "assert(_no_handle_mark_nesting == 0) failed: allocating handle inside NoHandleMark"
  • ... and 1181 more: https://git.openjdk.org/jdk/compare/cea409cc2822ccdc9cbf6df04d46742e3c73b0fe...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@prrace) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 7, 2022
@omikhaltsova
Copy link
Author

/integrate

@omikhaltsova
Copy link
Author

Thanks a lot for reviewing!

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Dec 7, 2022
@openjdk
Copy link

openjdk bot commented Dec 7, 2022

@omikhaltsova
Your change (at version 34764d8) is now ready to be sponsored by a Committer.

@bae
Copy link

bae commented Dec 7, 2022

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 7, 2022

Going to push as commit 8edb98d.
Since your change was applied there have been 1191 commits pushed to the master branch:

  • 3934484: 8298205: Prefer Member Initialization Lists for JFR classes in os_perf.hpp
  • 389b8f4: 8297298: SequenceInputStream should override transferTo
  • dd7385d: 8298202: [AIX] Dead code elimination removed jfr constructor used by AIX
  • 29f1c3c: 8298274: Problem list TestSPISigned on Windows
  • 3de7750: 8298177: Various java.lang.invoke cleanups
  • 6ed3683: 8297209: Serial: Refactor GenCollectedHeap::full_process_roots
  • 86270e3: 8269820: C2 PhaseIdealLoop::do_unroll get wrong opaque node
  • cf63f2e: 8298184: Incorrect record component type in record patterns
  • 58170f6: 8298035: Provide better descriptions for JIT compiler JFR events
  • bfcc238: 8297964: Jetty.java fails "assert(_no_handle_mark_nesting == 0) failed: allocating handle inside NoHandleMark"
  • ... and 1181 more: https://git.openjdk.org/jdk/compare/cea409cc2822ccdc9cbf6df04d46742e3c73b0fe...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 7, 2022
@openjdk openjdk bot closed this Dec 7, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Dec 7, 2022
@openjdk
Copy link

openjdk bot commented Dec 7, 2022

@bae @omikhaltsova Pushed as commit 8edb98d.

💡 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.

6 participants