#1 Full imbedding TrueType fonts into PDF

closed
nobody
None
5
2012-06-19
2011-05-12
No

Hello.

See: https://sourceforge.net/tracker/?func=detail&aid=3299854&group_id=203731&atid=986773

I checked the meantioned class from jPodRenderer but I ran into troubles.
I produced the following code:

Face face = new ?
GenericFont gFont = GenericFont.createNew(new
FileLocator("./Rostock.ttf"), );
FontConverterCwt2Pdf conv = new FontConverterCwt2Pdf(gFont);
conv.getPdFont()....

The Face class seems to be a wrapper which stores several contents from
the TTF file. But I couldn't find any existing routines who process the
font file. Am I right in assuming that I have to implement this code or is
there a proper routine in another class?

Discussion

  • mtraut
    mtraut
    2011-05-13

    Face is part of the Freetype native binding. You need this to parse the font program. The Freetype binding is part of the dependencies with jPodRenderer. After adding to the classpath, in theory you can act on the API directly.

    More convenient is the use of the IFontFactory as shown in the DrawTextTryType example with jPod. With jPodRenderer on the classpath the StandardFontFactory will be used, with embedding as the default.

    <code>

    IFontFactory factory = FontOutlet.get().lookupFontFactory(getDoc());
    FontQuery query;
    PDFont font;
    float fontSize;

    // open a device to the page content stream
    CSCreator creator = CSCreator.createNew(page);
    //
    query = new FontQuery("Comic Sans MS", ""); //$NON-NLS-1$ //$NON-NLS-2$
    try {
    font = factory.getFont(query);
    } catch (FontFactoryException e) {
    e.printStackTrace();
    return;
    }
    fontSize = 20f;
    //
    creator.textSetFont(null, font, fontSize);
    creator.textLineMoveTo(100, 700);
    creator.textShow("Hello, world."); //$NON-NLS-1$
    </code>

    Using the PlatformFonTools you can manage the embedding of fonts in an already exisiting document.

     
  • mtraut
    mtraut
    2012-06-19

    • status: open --> closed