I have never had a problem with losing default fonts when I add my custom
fonts in the manner described (if I am wrong I am certain I will be
corrected).

As an alternative, you can add the font to your userconfig.xml file, in the
"fonts" section:

<fonts>
  <font metrics-file="fre3of9x.xml" embed-file="fre3of9x.ttf"
kerning="yes">
    <font-triplet name="BarCode" style="normal" weight="normal"/>
    <font-triplet name="BarCode" style="normal" weight="bold"/>
    <font-triplet name="BarCode" style="italic" weight="normal"/>
    <font-triplet name="BarCode" style="italic" weight="bold"/>
 </font>
</fonts>

-Lou



                                                                                
                                                                   
                      Raśl Herranz                                              
                                                                   
                      Serrano                  To:      <[EMAIL PROTECTED]>     
                                                             
                      <[EMAIL PROTECTED]         cc:                            
                                                                     
                      es>                      Subject: Re: how to add a font 
to generate bar codes in my pdfs?                                    
                                                                                
                                                                   
                      10/25/2004 11:56                                          
                                                                   
                      Please respond                                            
                                                                   
                      to fop-user                                               
                                                                   
                                                                                
                                                                   
                                                                                
                                                                   



Thanks for your answer... but I have got a question:

Do I overwrite the rest of the fonts (the deafult fonts, I mean...) with
the
line "Configuration.put("fonts", allFonts);"?

Thanks again!

    Raul (Spain)

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 25, 2004 5:17 PM
Subject: Re: how to add a font to generate bar codes in my pdfs?



It looks like you have the font file ready to go.  To get a barcode in the
PDF, I did the following:

1.  First, here is some sample java code to configure the fonts (you would
probably want to do this dynamically (read better):

Vector allFonts = new Vector();//you may have more than one
Vector allTrips = new Vector();

allTrips.add(new FontTriplet("fre3of9x","normal","normal"));
allTrips.add(new FontTriplet("fre3of9x","bold","normal"));
allTrips.add(new FontTriplet("fre3of9x","normal","italic"));
allTrips.add(new FontTriplet("fre3of9x","bold","italic"));
FontInfo fontInfo = new FontInfo("3OF9X","/fonts/fre3of9x.xml"
,true,allTrips,"/fonts/fre3of9x.ttf");//sample font
allFonts.add(fontInfo);

Configuration.put("fonts", allFonts);


2.  Next, create a text block that uses your barcode font family:

<fo:block font-size="10pt" color="black" font-family="fre3of9x">
112233
</fo:block>

This works for me.

-Lou




                      Raśl Herranz
                      Serrano                  To:
<[EMAIL PROTECTED]>
                      <[EMAIL PROTECTED]         cc:
                      es>                      Subject: how to add a font
to
generate bar codes in my pdfs?

                      10/25/2004 11:06
                      Please respond
                      to fop-user





Hi there!

I have the following method in a Servlet that helps me to output pdf files:


    private ByteArrayOutputStream transform(Source xmlSrc, Source xslSrc)
            throws TransformerConfigurationException, TransformerException
{
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        org.apache.fop.configuration.Configuration.put("baseDir",
BASE_DIR);
        Driver driver = new Driver();
        Logger logger = new Log4JLogger(log4j);
        MessageHandler.setScreenLogger(logger);
        driver.setLogger(logger);
        driver.setRenderer(Driver.RENDER_PDF);
        driver.setOutputStream(out);
        TransformerFactory transformerFactory =
TransformerFactory.newInstance();
        Transformer transformer =
transformerFactory.newTransformer(xslSrc);
        Result res = new SAXResult(driver.getContentHandler());
        transformer.transform(xmlSrc, res);
        return out;
    }

The problem is that right now I need to generate some bar codes in my pdfs
and I have think to embed a ttf font in my pdfs that I can use to generate
those barcodes. I have the ttf font file and the xml font metrics file but
right now I don“t know what must I add to the code to be able to use this
font in my pdfs... can you help me?

Thanks a lot!!

    Raul (Spain)






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to