Hi,

How it looks with this? Would be better if I create tickets on sourceforge?

I am sending test case:

```
PdfMemDocument doc;
PdfPage *page = doc.CreatePage({0, 0, 500, 800});
PdfFont *font = doc.CreateFont("Verdana", false, false, false,
PdfEncodingFactory::GlobalIdentityEncodingInstance());
PdfPainter p;
p.SetPage(page);
p.SetFont(font);
p.DrawText(10, 780, (const pdf_utf8*)"ČŘĎ");
p.FinishPage();
doc.Write("doc.pdf");
printf("Width of 'ČŘĎ' using newly created font is: %f\n",
font->GetFontMetrics()->StringWidth((const pdf_utf8*)"ČŘĎ"));

PdfMemDocument doc2("doc.pdf");
PdfPage *page2 = doc2.GetPage(0);
PdfFont *font2 = doc2.GetFont(page2->GetFromResources("Font",
font->GetIdentifier()));
PdfPainter p2;
p2.SetPage(page2);
p2.SetFont(font2);
p2.DrawText(10, 760, (const pdf_utf8*)"ČŘĎ");
p2.FinishPage();
doc2.Write("doc2.pdf");
printf("Width of 'ČŘĎ' using loaded font is: %f\n",
font2->GetFontMetrics()->StringWidth((const pdf_utf8*)"ČŘĎ"));
```

Output:
```
Width of 'ČŘĎ' using newly created font is: 25.968750
Width of 'ČŘĎ' using loaded font is: 19.452000
```

This is slightly modified version of test case for bug described in email
with subject "Bug when drawing text using truetype font with difference
encoding loaded from pdf". Difference is that here I am
using GlobalIdentityEncodingInstance instead of
GlobalWin1250EncodingInstance because to fix this also for difference
encoding is needed to also fix that other bug.

Actually output which I mentioned in that other email:
```
Width of 'ČŘĎ' using newly created font is: 25.968750
Width of 'ČŘĎ' using loaded font is: 36.000000
```

Would be:
```
Width of 'ČŘĎ' using newly created font is: 25.968750
Width of 'ČŘĎ' using loaded font is: 0.000000
```

Without patch in this email chain.


On Wed, Dec 5, 2018 at 8:34 PM Michal Sudolsky <sudols...@gmail.com> wrote:

> Patch with corrected indentation attached.
>
> On Wed, Dec 5, 2018 at 8:31 PM Michal Sudolsky <sudols...@gmail.com>
> wrote:
>
>> Proposed patch attached.
>>
>> It follows something similar what is doing ConvertToEncoding in its core.
>> Now widths of all font supported unicode chars are correctly obtained. I
>> also deduplicated PdfFontMetricsObject::CharWidth as it does same thing as
>> UnicodeCharWidth and left GetGlyphWidth unimplemented as this would require
>> converting glyph to cid for cid encoding.
>>
>>
>> On Wed, Nov 28, 2018 at 11:39 PM Michal Sudolsky <sudols...@gmail.com>
>> wrote:
>>
>>> PdfFontMetricsObject::UnicodeCharWidth returns width for CID instead of
>>> unicode char (like does PdfFontMetricsFreetype and PdfFontMetricsBase14).
>>> Maybe it can be fixed by converting unicode char into CID using
>>> m_pEncoding->GetCIDValue (after few modifications). And implement also
>>> PdfFontMetricsObject::GetGlyphId. Body of UnicodeCharWidth could be
>>> implementation of PdfFontMetricsObject::GetGlyphWidth. Actually W contains
>>> CIDs and not glyphs so GetCIDValue may work for UnicodeCharWidth but I am
>>> not sure about GetGlyphId and GetGlyphWidth if encoding or CIDToGIDMap is
>>> not identity.
>>>
>>>
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to