Title: PS Renderer ttf Font update + work around

Hello all:

This is a follow up message that contains only information, and my work around to not be able to embed a font in the ps renderer.

I thought I would pass this message on to any of those who are struggling with the ps renderer and embedding fonts. As the documentation states the ps renderer does not support the "embedding" of fonts.

My problem was this. I needed to have my ps document have a line of text in it that used OCRAExtended font. After some reading on how to embed fonts. I configured my fop to use the pfb I created from the ttf. Ssee below for links to programs etc.. (here is were I fell apart) I was blissfully coding along, when I decided to test my output as a ps file, previously i was only outputting pdf files (I know I know dangerous practice.. I have learned). No Font.... after some reading a quick post to the group... I learned that font embedding is not supported in the ps renderer.

There are 2 possible work around for this:

ONE:
 process pdf files, and convert them to ps files post rendering.

setup:
        you will need to have the ttf file for you font
        create you fontmetrics file.
        java -cp  <YOUR_CLASSPATH_HERE> org.apache.fop.fonts.apps.TTFReader ttf-file xml-file

        Configure FOP to use your fontmetrics file...
       
        my configuration file:
                <fonts>
                        <font metrics-file="<SOMEPATH>/ocraext.xml"
                        kerning="yes" embed-file="<SOMEPATH>/ocraext.ttf">
                                <font-triplet name="ocraext" style="normal" weight="normal"/>
                </font>

  (see FOP Font page: http://xml.apache.org/fop/fonts.html#type1)
               
 d-load ghostscript (or another converter, I used ghostscript see below)
 get fop to produce your pdf files.
 for each pdf file you will have execute <GS_INSTALL>\lib\pdf2ps.bat ${infile} ${outfile}
 I wrote a service to accomplish the call to pdf2ps.
 
While this did accomplish what I needed, there was an extremely big price to pay in terms of performance. This approached double my processing time. Where I used to be able to push trough 1000 bills in 20min, this jumped to 40mins


TWO:
 install a Type 1 Font on the printer, and have my ps file reference it.

setup:
        you will need to have the pfm, and pfb file for the following steps
        create you fontmetrics file.
        java -cp <YOUR_CLASSPATH_HERE> org.apache.fop.fonts.apps.PFMReader pfm-file xml-file
        Configure FOP to use your fontmetrics file...
       
        my configuration file:
                <fonts>
                        <font metrics-file="<SOMEPATH>/ocraext.xml"
                        kerning="yes" embed-file="<SOMEPATH>/ocraext.pfb">
                                <font-triplet name="ocraext" style="normal" weight="normal"/>
                </font>
               
  (see FOP Font page: http://xml.apache.org/fop/fonts.html#type1)              
       
        The key difference here is that FOP will not embed the font in the ps files it renders rather, it will create a reference to it in the ps File such as:

   %%BeginResource: procset FOPFonts
   %%Title: Font setup (shortcuts) for this file
   /FOPFonts 100 dict dup begin
   <.. removed for brevity ..>
   /F11 /Courier-Bold def
   <.. removed for brevity ..>
   /F15 /OCRAExtended def
   end def
   %%EndResource
  
   So from now on all text with F15 precedding it in the ps file  will be OCRAExtended
  
 to use the font in my stylesheet, it is a simple as:
 
 <fo:block font-family="ocraext">some text in a wacky font</fo:block>
 
 the name used in the font-family attribute is the name you give the font in the userconfig.xml file (see above, my example of the configuration) .

  
This accomplished what I needed, and I was able to keep the performacne I was accustom to.     
  
Rob    

ttf2pfb converter:
http://ttf2pt1.sourceforge.net/

ps viewer/and tools
http://www.cs.wisc.edu/~ghost/

FOP font page:
http://xml.apache.org/fop/fonts.html#type1


Reply via email to