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
8219641: java/awt/font/Rotate/RotatedTextTest.java fails on Linux: Test failed for angle 15.0 #15780
Conversation
👋 Welcome back azeller! A progress list of the required criteria for merging this PR into |
@ArnoZeller The following label will be automatically applied to this pull request:
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me this looks pragmatic. I made a few suggestions for cleanup of the coding.
static final String text = "The quick brown fox jumps over the lazy dog"; | ||
|
||
static void drawRotatedText(Graphics g) { | ||
Font fnt = fnt = new Font(Font.SERIF, Font.PLAIN, 12); | ||
String os = System.getProperty("os.name").toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String os = System.getProperty("os.name").toLowerCase(); | |
boolean isLinux = System.getProperty("os.name").toLowerCase().startsWith("linux"); | |
Font fnt = isLinux ? new Font("DejaVu Serif", Font.PLAIN, 12) : new Font(Font.SERIF, Font.PLAIN, 12); |
// On Linux we prefer DejaVu Serif - we have seen issues with some other fonts. | ||
fnt = new Font("DejaVu Serif", Font.PLAIN, 12); | ||
} | ||
System.out.println(fnt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System.out.println(fnt); | |
System.out.println("Using font: " + fnt); |
You could use |
What is the root cause for the test failing with RobotoSlab-Regular.ttf? It doesn't look right to me to change the font without understanding why the test fails with it. Is it a bug in the JDK? Is it a bug in test? |
Hi Alexey, there is a bit of discussion here https://bugs.openjdk.org/browse/JDK-8219641 The RobotoSlab-Regular.ttf: "Roboto Slab" "Regular" from /usr/share/fonts/truetype/RobotoSlab-Regular.ttf is indeed causing the trouble. user@sles15-x86_64_machine:> fc-match serif The test RotatedTextTest shows a small width difference in the rotation (but the test assumes the width difference is 0 and fails). I wonder if the test can really assume a width difference 0 , is this really what we can expect for all fonts on the various distros ? |
Perhaps, the test should allow for some small differences in widths. It could still be a bug in JDK where rounding isn't handled precisely. By choosing a different default font we may mask a problem. |
The bug report has "Angle: 15, width diff: -4" The JDK rounding code has been stable for a while now and changing that could cause problems elsewhere. Drawing and measuring the string using fractional metrics and floating point with a tolerance might have been a |
So, I guess it would be ok to change the test to allow a small difference? The question then is "What is valid allowed difference?" |
It looks 5 wouldn't be enough. On Ubuntu, using the Roboto font, I get |
Sounds like (1) we don't have any reasonable idea of a small error to allow and (2) we don't know that this test isn't just getting lucky with the fonts for which it does pass. So I am not comfortable with either solution. And looking at the image we have a badly wandering baseline which seems like rounding (from somewhere) is partly to blame. I'd really like to dig into the specifics of what's happening here for the advances of the code points here - and see what they are before truncation (ie what is the 26.6 value) as well as afterwards. I don't know what we'll find but I'd like to make a more informed decision. |
That sounds reasonable to me - I suspected it to be just an issue with some fonts and small differences, but it now looks like a bigger thing. I will close this PR. |
The test fails on newer SLES versions that have RobotoSlab-Regular.ttf as default font. I suggest to try getting a DejaVu font as default on Linux because it is known to work without issues.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15780/head:pull/15780
$ git checkout pull/15780
Update a local copy of the PR:
$ git checkout pull/15780
$ git pull https://git.openjdk.org/jdk.git pull/15780/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15780
View PR using the GUI difftool:
$ git pr show -t 15780
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15780.diff
Webrev
Link to Webrev Comment