Search code examples
javajavafxtruetypeapache-fop

OTF files modified after compilation


This is something very weird and I am sure I am doing something wrong, but I don't know what.

I have a few OTF files on src/main/resources/report/fonts. These files are correct and work fine, but when I compile the application, they are modified (the size of the files increases 2x) and they are not valid anymore.

I am using Apache FOP and I get the following errors:

2014-05-27 11:34:30,145 [JavaFX Application Thread] ERROR org.apache.fop.fonts.truetype.TTFFile - Dirtab head not found.
2014-05-27 11:34:30,145 [JavaFX Application Thread] ERROR org.apache.fop.fonts.truetype.TTFFile - Dirtab maxp not found.
2014-05-27 11:34:30,145 [JavaFX Application Thread] ERROR org.apache.fop.fonts.truetype.TTFFile - Dirtab hhea not found.
2014-05-27 11:34:30,145 [JavaFX Application Thread] ERROR org.apache.fop.fonts.truetype.TTFFile - Dirtab hmtx not found

Now, if I, mannually change the fonts for the original files, everything works like a charm.

What is wrong? I have other files on the same folder and they are not modified.

UPDATE

This is how I am loading it, but I don't think the loading is the problem because, if I change the files for the original ones, it works.

fopFactory.getFontManager().setFontBaseURL(getClass().getClassLoader().getResource("report/").toString().replace(":/", ":///"))

Solution

  • It turned out this was a maven problem. You have to select the extensions of the files you are going to include. I knew this, but I did not remember I had done this in the past:

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <excludes>
                    <exclude>**/*.otf</exclude>
                    <exclude>**/*.ttf</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <includes>
                    <include>**/*.otf</include>
                    <include>**/*.ttf</include>
                </includes>
            </resource>
        </resources>