2.10.2015. u 19:18, zyx je napisao/la:
> I skipped that and run `make` which results in a build failure:

True, now patches should be OK.

I have played again (on trunk) with recent (more/or less) changes to
PdfEncodings and PdfIdentityEncoding which have made broken generation of a new
PDF files which are using this encoding.

[r1679] <http://sourceforge.net/p/podofo/code/1679/> (78.9 kB) by pzent

Moved /ToUnicode processing to PdfEncoding so it applies to all encodings by 
default
Attempt at fixing some char/string width calculations in PdfFontMetrics


PdfIdentityEncoding is useless in case when you create a new PDF's. It's working
only when you edit existing PDF because in that case this encoding is fully
loaded from PdfObject. Same might apply to the PdfCMapEncoding too.

Here is constuctor for this encoding:

PdfIdentityEncoding::PdfIdentityEncoding( int nFirstChar = 0, int nLastChar =
0xffff, bool bAutoDelete = true, PdfObject* pToUnicode = NULL );

For a new PDF, pToUnicode object does not exits, and later ConvertToUnicode and
ConvertToEncoding calls will fail or return empty object as  PdfEncoding member
m_bToUnicodeIsLoaded is false, and m_toUnicode map is empty too.

If it's safe to take assumption, that m_bToUnicodeIsLoaded is true when encoding
is loaded from existing PDF, then for a new PDFs ConvertToEncoding function has
to go directly to the font related PdfFontMetrics object.

Anyhow PdfEncoding::ConvertToEncoding function first tries to get CID from
already loaded CMap (if such object exists). If there is no match found, then
second try is to get this mappings from PdfFontMetrics->GetGlyphId(lUnicode).

I believe, that it should be safe to promote m_toUncode map to protected member
and change conditions from:
    if (m_bToUnicodeIsLoaded) ...
to
    if(!m_toUnicode.empty()) ...

In the case that PDF is generated from scratch, then ConvertToEncoding has to
use font metrics, to get a glyph code from a font. PdfString class already has
an way to provide ConvertToUnicode translation.

Here are attached encoding, subset and helloworld-base14 patches.

After applying enc.patch and helloworld-base14.patch, resulting PDF should be
around 248 kB, and after subset.patch, size should drop to 54 kB.


Regards,

Attachment: subset.patch.gz
Description: GNU Zip compressed data

Attachment: enc.patch.gz
Description: GNU Zip compressed data

Attachment: hello-base14.patch.gz
Description: GNU Zip compressed data

------------------------------------------------------------------------------
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to