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

[Build] testFontStyleOfStyledFont causes builds to fail with default Maven configuration on OSX 13.0 and higher #1158

Open
kurt-r2c opened this issue Apr 30, 2024 · 5 comments
Labels

Comments

@kurt-r2c
Copy link

kurt-r2c commented Apr 30, 2024

Describe the bug

On OS X Ventura (13.0) or later, the Courier font is missing its OS/2 table, probably due to licensing decisions made by Apple.

This causes the testFontStyleOfStyledFont test to fail:

void testFontStyleOfStyledFont(int style) {
final Font font = FontFactory.getFont(FONT_NAME_WITH_STYLES, DEFAULT_FONT_SIZE, style);
// For the font Courier, there is no Courier-Underline or Courier-Strikethrough font available.
if (style == Font.UNDERLINE || style == Font.STRIKETHRU) {
assertEquals(style, font.getStyle(), "Style: " + style);
} else {
assertEquals(style, font.getCombinedStyle(), "Total style should be the given style: " + style);
assertEquals(font.getBaseFontStyle(), style ^ font.getCalculatedStyle(), "Styles should not repeat in"
+ " Font and BaseFont.");
}
}

To Reproduce

Run mvn clean install on OSX 13.0 or newer. The build will fail due to an exception com.lowagie.text.DocumentException: Table 'OS/2' does not exist in /System/Library/Fonts/Courier.ttc in testFontStyleOfStyledFont.

Setting maven.test.failure.ignore to true allows you to build the project but, for obvious reasons, this is a bad workaround for anything other than trivial changes.

Expected behavior

It would be nice if this test failed gracefully if the font is not present or readable on the system.

System

(please complete the following information)

  • OS: [e.g. iOS] macOS 14.4.1
  • Used font: Courier
  • OpenPDF version: 2.0.2 (master branch - 0a92bcc)
  • Java version: openjdk 21.0.2

Your real name

Kurt Boberg

@kurt-r2c kurt-r2c added the bug label Apr 30, 2024
@asturio
Copy link
Member

asturio commented May 4, 2024

Which version of maven are you using:

mvn -version

@kurt-r2c
Copy link
Author

@asturio 3.9.6

@asturio
Copy link
Member

asturio commented May 27, 2024

I'd like to find a font provided by all OS.
Are there any other Mac-Users who can confirm, that this test also fails on their computer?
Which font could be used instead.
Alternatively, the test could be disabled on MacOS.

@asturio
Copy link
Member

asturio commented May 27, 2024

Just checked, that courier is also bundled with OpenPDF. So even a more strange behavior here.

asturio pushed a commit that referenced this issue May 27, 2024
- Added beforeAll() and registered the directories before all tests.
@asturio
Copy link
Member

asturio commented May 27, 2024

The call of FontFactory.registerDirectories(); was made only in one of the tests. It could be, that the order of the tests are different in MacOS, and this call is necessary for all.

I just commited a little change. @kurt-r2c, can you please try, if the test passes now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants