pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject using a TT font from a TTC file
Date Sat, 10 Oct 2015 11:36:58 GMT
I tried this to answer this question:
http://stackoverflow.com/questions/33044069/pdfbox-2-0-and-ttc-fonts

         TrueTypeCollection trueTypeCollection = new 
TrueTypeCollection(new File("c:/windows/fonts/MSGothic.ttc"));
         TrueTypeFont ttFont = null;
         for (TrueTypeFont font : trueTypeCollection.getFonts())
         {
             if ("MS-Gothic".equals(font.getName()))
             {
                 ttFont = font;
             }
         }
         if (ttFont == null)
         {
             return;
         }
         PDType0Font font = PDType0Font.load(document, 
ttFont.getOriginalData(), true);

Exception in thread "main" java.io.IOException: head is mandatory
     at org.apache.fontbox.ttf.TTFParser.parseTables(TTFParser.java:176)
     at org.apache.fontbox.ttf.TTFParser.parse(TTFParser.java:145)
     at org.apache.fontbox.ttf.TTFParser.parseEmbedded(TTFParser.java:119)
     at 
org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder.buildFontFile2(TrueTypeEmbedder.java:89)
     at 
org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder.<init>(TrueTypeEmbedder.java:72)
     at 
org.apache.pdfbox.pdmodel.font.PDCIDFontType2Embedder.<init>(PDCIDFontType2Embedder.java:61)
     at 
org.apache.pdfbox.pdmodel.font.PDType0Font.<init>(PDType0Font.java:120)
     at org.apache.pdfbox.pdmodel.font.PDType0Font.load(PDType0Font.java:89)

Is this a bug, or is this a misunderstanding by me, i.e. that this isn't 
assumed to work this way? I am able to save these streams and display 
them with Windows font preview.

Tilman



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message