~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to lib/gs_fntem.ps

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%    Copyright (C) 2000 Artifex Software, Inc.  All rights reserved.
2
 
3
 
% This software is provided AS-IS with no warranty, either express or
4
 
% implied.
5
 
6
 
% This software is distributed under license and may not be copied,
7
 
% modified or distributed except as expressly authorized under the terms
8
 
% of the license contained in the file LICENSE in this distribution.
9
 
10
 
% For more information about licensing, please refer to
11
 
% http://www.ghostscript.com/licensing/. For information on
12
 
% commercial licensing, go to http://www.artifex.com/licensing/ or
13
 
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
 
% San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
 
 
16
 
% $Id: gs_fntem.ps 8274 2007-10-09 00:06:24Z leonardo $
17
 
% A procset for Postscript font emulation
18
 
 
19
 
% The procedures must not depend on the presence of the
20
 
% procset dictionary on the dictionary stack.
21
 
 
22
 
languagelevel 2 .setlanguagelevel
23
 
 
24
 
%========================= Process xlatmap ====================
25
 
mark
26
 
%% Replace 1 (xlatmap)
27
 
(xlatmap) .runlibfile
28
 
.dicttomark dup systemdict exch /.xlatmap_dict exch put
29
 
 
30
 
% Convert it into a plain text to simplify the processing in C :
31
 
% *(fontkind\0\0\ *(charmap\0decoding\0) ) \0
32
 
 
33
 
() exch {
34
 
  3 1 roll =string cvs concatstrings (\0\0) concatstrings
35
 
  exch
36
 
  { =string cvs concatstrings (\0) concatstrings
37
 
  } forall
38
 
} forall
39
 
(\0) concatstrings
40
 
systemdict exch /.xlatmap exch put
41
 
 
42
 
/FontEmulationProcs 10 dict begin
43
 
 
44
 
%-------------------------------Font--------------------------------
45
 
 
46
 
 
47
 
/FontCommon  % - font_common -
48
 
{ currentdict /PaintType known not {
49
 
    /PaintType 0 def
50
 
  } if
51
 
  currentdict /Encoding .knownget not {
52
 
    //StandardEncoding
53
 
  } if
54
 
  dup type /nametype eq {
55
 
    /Encoding findresource
56
 
  } if
57
 
  /Encoding exch def
58
 
} bind def
59
 
 
60
 
/FontOptions 5 dict begin
61
 
  /make_procs currentdict def
62
 
  /NameKey /FontName def
63
 
  /TypeKey /FontType def
64
 
 
65
 
  1
66
 
  { /FontMatrix [0.001 0 0 0.001 0 0] def
67
 
    /FontBBox [-128 -128 1024 1024] def % zfapi.ps refines it.
68
 
    /Private 0 dict def
69
 
    /CharStrings << /.notdef () >> def
70
 
    //FontCommon exec
71
 
  } bind def
72
 
 
73
 
  42
74
 
  { /FontMatrix [1 0 0 1 0 0] def
75
 
    /FontBBox [0 0 1 1] def % zfapi.ps refines it.
76
 
    /CharStrings <<>> def
77
 
    /sfnts [<00010000 0000 0000 0000 0000 0000>] def
78
 
    /GlyphDirectory [] def
79
 
    //FontCommon exec
80
 
  } bind def
81
 
 
82
 
  %fixme : more font types.
83
 
 
84
 
currentdict end def
85
 
 
86
 
%---------------------------CIDFont---------------------------
87
 
 
88
 
/TranslateCSI   % <record> TranslateCSI <CSI>
89
 
{ RESMPDEBUG { (fntem TranslateCSI beg ) = } if
90
 
  begin
91
 
  CSI length 2 eq {
92
 
    << /Registry (Adobe) 
93
 
       /Ordering CSI aload pop 
94
 
       /Supplement exch 
95
 
    >>
96
 
  } {
97
 
    << /Registry CSI 0 get
98
 
       /Ordering CSI 1 get
99
 
       /Supplement CSI 2 get
100
 
    >>
101
 
  } ifelse
102
 
  end
103
 
  RESMPDEBUG { (fntem TranslateCSI end ) = } if
104
 
} bind def
105
 
 
106
 
/CIDFontCommon
107
 
{ /CIDSystemInfo currentdict //TranslateCSI exec def
108
 
  currentdict /CSI undef
109
 
  /FontBBox [-128 -128 1024 1024] def % zfapi.ps refines it.
110
 
  /CIDCount 1 def % ChooseDecoding will set a reasonable value.
111
 
} bind def
112
 
 
113
 
% GFlyph substitution table for narrow, wide, proportional glyphs - 
114
 
% used with TrueTypes.
115
 
 
116
 
currentpacking false setpacking
117
 
/SubstNWP << 
118
 
 
119
 
  % Array format : orig_type, beg_CID, end_CID, subst_beg_CID, subst_type
120
 
  % type = (n==narrow, w==wide, p==proportional).
121
 
 
122
 
  /Japan1
123
 
  { p 1 94 231 n    
124
 
 
125
 
    p 17 26 780 w
126
 
    p 34 59 790 w
127
 
    p 66 91 816 w
128
 
    w 842 842 7918 w  % fixme: These substitutions require to shift the glyph origin.
129
 
    w 844 844 7919 w
130
 
    w 846 846 7920 w
131
 
    w 848 848 7921 w
132
 
    w 850 850 7922 w
133
 
    w 876 876 7923 w
134
 
    w 908 908 7924 w
135
 
    w 910 910 7925 w
136
 
    w 912 912 7926 w
137
 
    w 914 914 7927 w
138
 
    w 925 925 7928 w
139
 
    w 927 927 7929 w
140
 
    w 929 929 7930 w
141
 
    w 931 931 7931 w
142
 
    w 933 933 7932 w
143
 
    w 959 959 7933 w
144
 
    w 991 991 7934 w
145
 
    w 993 993 7935 w
146
 
    w 995 995 7936 w
147
 
    w 1002 1002 7937 w
148
 
    w 1009 1009 7938 w
149
 
    w 1010 1010 7939 w
150
 
  } cvlit
151
 
 
152
 
  /Japan2 1 index
153
 
 
154
 
  /CNS1
155
 
  { p 1 94 13648 n
156
 
 
157
 
    p 17 26 333 w
158
 
    p 34 59 365 w
159
 
    p 66 91 391 w
160
 
  } cvlit
161
 
 
162
 
  /GB1
163
 
  { p 2 94 814 n
164
 
  
165
 
    p 2 94 262 w
166
 
 
167
 
    p 1 1 7716 n
168
 
  } cvlit
169
 
 
170
 
  /Korea1
171
 
  { p  1 60 8094 n
172
 
    p 62 94 8155 n
173
 
 
174
 
    p  2 59 264 w
175
 
    p 63 94 325 w
176
 
  } cvlit
177
 
 
178
 
  /Identity []
179
 
 
180
 
  /Unicode []
181
 
 
182
 
>> def
183
 
setpacking
184
 
 
185
 
/CIDFontOptions 5 dict begin
186
 
  /make_procs currentdict def
187
 
  /NameKey /CIDFontName def
188
 
  /TypeKey /CIDFontType def
189
 
 
190
 
  0
191
 
  { //CIDFontCommon exec
192
 
    /FDArray [
193
 
      14 dict begin
194
 
        /FontName CIDFontName =string cvs (%) concatstrings cvn def
195
 
        /FontType 1 def
196
 
        /FontMatrix [0.001 0 0 0.001 0 0 ] def
197
 
        /PaintType 0 def
198
 
        /Private 0 dict def
199
 
        currentdict
200
 
      end
201
 
    ] def
202
 
    /GlyphDirectory [] def
203
 
    /GDBytes 1 def
204
 
    /FDBytes 0 def
205
 
  } bind def
206
 
 
207
 
  1
208
 
  { //CIDFontCommon exec
209
 
    /FontMatrix [1 0 0 1 0 0] def
210
 
    /BuildGlyph {} def
211
 
  } bind def
212
 
 
213
 
  2
214
 
  { //CIDFontCommon exec
215
 
    /FontMatrix [1 0 0 1 0 0] def
216
 
    /GDBytes 2 def
217
 
    /CIDMap <0000> def
218
 
    /sfnts [<00010000 0000 0000 0000 0000 0000>] def
219
 
    /Encoding [] def
220
 
    /CharStrings << /.notdef 0 >> def
221
 
  } bind def
222
 
 
223
 
currentdict end def
224
 
 
225
 
/complete_instance  % <font_name> <FontDict> <Options> complete_FAPI_Font <font_name> <FontDict>
226
 
{ begin
227
 
  dup length dict copy
228
 
  begin
229
 
  dup type /nametype ne { cvn } if
230
 
  dup NameKey exch def
231
 
  currentglobal true setglobal
232
 
  make_procs TypeKey load .knownget {
233
 
    exec
234
 
  } { setglobal
235
 
      /complete_instance cvx /invalidfont signalerror
236
 
  } ifelse
237
 
  setglobal
238
 
  currentdict end
239
 
  end
240
 
} bind def
241
 
 
242
 
/GetFilePath    % <scratch> <Name> <record> GetFilePath <filepath>
243
 
{ exch pop                       % (scratch) <record>
244
 
  /Path get                      % (scratch) (path)
245
 
  exch copy
246
 
  % What we make here it is not a complete PS resource.
247
 
  % Unable to provide full conformity :
248
 
  % the attempt to run this file may fail.
249
 
} bind def
250
 
 
251
 
/GetSize        % <Name> <record> GetSize <size>
252
 
{ pop pop -1 % Unknown size.
253
 
  % fixme: probably we could provide an estimation size for some fonts.
254
 
} bind def
255
 
 
256
 
/RecordVirtualMethodsStub 3 dict begin
257
 
  /GetFilePath //GetFilePath def
258
 
  /GetSize //GetSize def
259
 
currentdict end def
260
 
 
261
 
% ---------------------- Decoding helpers ----------------------------
262
 
 
263
 
/encodingnames mark
264
 
 StandardEncoding /StandardEncoding
265
 
 ISOLatin1Encoding /ISOLatin1Encoding
266
 
 SymbolEncoding /SymbolEncoding
267
 
 DingbatsEncoding /DingbatsEncoding
268
 
 /resourceforall where {
269
 
   pop (*) { dup cvn
270
 
     EncodingDirectory exch .knownget not {
271
 
       % A work around bug 688710 on Linux :
272
 
       % findencoding can't load resource files until gs_init.ps executes .fixresources . 
273
 
       % It will happen after gs_init.ps runs INITFILES,
274
 
       % from which the current file runs.
275
 
       % Windows build has no such problem.
276
 
       (.svn) anchorsearch {
277
 
         % HACK : skip .svn or */* names, which are subdirectories.
278
 
         pop pop
279
 
       } {
280
 
         (/) search {
281
 
           pop pop pop
282
 
         } {
283
 
           cvn dup /Encoding findresource
284
 
         } ifelse
285
 
       } ifelse
286
 
     } {
287
 
       exch cvn exch
288
 
     } ifelse
289
 
     exch 
290
 
   } 1024 string /Encoding resourceforall 
291
 
 } if
292
 
.dicttomark def
293
 
 
294
 
/ChooseDecoding  % <font> ChooseDecoding <font>
295
 
{ { % A loop for 'exit' context.
296
 
    dup /Decoding .knownget {
297
 
      dup type /nametype eq {
298
 
        1 index /CIDFontType known { /CIDDecoding } { /Decoding } ifelse
299
 
        findresource 1 index exch /Decoding exch put
300
 
      } {
301
 
        pop
302
 
      } ifelse
303
 
      dup /CIDFontType known {
304
 
        dup dup /Decoding get /CIDCount get /CIDCount exch put
305
 
      } if
306
 
      exit
307
 
    } if
308
 
    dup /CIDFontType known {
309
 
      % This is a hooked CID font, no need for Decoding.
310
 
      exit
311
 
    } if
312
 
    % This works when the renderer can't choose character by name,
313
 
    % and we cannot determine the charset.
314
 
    % Probably this branch is to be removed after UFST problem is fixed.
315
 
    dup /Encoding get                                    % <<font>> encoding
316
 
    dup type /nametype eq {
317
 
      /Decoding findresource 1 index exch /Decoding exch put
318
 
    } {
319
 
      dup //encodingnames
320
 
      exch .knownget {
321
 
        exch pop
322
 
        /Decoding findresource 1 index exch /Decoding exch put
323
 
      } {
324
 
        % unknown encoding, convert it to decoding :
325
 
        dup length dict begin
326
 
        /.notdef 0 def
327
 
        0 1 currentdict length 1 sub
328
 
        { dup 2 index exch get 
329
 
          dup /.notdef ne {
330
 
            exch def
331
 
          } {
332
 
            pop pop
333
 
          } ifelse
334
 
        } for
335
 
        pop
336
 
        currentdict end
337
 
        1 index exch /Decoding exch put
338
 
      } ifelse
339
 
    } ifelse
340
 
    exit
341
 
  } loop
342
 
  dup /CIDFontType known {
343
 
    dup /SubstNWP .knownget not {
344
 
      dup /CIDSystemInfo get /Ordering get cvn
345
 
    } if
346
 
    dup type /nametype eq {
347
 
      //SubstNWP exch .knownget not {
348
 
        []
349
 
      } if                                   % <<font>> [SubstNWP]
350
 
    } if
351
 
    1 index exch /SubstNWP exch put
352
 
  } if
353
 
} bind def
354
 
 
355
 
/PrintFontRef      % <string|name> <font> PrintFontRef <string|name> <font>
356
 
{ dup /FontName known { (Font ) } { (CIDFont ) } ifelse print
357
 
  1 index =string cvs print
358
 
  dup /FontName .knownget not {
359
 
    dup /CIDFontName get
360
 
  } if                               % <string|name> <font> <fontname>
361
 
  dup 3 index ne {
362
 
    ( \( aliased from ) print
363
 
    =string cvs print ( \)) print
364
 
  } {
365
 
    pop
366
 
  } ifelse
367
 
} bind def
368
 
 
369
 
/GetFontType       % <font> GetFontType int
370
 
{ dup /CIDFontType .knownget {
371
 
    exch pop 9 add
372
 
  } {
373
 
    /FontType get
374
 
  } ifelse
375
 
} bind def
376
 
 
377
 
/FindInArray    % <array> <elem> .array_find <bool>
378
 
{ false 3 1 roll
379
 
  exch {                      % false elem elem_i
380
 
    1 index eq {              % false elem
381
 
       pop true exch
382
 
    } if
383
 
  } forall
384
 
  pop
385
 
} bind def
386
 
 
387
 
/ProvideUnicodeDecoding % <font> ProvideUnicodeDecoding <font>
388
 
{
389
 
  % If the font is maintained by FAPI, or if it is TT-emulated CID font,
390
 
  % it already has /Decoding. But its value isn't guaranteeed to
391
 
  % be an Unicode decoding. Since we can't determine whether 
392
 
  % it is an Unicode decoding, we unconditionally load an appropriate Unicode decoding
393
 
  % and attach it with /GlyphNames2Unicode entry.
394
 
  %
395
 
  % Another interesting case is when the font already has /GlyphNames2Unicode.
396
 
  % The latter to be used instead. Note that /GlyphNames2Unicode
397
 
  % appears only when type 32 fonts are disable (see .pdf_hook_DSC_Creator),
398
 
  % but an automatic disabling is not implemented yet.
399
 
 
400
 
  currentglobal true setglobal exch
401
 
  dup /FontInfo known not {
402
 
    dup /FontInfo 1 dict put
403
 
  } if
404
 
  { % A loop just for 'exit' context.
405
 
    dup /FontInfo get /GlyphNames2Unicode known {
406
 
      exit
407
 
    } if
408
 
    dup /CIDFontType known {
409
 
      dup mark exch                                              % bool <font> [ <font>
410
 
      dup /CIDSystemInfo get /Ordering get (.Unicode)            % bool <font> [ <font> () ()
411
 
      concatstrings cvn                                          % bool <font> [ <font> /Name
412
 
      /CIDDecoding { findresource } stopped {
413
 
        % Can't provide a decoding, giving up without creating /GlyphNames2Unicode.
414
 
        cleartomark exit
415
 
      } if                                                       % bool <font> [ <font> <D>
416
 
      exch /FontInfo get exch                                    % bool <font> [ <FI> <D>
417
 
      /GlyphNames2Unicode exch
418
 
      .forceput % FontInfo can be read-only.
419
 
      pop                                                        % bool <font>
420
 
      exit
421
 
    } if
422
 
    dup /FontInfo get                                            % bool <font> <FI>
423
 
    /GlyphNames2Unicode /Unicode /Decoding findresource
424
 
    .forceput % FontInfo can be read-only.
425
 
    exit
426
 
  } loop
427
 
  exch setglobal
428
 
} bind def
429
 
 
430
 
currentdict end /ProcSet defineresource pop
431
 
 
432
 
.setlanguagelevel