#691 font import problems in 5.9.153

closed
nobody
None
5
2012-10-09
2012-03-28
Jim Hanlon
No

The attached testcase illustrates a font that once imported has 7 code points (that I know of) that are 'true' according to isCharDefined() even though they aren't actually implemented by the font. Furthermore, 6 of the characters (Yacute, yacute, Thorn, thorn, Eth and eth) actually render to the wrong glyph. The seventh (hyphen) renders to the 'notdef' glyph (as one would expect).

I have several other fonts that exhibit the same problem with various other code points.

Attached find: (a) the test case code, (b) the test font, (c) output from test case, and (d) the TCPDF generated metadata file for the font which contains the code points in its 'cw' array.

Discussion

  • Jim Hanlon
    Jim Hanlon
    2012-03-28

    Test case

     
    Attachments
  • Jim Hanlon
    Jim Hanlon
    2012-03-28

    The test font

     
    Attachments
  • Jim Hanlon
    Jim Hanlon
    2012-03-28

    Test case output

     
    Attachments
  • Jim Hanlon
    Jim Hanlon
    2012-03-28

    TCPDF's metadata file for testfont

     
    Attachments
  • Nicola Asuni
    Nicola Asuni
    2012-03-29

    On the test font there is a cmap table for MAC that defines the mapping for the "missing keys":
    Platform ID = 1, Encoding ID = 0, Format 6 = Trimmed table mapping.

    Assuming that TCPDF is decoding this table correclty (I've checked it several times), this table contains wrong data. Indeed, commenting the line 10619 ($ctg[$c] = $g;) You get the expected results.

     
  • Jim Hanlon
    Jim Hanlon
    2012-03-31

    Okay. So I'm wondering why TCPDF is slurping up that cmap at all. It's for the so-called "Mac OS Roman" encoding, not Unicode. The third cmap is for Windows Unicode encoding. I think that the only cmap subtable that TCPDF cares about (if we are using Unicode, anyway) is the Unicode cmap (platform id = 0). And in any case, I don't think you would ever want to merge the cmaps together that have different platform and encoding identifiers.

     
  • Nicola Asuni
    Nicola Asuni
    2012-04-02

    OK. TCPDF 5.9.155 now includes an improved addTTFfotn() method that allows to specify the Platform ID and Encoding ID to extract. default fonts were updated.

     
  • Tao Sasaki
    Tao Sasaki
    2012-04-03

    Can not import Japanese truetype font.
    I used addTTFfont(), but did not display characters in generated pdf file.

    But, Charactors displayed in generated pdf file. if set $dw=1000 in generated font setting file in /fonts.

     
  • Nicola Asuni
    Nicola Asuni
    2012-04-04

    Did you set the correct Platform ID and Encoding ID?
    The Platform ID must be 3 for windows.
    The Encoding ID must be 1 for unicode and 2 for ShiftJIS.
    You can also send me the font for further checks.

     
  • Tao Sasaki
    Tao Sasaki
    2012-04-05

    Yes. I did set Platform ID and Encoding ID(1 and 2). but I can not import well.
    I will send you this font file.