You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Tilman Hausherr <TH...@t-online.de> on 2015/10/10 13:36:58 UTC

using a TT font from a TTC file

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


Re: using a TT font from a TTC file

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,

Am 10.10.2015 um 19:58 schrieb titto agustine:
> A suggestion to solve issue.
> Use TrueType   PDTrueType and pass the input steam to the load method.
The goal was to use a ttc instead of a "simple" ttf. PDFBOX-3018 [1] adds 
support for using ttc.

BR
Andreas

[1] https://issues.apache.org/jira/browse/PDFBOX-3018
>
> Regards
> Augustine
> Sent from my iPhone
>
>> On Oct 10, 2015, at 7:35 PM, Andreas Lehmkuehler <an...@lehmi.de> wrote:
>>
>> PDType0Font
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


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


Re: using a TT font from a TTC file

Posted by titto agustine <ti...@hotmail.com>.
A suggestion to solve issue. 
Use TrueType   PDTrueType and pass the input steam to the load method.

Regards
Augustine 
Sent from my iPhone

> On Oct 10, 2015, at 7:35 PM, Andreas Lehmkuehler <an...@lehmi.de> wrote:
> 
> PDType0Font

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


Re: using a TT font from a TTC file

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,

Am 10.10.2015 um 13:36 schrieb Tilman Hausherr:
> 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.

Looks like a bug. ttFont.getOriginalData() returns the data of the underlying 
ttc instead of the single ttf.

> Tilman

BR
Andreas


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