Skip to content

Commit

Permalink
8316206: Test StretchedFontTest.java fails for Baekmuk font
Browse files Browse the repository at this point in the history
Ignore broken fonts, i.e. the fonts for which
GlyphVector(TEXT).getVisualBounds().isEmpty() returns true

Reviewed-by: azvegint, prr, goetz
  • Loading branch information
aivanov-jdk committed Sep 22, 2023
1 parent c24c66d commit 00f585b
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions test/jdk/java/awt/font/FontScaling/StretchedFontTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
Expand Down Expand Up @@ -61,15 +62,19 @@ public final class StretchedFontTest {
new Color(0x7F000000, true)
};

/** Locale for getting font names. */
private static final Locale ENGLISH_LOCALE = Locale.ENGLISH;

private static final AffineTransform STRETCH_TRANSFORM =
AffineTransform.getScaleInstance(2.0, 1.0);

public static void main(String[] args) {
List<String> errors =
Arrays.stream(getLocalGraphicsEnvironment()
.getAvailableFontFamilyNames(Locale.ENGLISH))
.getAvailableFontFamilyNames(ENGLISH_LOCALE))
.map(family -> new Font(family, Font.PLAIN, FONT_SIZE))
.filter(font -> font.canDisplay(TEXT.codePointAt(0)))
.filter(font -> !isBrokenFont(font))
.map(font -> font.deriveFont(STRETCH_TRANSFORM))
.flatMap(StretchedFontTest::testFont)
.filter(Objects::nonNull)
Expand All @@ -82,6 +87,26 @@ public static void main(String[] args) {
}
}

/**
* Checks whether the font renders the glyph in {@code TEXT} and
* returns {@code true} if the glyph isn't rendered.
*
* @param font the font to test
* @return {@code true} if the visual bounds of {@code TEXT} are empty, and
* {@code false} otherwise
*/
private static boolean isBrokenFont(final Font font) {
final boolean empty =
font.createGlyphVector(new FontRenderContext(null, false, false),
TEXT)
.getVisualBounds()
.isEmpty();
if (empty) {
System.err.println("Broken font: " + font.getFontName(ENGLISH_LOCALE));
}
return empty;
}

/**
* Tests the font with a set of text antialiasing hints.
*
Expand Down Expand Up @@ -145,7 +170,7 @@ private static String testFont(final Font font,
if (verifyImage(image)) {
return null;
}
String fontName = font.getFontName(Locale.ENGLISH);
String fontName = font.getFontName(ENGLISH_LOCALE);
String hintValue = getHintString(hint);
String hexColor = String.format("0x%08x", foreground.getRGB());
saveImage(image, fontName + "-" + hintValue + "-" + hexColor);
Expand Down

7 comments on commit 00f585b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@aivanov-jdk
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk21u

@openjdk
Copy link

@openjdk openjdk bot commented on 00f585b Sep 22, 2023

Choose a reason for hiding this comment

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

@aivanov-jdk the backport was successfully created on the branch aivanov-jdk-backport-00f585bd in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 00f585bd from the openjdk/jdk repository.

The commit being backported was authored by Alexey Ivanov on 22 Sep 2023 and was reviewed by Alexander Zvegintsev, Phil Race and Goetz Lindenmaier.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git aivanov-jdk-backport-00f585bd:aivanov-jdk-backport-00f585bd
$ git checkout aivanov-jdk-backport-00f585bd
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git aivanov-jdk-backport-00f585bd

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 00f585b Sep 26, 2023

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 00f585b Sep 26, 2023

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 00f585b Sep 26, 2023

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-00f585bd in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 00f585bd from the openjdk/jdk repository.

The commit being backported was authored by Alexey Ivanov on 22 Sep 2023 and was reviewed by Alexander Zvegintsev, Phil Race and Goetz Lindenmaier.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-00f585bd:GoeLin-backport-00f585bd
$ git checkout GoeLin-backport-00f585bd
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-00f585bd

@openjdk
Copy link

@openjdk openjdk bot commented on 00f585b Sep 26, 2023

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-00f585bd in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 00f585bd from the openjdk/jdk repository.

The commit being backported was authored by Alexey Ivanov on 22 Sep 2023 and was reviewed by Alexander Zvegintsev, Phil Race and Goetz Lindenmaier.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev.git GoeLin-backport-00f585bd:GoeLin-backport-00f585bd
$ git checkout GoeLin-backport-00f585bd
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev.git GoeLin-backport-00f585bd

Please sign in to comment.