Blame SOURCES/ghostscript-strange-fonts.patch

ea5d11
diff -up ghostscript-9.07/Resource/Init/gs_ttf.ps.strange-fonts ghostscript-9.07/Resource/Init/gs_ttf.ps
ea5d11
--- ghostscript-9.07/Resource/Init/gs_ttf.ps.strange-fonts	2013-02-14 07:58:16.000000000 +0000
ea5d11
+++ ghostscript-9.07/Resource/Init/gs_ttf.ps	2013-06-18 16:09:49.904150294 +0100
ea5d11
@@ -41,21 +41,17 @@
ea5d11
 % Closes the file in either case.
ea5d11
 /.findnonttfontvalue /.findfontvalue load def
ea5d11
 /.findfontvalue {
ea5d11
-  1 index read {
ea5d11
-    2 index 1 index unread
ea5d11
-    % beginning with binary 0 or 't' (TrueType), or 'O' (OpenType)
ea5d11
-    dup 0 eq 1 index (O) 0 get eq or exch (t) 0 get eq or {
ea5d11
+  1 index .is_ttf_or_otf {
ea5d11
                 % If this is a font at all, it's a TrueType font.
ea5d11
       dup /FontType eq {
ea5d11
         pop closefile 42 //true
ea5d11
       } {
ea5d11
         dup /FontName eq { pop .findttfontname } { pop closefile //false } ifelse
ea5d11
       } ifelse
ea5d11
-    } {
ea5d11
+  } {
ea5d11
                 % Not a TrueType font.
ea5d11
       .findnonttfontvalue
ea5d11
-    } ifelse
ea5d11
-  } { pop closefile //false } ifelse
ea5d11
+  } ifelse
ea5d11
 } bind def
ea5d11
 
ea5d11
 % <file> .findttfontname <fname> true
ea5d11
@@ -65,7 +61,9 @@
ea5d11
   //true 0 .loadttfonttables
ea5d11
   tabdict /name .knownget {
ea5d11
     dup 8 getu32 f exch setfileposition
ea5d11
-    12 getu32 string f exch readstring pop
ea5d11
+    12 getu32
ea5d11
+    dup 65535 gt { pop 65535 } if % protect against extremely large name
ea5d11
+    string f exch readstring pop
ea5d11
     dup
ea5d11
     6 findname not {
ea5d11
       4 findname	% Try FullName
ea5d11
@@ -82,6 +80,7 @@
ea5d11
 % Load a font file that might be a TrueType font.
ea5d11
 
ea5d11
 /tt_tag_dict << <00010000> 0 (true) 0 (typ1) 0 (ttcf) 0 >> readonly def
ea5d11
+/ttf_otf_tag_dict << <00010000> 0 (true) 0 (typ1) 0 (ttcf) 0 (OTTO) 0>> readonly def
ea5d11
 
ea5d11
 % <file> .loadfontfile -
ea5d11
 /.loadnonttfontfile /.loadfontfile load def
ea5d11
@@ -95,7 +94,13 @@
ea5d11
   } ifelse
ea5d11
 } bind def
ea5d11
 
ea5d11
+% <file> .istruetypefont <bool>
ea5d11
+/.is_ttf_or_otf {
ea5d11
+    dup 0 setfileposition (1234) .peekstring { //ttf_otf_tag_dict exch known } { //false } ifelse
ea5d11
+} bind def
ea5d11
+
ea5d11
 currentdict /tt_tag_dict .undef
ea5d11
+currentdict /ttf_otf_tag_dict .undef
ea5d11
 
ea5d11
 % ---------------- Automatic Type 42 generation ---------------- %
ea5d11