> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of David Thielen
> Sent: Thursday, April 12, 2007 4:44 PM
> To: itext
> Subject: [iText-questions] Second attempt - how should I get a font
> 
> 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.
>

In other words, don't believe in the rtf codepage.
 
>  
> 
> 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

I don't know if that's the best way, it's a matter of choice. Identity-H
will always work with TTF fonts and will access all the characters, on
the other hand you could check all the text and find that cp1252 could
be enough. Your choice.
 
> 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 

You should talk with Kazuya Ujihara about that, not us. It works well in
iText and iTextSharp.

> would like to have embedding be an option.
> 

Identity-H will always embedd.

>  
> 
> 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?
> 

cp1252 should work or better yet Identity-H.

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.


-------------------------------------------------------------------------
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/

Reply via email to