Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception using stix-fonts with openjdk?

Problem happens while i try to create SXSSFWorkbook .

Exception stacktrace :

java.lang.ArrayIndexOutOfBoundsException: 0
    at sun.font.CompositeFont.getSlotFont(CompositeFont.java:351)
    at sun.font.CompositeGlyphMapper.initMapper(CompositeGlyphMapper.java:81)
    at sun.font.CompositeGlyphMapper.<init>(CompositeGlyphMapper.java:62)
    at sun.font.CompositeFont.getMapper(CompositeFont.java:409)
    at sun.font.CompositeFont.canDisplay(CompositeFont.java:435)
    at java.awt.Font.canDisplayUpTo(Font.java:2063)
    at java.awt.font.TextLayout.singleFont(TextLayout.java:470)
    at java.awt.font.TextLayout.<init>(TextLayout.java:531)
    at FontTest.main(FontTest.java:15)

gradle file :

compile 'org.apache.poi:poi:3.14'
compile 'org.apache.poi:poi-ooxml:3.14'

Environment :

  • openjdk version "1.8.0_141"
  • RedHat 7.4
  • wildfly 10.0.0
like image 305
Ahmed Gamal Avatar asked Oct 12 '17 14:10

Ahmed Gamal


1 Answers

The issue happened only on Red hat version 7.4. it is reported there. and the Red hat guys are working to fix it here. the solution I found is just to provide the fonts in order to force back Utopia as the default font, used by java.

Create the following file /etc/fonts/local.conf with the following content:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <alias>
    <family>serif</family>
    <prefer><family>Utopia</family></prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer><family>Utopia</family></prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer><family>Utopia</family></prefer>
  </alias>
  <alias>
    <family>dialog</family>
    <prefer><family>Utopia</family></prefer>
  </alias>
  <alias>
    <family>dialoginput</family>
    <prefer><family>Utopia</family></prefer>
  </alias>
</fontconfig>

Make sure the file is readable by the correct user.

like image 117
Ahmed Gamal Avatar answered Nov 19 '22 10:11

Ahmed Gamal