diff options
-rw-r--r-- | gs/Resource/Init/gs_ttf.ps | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/gs/Resource/Init/gs_ttf.ps b/gs/Resource/Init/gs_ttf.ps index 0dbc20614..7893764bd 100644 --- a/gs/Resource/Init/gs_ttf.ps +++ b/gs/Resource/Init/gs_ttf.ps | |||
@@ -41,21 +41,17 @@ | |||
41 | % Closes the file in either case. | 41 | % Closes the file in either case. |
42 | /.findnonttfontvalue /.findfontvalue load def | 42 | /.findnonttfontvalue /.findfontvalue load def |
43 | /.findfontvalue { | 43 | /.findfontvalue { |
44 | 1 index read { | 44 | 1 index .is_ttf_or_otf { |
45 | 2 index 1 index unread | ||
46 | % beginning with binary 0 or 't' (TrueType), or 'O' (OpenType) | ||
47 | dup 0 eq 1 index (O) 0 get eq or exch (t) 0 get eq or { | ||
48 | % If this is a font at all, it's a TrueType font. | 45 | % If this is a font at all, it's a TrueType font. |
49 | dup /FontType eq { | 46 | dup /FontType eq { |
50 | pop closefile 42 //true | 47 | pop closefile 42 //true |
51 | } { | 48 | } { |
52 | dup /FontName eq { pop .findttfontname } { pop closefile //false } ifelse | 49 | dup /FontName eq { pop .findttfontname } { pop closefile //false } ifelse |
53 | } ifelse | 50 | } ifelse |
54 | } { | 51 | } { |
55 | % Not a TrueType font. | 52 | % Not a TrueType font. |
56 | .findnonttfontvalue | 53 | .findnonttfontvalue |
57 | } ifelse | 54 | } ifelse |
58 | } { pop closefile //false } ifelse | ||
59 | } bind def | 55 | } bind def |
60 | 56 | ||
61 | % <file> .findttfontname <fname> true | 57 | % <file> .findttfontname <fname> true |
@@ -65,7 +61,9 @@ | |||
65 | //true 0 .loadttfonttables | 61 | //true 0 .loadttfonttables |
66 | tabdict /name .knownget { | 62 | tabdict /name .knownget { |
67 | dup 8 getu32 f exch setfileposition | 63 | dup 8 getu32 f exch setfileposition |
68 | 12 getu32 string f exch readstring pop | 64 | 12 getu32 |
65 | dup 65535 gt { pop 65535 } if % protect against extremely large name | ||
66 | string f exch readstring pop | ||
69 | dup | 67 | dup |
70 | 6 findname not { | 68 | 6 findname not { |
71 | 4 findname % Try FullName | 69 | 4 findname % Try FullName |
@@ -82,6 +80,7 @@ | |||
82 | % Load a font file that might be a TrueType font. | 80 | % Load a font file that might be a TrueType font. |
83 | 81 | ||
84 | /tt_tag_dict << <00010000> 0 (true) 0 (typ1) 0 (ttcf) 0 >> readonly def | 82 | /tt_tag_dict << <00010000> 0 (true) 0 (typ1) 0 (ttcf) 0 >> readonly def |
83 | /ttf_otf_tag_dict << <00010000> 0 (true) 0 (typ1) 0 (ttcf) 0 (OTTO) 0>> readonly def | ||
85 | 84 | ||
86 | % <file> .loadfontfile - | 85 | % <file> .loadfontfile - |
87 | /.loadnonttfontfile /.loadfontfile load def | 86 | /.loadnonttfontfile /.loadfontfile load def |
@@ -95,7 +94,13 @@ | |||
95 | } ifelse | 94 | } ifelse |
96 | } bind def | 95 | } bind def |
97 | 96 | ||
97 | % <file> .is_ttf_or_otf <bool> | ||
98 | /.is_ttf_or_otf { | ||
99 | dup 0 setfileposition (1234) .peekstring { //ttf_otf_tag_dict exch known } { //false } ifelse | ||
100 | } bind def | ||
101 | |||
98 | currentdict /tt_tag_dict .undef | 102 | currentdict /tt_tag_dict .undef |
103 | currentdict /ttf_otf_tag_dict .undef | ||
99 | 104 | ||
100 | % ---------------- Automatic Type 42 generation ---------------- % | 105 | % ---------------- Automatic Type 42 generation ---------------- % |
101 | 106 | ||