Bug 688154 - TTF file fails to load
TTF file fails to load
Product: Ghostscript
Classification: Unclassified
Component: Font API
PC All
: P3 normal
Assigned To: Igor Melichev
Bug traffic
Depends on:
  Show dependency treegraph
Reported: 2005-06-21 15:08 PDT by Han-Wen Nienhuys
Modified: 2008-12-19 08:31 PST (History)
0 users

See Also:
Word Size: ---

patch.txt (8.36 KB, patch)
2005-08-03 16:11 PDT, Igor Melichev
Details | Diff
PS file using kochi gothic (2.13 MB, application/postscript)
2005-08-03 16:45 PDT, Han-Wen Nienhuys
the same file, but as destilled PDF from embedded type42 font (132.99 KB, application/pdf)
2005-08-03 16:48 PDT, Han-Wen Nienhuys
load kochi and display 2 glyphs. (15.30 MB, application/postscript)
2005-08-04 03:15 PDT, Han-Wen Nienhuys

Note You need to log in before you can comment on or make changes to this bug.
Description Han-Wen Nienhuys 2005-06-21 15:08:06 PDT

I have problems loading the Kochi gothic font (shipped with Fedora Core by
RedHat) into ghostcript:

AFPL Ghostscript 8.51 (2005-04-18)
Copyright (C) 2005 artofcode LLC, Benicia, CA.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>(/usr/share/fonts/japanese/TrueType/kochi-gothic-subst.ttf) (r) file
Error: /rangecheck in --string--
Operand stack:
   --nostringval--   155849   155850
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--  
--nostringval--   2   %stopped_push   --nostringval--   --nostringval--  
%loop_continue   3  3   %oparray_pop   --nostringval--   --nostringval--   false
  1   %stopped_push   .runexec2   --nostringval--   --nostringval--  
--nostringval--   2   %stopped_push   --nostringval--   --nostringval--  
--nostringval--   %loop_continue  --nostringval--   1   --nostringval--  
--nostringval--   false   1   %stopped_push   --nostringval--   --nostringval--
  --nostringval--   --nostringval--   --nostringval--   %array_continue  
--nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1117/1686(ro)(G)--   --dict:0/20(G)--   --dict:70/200(L)--  
--dict:28/50(ro)(G)--   --dict:15/40(L)--
Current allocation mode is local
Current file position is 10

The font loads fine in fontforge. font is attached.
Comment 1 Han-Wen Nienhuys 2005-06-21 15:10:28 PDT
Created attachment 1466 [details]
kochi gothic ttf file.
Comment 2 Stefan Kemper 2005-06-22 08:17:19 PDT
Font file appears fine, using ftview.

Reproduceable in head.
Comment 3 Alex Cherepanov 2005-06-22 11:37:36 PDT
The problem is cause by a very large 'post' table in the font.
GS expects this table to be small, tries to read it into a single string
and fails.
Comment 4 Igor Melichev 2005-08-03 16:11:51 PDT
Created attachment 1596 [details]

A suggested patch - please try it.
It works for the supplied test case and has no regressions, but I have no
documents to test it with a text with the supplied font. Please supply some.
Comment 5 Han-Wen Nienhuys 2005-08-03 16:45:16 PDT
Created attachment 1597 [details]
PS file using kochi gothic

this file loads kochi.ttf near the top.
Comment 6 Han-Wen Nienhuys 2005-08-03 16:48:20 PDT
Created attachment 1598 [details]
the same file, but as destilled PDF from embedded type42 font

this file shows how the previous attachment should look.

Please let me know if you have problems with verifying the behavior. I'll try
to build GS with the patch.

Thanks for looking at this problem!

BTW, will this patch be backported to GS 8.15 ?
Comment 7 Igor Melichev 2005-08-04 02:33:34 PDT
Patch to HEAD :
Comment 8 Igor Melichev 2005-08-04 02:36:59 PDT
Dear  Han-Wen Nienhuys,

Could you please compose a single PS file with the font embedded, so that we'll 
add it to our test base ? Our regression tool doesn't support the 
operator 'file'. Thank you.
Comment 9 Igor Melichev 2005-08-04 02:42:27 PDT
Btw, the rendering (both GS and Adobe Distiller + Reader) contails some 
cyrillic characters under the text "ten brichst du", which doesn't look as a 
correct Russian, Ukrainian, Bulgarian, etc. text. Likely the encoding is 
broken. Maybe it's a separate bug.
Comment 10 Han-Wen Nienhuys 2005-08-04 02:48:20 PDT
It might very well be non-correct cyrillic. I have just cut & pasted some random
text from a webpage. 

I'll make the PS file.
Comment 11 Han-Wen Nienhuys 2005-08-04 03:15:53 PDT
Created attachment 1600 [details]
load kochi and display 2 glyphs.

this file contains kochi as type42 font, and then shows two glyphs from the
font, lower right on the page.