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

Could not initialize class org.docx4j.fonts.IdentityPlusMapper on loading AppleSDGothicNeo.ttc font for MacOs + java 11 #590

Open
llmartinll opened this issue Aug 27, 2024 · 0 comments

Comments

@llmartinll
Copy link

llmartinll commented Aug 27, 2024

Good day

This is the first time trying to check out and run the project.
After a cloning the project and running mvn clean install on

I noticed that the RunFontSelectorCalibriCheckBoxTest fails

java.lang.NoClassDefFoundError: Could not initialize class org.docx4j.fonts.IdentityPlusMapper
	at org.docx4j.openpackaging.packages.WordprocessingMLPackage.getFontMapper(WordprocessingMLPackage.java:375)
...
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.RuntimeException: java.lang.NullPointerException: Cannot invoke "org.docx4j.fonts.fop.fonts.CustomFont.getStrippedFontName()" because "customFont" is null [in thread "main"]
	at org.docx4j.fonts.IdentityPlusMapper.<clinit>(IdentityPlusMapper.java:77)
	at org.docx4j.openpackaging.packages.WordprocessingMLPackage.getFontMapper(WordprocessingMLPackage.java:375)
	at org.docx4j.fonts.RunFontSelectorCalibriCheckBoxTest.testFont(RunFontSelectorCalibriCheckBoxTest.java:64)

When debugging via Intellij and found out it breaks on loading in the physical font AppleSDGothicNeo which is included by default in mac os in /System/Library/Fonts

This issue might be the same issue as #507 but there's little information there.

The test breaks on loading in IdentityPlusMapper , after trying to load in the discoveryPhysicalFonts which tries to add the font file:/System/Library/Fonts/AppleSDGothicNeo.ttc for which no customFont can be determined at


which re-sets customFont to null which causes code further down the chain to throw.

In attempt to find out why it could not load the font; I found out that it throws an IO exception at

OpenFont otf = (isCFF) ? new OTFFile(useKerning, useAdvanced) : new TTFFile(useKerning, useAdvanced);

isCFF being false, it will call new TTFFile(userKerning: true, useAdvanced: false) and throw with error message

'loca' table not found, happens when the font file doesn't contain TrueType outlines (trying to read an OpenType CFF font maybe?)

This is where I ended up.

I'm not very knowledgeable about font types but the structure of this font appears to be different than other system fonts
From what I can gather online, it's a font for the Korean language.

@llmartinll llmartinll changed the title RunFontSelectorCalibriCheckBoxTest failing on loading AppleSDGothicNeo.ttc font for MacOs + java 11 Could not initialize class org.docx4j.fonts.IdentityPlusMapper on loading AppleSDGothicNeo.ttc font for MacOs + java 11 Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant