Summary: | Loading IPAex fonts raises an error | ||
---|---|---|---|
Product: | Ghostscript | Reporter: | Masamichi Hosoda <trueroad> |
Component: | Font API | Assignee: | Chris Liddell (chrisl) <chris.liddell> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P4 | ||
Version: | 9.19 | ||
Hardware: | PC | ||
OS: | Windows 8 | ||
Customer: | Word Size: | --- |
Description
Masamichi Hosoda
2016-06-06 06:41:27 UTC
Please don't try to use language extensions. If you want to load a font you need to use the documented method (add it to fontmap). If these are not PostScript fonts then you need first to realise that there is no support in the language for TrueType fonts, Ghostscript has extensions that allow you to load TrueType fonts in various ways. I assume from the names that these are CJKV fonts and so you will need to load them by modifying cidfmap, as I described in your other bug report. Thank you for your advice. The is genuinely invalid. The 'post' table contains glyph indices beyond the number of glyph names in the table. This ends up leaving some of our internal data unset, and hence we end up with a typecheck Postscript error. I think we can work around the problem.... as long as it doesn't end up breaking some other font...... This commit http://git.ghostscript.com/?p=user/chrisl/ghostpdl.git;a=commitdiff;h=c74fe6dfa makes our 'post' table handling more tolerant of this type of issue. Thank you for your commit. If I understand correctly, IPAex font 'post' table is not invalid. However, in IPAex fonts, numberNewGlyphs is larger than numberOfGlyphs. i.e. https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6post.html Table 73: 'post' format2, numberOfGlyphs < numberNewGlyphs In other words, there are a larger number of glyph names than the number of glyphs. I think that Ghostscript cannot find a glyph name which has a larger index than the number of glyphs. I've tried your commit for ".loadfont". (Sorry, I know it is non-recommended way.) It can load IPAex fonts without errors. However, some glyph names which have larger indexes than the number of glyphs cannot be used. (In reply to Masamichi Hosoda from comment #5) > Thank you for your commit. > > If I understand correctly, IPAex font 'post' table is not invalid. > > However, in IPAex fonts, numberNewGlyphs is larger than numberOfGlyphs. > > i.e. > https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6post. > html > Table 73: 'post' format2, > > numberOfGlyphs < numberNewGlyphs > > In other words, there are a larger number of glyph names than the number of > glyphs. > I think that Ghostscript cannot find a glyph name which has a larger index > than the number of glyphs. > > I've tried your commit for ".loadfont". > (Sorry, I know it is non-recommended way.) > It can load IPAex fonts without errors. > However, some glyph names which have larger indexes than the number of > glyphs cannot be used. You are correct, it is not explicitly forbidden to have more names in the table that glyph indices (I hadn't noticed the size of the names list was a separate value from the list of indices). Although, I cannot imagine what utility you think you gain from having name entries that cannot be used, other than making the font file larger. I'm testing a solution now..... (In reply to Chris Liddell (chrisl) from comment #6) > > I'm testing a solution now..... Done: http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=f3ed5db Thank you for your solution. I've tried both your commits. It seems to work fine. IPA / IPAex / IPAmj fonts are the most useful Japanese free fonts. I'm not a developer of them. I'm only a user. So I don't know that the reason of the larger glyph name entries. Thank you again I've found another problem related to 'post' table. If you would like a new bug report, I'll create it. ".loadfont" cannot load all glyph names of IPAmjMincho font. (Sorry, again, I know it is non-recommended way.) IPAmj font: http://mojikiban.ipa.go.jp/1300.html#LicenseEng http://dl.mojikiban.ipa.go.jp/IPAmjMincho/ipamjm00301.zip This font has a lot of glyphs. The number of the glyph names exceeds 32768. In OpenType specification v1.6 (April 2009, July 2010), glyph name index numbers 32768 through 65535 were reserved. https://www.microsoft.com/typography/otspec160/default.htm https://www.microsoft.com/typography/otspec160/post.htm However, in OpenType specification v1.7 (March 2015), it allows the index number up to 65535. https://www.microsoft.com/typography/otspec170/default.htm https://www.microsoft.com/typography/otspec170/post.htm https://www.microsoft.com/typography/otspec/changes.htm#v1.7 So I've tried the following patch. It can load all glyph names of IPAmjMincho font. ``` --- a/Resource/Init/gs_ttf.ps 2016-06-21 23:46:16.165959300 +0900 +++ b/Resource/Init/gs_ttf.ps 2016-06-21 23:46:43.101499900 +0900 @@ -753,7 +753,7 @@ } { % If the index we read from the table is outside the range of glyph % names available, just use the /.notdef name, and carry on - dup 32768 ge exch 258 sub dup postnames length ge + dup 65536 ge exch 258 sub dup postnames length ge 3 -1 roll or { % According to the published TrueType spec, such values are % "reserved for future use", but at least some PDF files ``` (In reply to Masamichi Hosoda from comment #9) > I've found another problem related to 'post' table. > If you would like a new bug report, I'll create it. Generally, we do prefer a new bug for cases like this, but this is fine for this case. I'm not adopting quite your suggestion because since we maximum possible value (as we only read two bytes from the stream) is 65535, there's no point checking that the value is less than 65536. I'm rejigging the procedure a bit more, as I can make it a bit more efficient. This should address the problem: http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=d278f6a3 It works fine. Thank you so much. |