Hi;
When I write blocks of text using ColumnText.showTextAligned(). When
calling this I need to pass it a new Phrase(someText, font) where font
is a com.lowagie.text.Font.
All of the text I get from parsing a rtf file. For each block of text I
know the font name, family, and codepage as rtf has that set for each
run of text. Generally all of the text is in the codepage such as a
block that is "hi there" with codepage 1252 and font Arial. However, a
block could be "this is Chinese \u6FC9" and still be marked codepage
1252. If the font is Arial the glyph is in the font so everything needed
is there to display that string.
My questions is how best to create the Font I need for new Phrase(). At
present my code is:
// fontName is the name of the font - like Arial
// internalName is the closest embedded Acrobat font like Helvitica
// embed is true if the font should be embedded
// codepage is the codepage of the text
BaseFont getBaseFont(String fontName, String internalName, float size,
boolean embed, int codepage) {
Font font = FontFactory.getFont(fontName, BaseFont.IDENTITY_H, embed,
size, 0);
if ((font != null) && (font.getBaseFont() == null))
return font.getBaseFont()
font = FontFactory.getFont(fontname, codepage, embed, 24, 0);
if ((font != null) && (font.getBaseFont() != null))
font.getBaseFont()
return FontFactory.getFont(internalName, codepage,
BaseFont.NOT_EMBEDDED);
}
...
// Get BaseFont as that method is used in other places as we go
Font->BaseFont->Font here
BaseFont bf = getBaseFont("Arial", "Helvetica", 12, true, 1252);
Font fnt = new Font(bf, 12);
Is the above the best way to get the fonts I need? The IDENTITY_H is
causing me problems in the iTextDotNet version - but I need to use the
same code in both Java and J#. I also would like to have embedding be an
option.
I also have to handle the case where the font could be something like
Wingdings2 where there is no unicode value for the glyphs. In this case
all characters have a value of 0x00 - 0xFF and the font has glyphs for
that same range. In that case I presently or an 0x8000 to each char so
they are then in the range if 0x8000 - 0x80ff which tells the font
system to take the low byte and map it direct to the glyph. For this
case how should I generate my font?
Thanks - dave
David Thielen
www.windwardreports.com
303-499-2544 x1185
Cubicle Wars - http://www.windwardreports.com/film.htm
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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/