Run this program:

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Font fonts[] = ge.getAllFonts();
for (int k = 0; k < fonts.length; ++k)
    System.out.println(fonts[k].getFontName() + " * " + fonts[k].toString());

and check that you really have the font recognized by java.

Paulo 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Piotr Górski
> Sent: Tuesday, April 04, 2006 9:19 AM
> To: [email protected]
> Subject: Re: [iText-questions] polish fonts in drawString() method
> 
> Hi,
> Thanks for your help.
> But I have not any results :(
> 
> Here is my code:
> 
> *import* java.io.FileOutputStream;
> 
> *import* com.lowagie.text.Document;
> *import* com.lowagie.text.PageSize;
> *import* com.lowagie.text.pdf.PdfContentByte;
> *import* com.lowagie.text.pdf.PdfWriter;
> *import* com.lowagie.text.DocumentException;
> *import* com.lowagie.text.FontFactory;
> *import* com.lowagie.text.pdf.DefaultFontMapper;
> *import* com.lowagie.text.pdf.PdfTemplate;
> *import* com.lowagie.text.pdf.PdfGraphics2D;
> *import* com.lowagie.text.pdf.BaseFont;
> *import* com.lowagie.text.*;
> *import* com.lowagie.text.pdf.*;
> 
> *import* java.io.*;
> *import* java.util.*;
> *import* java.awt.*;
> *import* java.awt.image.*;
> 
> */***
> * * Draws arabic text using java.awt.Graphics2D*
> * */*
> *public* *class* PolishText {
> 
>       */***
> *      * Draws arabic text using java.awt.Graphics2D.*
> /     /***/ /[EMAIL PROTECTED] */args //no arguments needed/
> /     /**/*
>     *public* static void main(*String*[] args) {
>         *System*.out.println("Polish Text.");
>       /// step 1/
>         *Document* document = *new* *Document*(PageSize.A4, 
> 50, 50, 50, 50);
>         *try* {
>               /// step 2/
>             PdfWriter writer = 
> PdfWriter.getInstance(document, *new* 
> *FileOutputStream*("polishtext.pdf"));
>             /// step 3/
>             document.open();
> 
>             DefaultFontMapper mapper = *new* DefaultFontMapper();
>             ///read all the fonts in the directory/
>             mapper.insertDirectory("/usr/local/font");
>             ///change the encoding of font "MS PGothic"/
>             DefaultFontMapper.BaseFontParameters pp = 
> mapper.getBaseFontParameters("LuxiSans");
>             *if* (pp != *null*)
>                 pp.encoding = BaseFont.IDENTITY_H;
> 
> 
>             /// step 4/
>             *String* text1 = "Some polish characters ???? 
> \u0104\u0107\u0119\u1042\u0144\u00F3\u015B\u017A\u017C";
>             java.awt.Font font = *new* 
> java.awt.Font("LuxiSans", java.awt.Font.PLAIN, 23);
>             PdfContentByte cb = writer.getDirectContent();
>             *Graphics2D* g2 = 
> cb.createGraphics(PageSize.A4.width(), PageSize.A4.height());
> 
>             g2.setFont(font);
>             g2.drawString(text1, 50, 100);
>             g2.drawString(text1, 50, 120);
>             g2.drawString(text1, 50, 140);
>             g2.drawString(text1, 50, 160);
>             g2.drawString(text1, 50, 180);
>             g2.dispose();
>             /// step 5/
>             document.close();
>         }
>         *catch* (*Exception* de) {
>             de.printStackTrace();
>         }
>     }
> 
> }
> 
> 
> Moreover I tried with another names like: Luxi Sans, Luxi 
> Sans Regular, 
> LuxiSans ...
> 
> What I did wrong ?
> Regards,
> Piotr Górski
> 
> Paulo Soares wrote:
> 
> >Have a look at 
> http://prdownloads.sourceforge.net/jfreechart/jfreechart2pdf-v
> 2.pdf?download. It's for CJK fonts but the same principle 
> applies to polish fonts.
> >
> >Paulo 
> >
> >  
> >
> >>-----Original Message-----
> >>From: [EMAIL PROTECTED] 
> >>[mailto:[EMAIL PROTECTED] On 
> >>Behalf Of Piotr Górski
> >>Sent: Monday, April 03, 2006 1:34 PM
> >>To: [email protected]
> >>Subject: [iText-questions] polish fonts in drawString() method
> >>
> >>Hi,
> >>I am able to print polish fonts in pdf with:
> >>String text = "Some polish characters: \u0105\u0107\u00f3\u017c"
> >>document.add(new Paragraph(text,font));
> >>
> >>I also can generate polish characters through:
> >>Graphics2D g2d = cb.createGraphicsShapes(w,h);
> >>But quality of printed strings is too low.
> >>
> >>I have to print those strings with drawString() method in 
> >>awt.java.Graphics2D or com.lowagie.text.pdf.PdfGraphics2D
> >>I tried almost everything which I found on mailing lists and google.
> >>
> >>Unluckily with no result.
> >>Of course I have a true type font with polish characters.
> >>
> >>Is there any working solution ? I will be really grateful.
> >>Best Regards,
> >>Piotr Górski
> >>
> >>
> >>-------------------------------------------------------
> >>This SF.Net email is sponsored by xPML, a groundbreaking 
> >>scripting language
> >>that extends applications into web and mobile media. Attend 
> >>the live webcast
> >>and join the prime developer group breaking into this new 
> >>coding territory!
> >>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&;
> >>dat=121642
> >>_______________________________________________
> >>iText-questions mailing list
> >>[email protected]
> >>https://lists.sourceforge.net/lists/listinfo/itext-questions
> >>
> >>    
> >>
> >
> >  
> >
> 
> 


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to