> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Gregan, Miroslav
> Sent: Wednesday, January 16, 2008 9:17 AM
> To: [email protected]
> Subject: [iText-questions] About defaultFontMapper.awtToPdf
> 
> Hi all,
>  
> I'm new iText user, and I have some fonts problems.
> I need to write texts in many different languages using 
> different alphabet,
> and I want to be polyvalent, and friendly user so I though I 
> could use the System default font.
>  
> This is the String I would like to test:
> ĚŠČŘŽÝÁÍÉÚěščřžýáíéúů
>  
> Having the program running under Eclipse 3.3, I have tested 
> the following code :
>  
> private BaseFont getSystemFont() {
>   DefaultFontMapper defaultFontMapper = new DefaultFontMapper();
>   Display display = PlatformUI.getWorkbench().getDisplay();
>   FontData[] swtFontData = display.getSystemFont().getFontData();
>   String defaultSystemFontName = "";
>   if (swtFontData.length > 0) {
>     defaultSystemFontName = swtFontData[0].getName();
>     java.awt.Font[] defaultAwtFonts = 
> GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
>     for (java.awt.Font awtFont : defaultAwtFonts) {
>       if (awtFont.getName().equalsIgnoreCase(defaultSystemFontName)) {
>         return defaultFontMapper.awtToPdf(awtFont);
>       }
>     }
>   }
>   return FontFactory.getFont(FontFactory.TIMES).getBaseFont();
> }
>  
> The font I got is Tahoma, I don't know if it supports the 
> character I need,
> but the program does, so I guess it should but I got:
> ŠŽÝÁÍÉÚšžýáíéú
>  
>  
> So, to be sure I tested it with an UNICODE font instead, the 
> code was changed like this:
>  
>     for (java.awt.Font awtFont : defaultAwtFonts) { 
>       if (awtFont.getName().equalsIgnoreCase("Arial Unicode 
> MS")){ //defaultSystemFontName)) {
>         return defaultFontMapper.awtToPdf(awtFont);
>       }
>     }
> 

You'll also have to change the encoding to Identity-H otherwise you'll get 
cp1252 and it won't work.
See http://downloads.sourceforge.net/jfreechart/jfreechart2pdf-v2.pdf.
 
> The font is found but the String remains:
> ŠŽÝÁÍÉÚšžýáíéú
>  
>  
> So I test it by hard coding it :(((
>  
> FontFactory.register("C:\\WINNT\\Fonts\\ARIALUNI.TTF");
> return FontFactory.getFont("Arial Unicode MS", 
> BaseFont.IDENTITY_H, PdfConstants.FONT_SIZE_NORMAL).getBaseFont();
>  
> And I got the correct finally:
> ĚŠČŘŽÝÁÍÉÚěščřžýáíéúů
>  
>  
> So my question are:
>  
> Is there anyway to have it working like I would like to (use 
> the same font like Eclipse does)?
>  
> Just to know more about it... 
> Does someone know why it working this way?
> Is the awt.font only a subset of the original font, or does 
> the defaultFontMapper.awtToPdf only read a subset of it?
>  
> BTW, hard coding Tahoma, doesn't give me the correct text, it 
> means that this font doesn't support the chars I want to print...
> so how does Eclipse manage to print me the correct characters???
> 

Java has access to all the system fonts and when some font doesn't have the 
char it choses another font to replace it.

Paulo


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to