Hi,

Sorry for the delay. I’m having issues with your patch file. Can you regenerate 
it using "svn diff” based on the latest HEAD?

I’ll have time in the next few days to run a few tests and commit it.

Thanks

-- 
Palmer Zent

On October 15, 2015 at 3:40:56 AM, Nenad Novak (nenad.no...@gmail.com) wrote:

Hi Palmer,  

Attached is a patch for TrueType font sub-setting. Now you can use  
single byte encoding like WinAnsiEncoding. Difference encoding should  
work too.  

Using a PdfString constructor with explicitly specified encoding is  
preferred way to supply text. Otherwise there can be surprises, as  
default string encoding (GlobalDocEncoding) might produce different  
unicode characters then WinAnsi or MacRoman encoding when you are  
using characters out of 0x20-0x7f range.  

I do not see any advantages of using single byte encoding instead of  
Identity, because if you would like to draw some strange characters  
from win-1250 code page like "scaron/ccaron" /* šč */, then you have  
to use differences anyway.  

const PdfEncoding* textEncoding =  
PoDoFo::PdfEncodingFactory::GlobalWinAnsiEncodingInstance();  

fontEncoding = PoDoFo::PdfEncodingFactory::GlobalWinAnsiEncodingInstance();  
pdfFont = pdf->CreateFontSubset(fontName, isBold, isItalic, false,  
fontEncoding, fontPath);  
pdfPainter.SetFont(pFont);  
pdfPainter.DrawText( x, y , PdfString("text encoded as WinAnsi",  
textEncoding););  

PdfEncodingDifference diffs;  
diffs.AddDifference( 0x0041, 0, PdfName("a") );  
diffs.AddDifference( 0x0061, 0, PdfName("A") );  

PdfEncoding* diffEnc = new PdfDifferenceEncoding( diffs,  
PdfDifferenceEncoding::eBaseEncoding_WinAnsi, &pdfDoc, true );  
pFont = pdfDoc.CreateFontSubset(fontName, isBold, isItalic, false, diffEnc);  
pdfPainter.SetFont(pFont);  
pdfPainter.DrawText( x, y , PdfString("abAB"));  


>  
> If I apply the patch and run the same test, the result is a corrupted PDF 
> file (according to Adobe Reader: Invalid font data).  
>  
>  
> fontEncoding = PoDoFo::PdfEncodingFactory::GlobalWinAnsiEncodingInstance();  
> pdfFont = pdf->CreateFontSubset(fontName, isBold, isItalic, false, 
> fontEncoding, fontPath);  
>  
>  
> Do you think you could look into this?  
------------------------------------------------------------------------------
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to