Hi iText'ers,

I came across the following problem: printing Unicode with (Graphics2D)g.drawString() 
works fine on screen for all unicodes, but not using PdfGraphics2D class. I figured 
that this is due to the fact that the DefaultFontMapper used in PdfGraphics2D uses the 
font encoding CP1252. No means are provided to set the font encoding explicitly. I 
tried to write my own DefaultFontManager (which had the encoding for the basefonts set 
to IDENTITY_H or IDENTITY_V [what's the difference or reason for the two identities, 
anyhow]) but this leads (run the attached example) to the following exception, 
(encoding in DefaultFontMapper is set to BaseFont.IDENTITY_H) 

ExceptionConverter: com.lowagie.text.DocumentException: Identity-H
        at com.lowagie.text.pdf.Type1Font.<init>(Type1Font.java:252)
        at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:360)
        at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:313)
        at com.lowagie.text.pdf.DefaultFontMapper.awtToPdf(DefaultFontMapper.java:125)
        at com.lowagie.text.pdf.PdfGraphics2D.getCachedBaseFont(PdfGraphics2D.java:514)
        at com.lowagie.text.pdf.PdfGraphics2D.setFont(PdfGraphics2D.java:508)
        at com.lowagie.text.pdf.PdfGraphics2D.<init>(PdfGraphics2D.java:140)
        at com.lowagie.text.pdf.PdfContentByte.createGraphics(PdfContentByte.java:2168)
        at com.lowagie.text.pdf.PdfContentByte.createGraphics(PdfContentByte.java:2157)
        at DerivedScreen.<init>(DerivedScreen.java:50)
        at DerivedScreen.main(DerivedScreen.java:72)


This stack trace raises several questions: 
Why is it trying to create a Type1Font? I'm only using arial.ttf, don't I? 
What would be the proposed way to give the user a chance for changing the encoding? 
The best (most convenient for the user) would be, if PdfGraphics2D.drawString() would 
switch encoding (and associated BaseFont) if a Unicode character outside the current 
encoding is encountered. Are there any means for that? 

Thanks for any help and cheers
Erwin





Attachment: DerivedScreen.java
Description: DerivedScreen.java

Reply via email to