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.
Test case
The test font
Test case output
TCPDF's metadata file for testfont
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.
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.
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.
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.
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.
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.