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);
}
}
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???
-------------------------------------------------------------------------
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/