]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/ghostscript/gs_typ32.ps
etherbcm: handle 64-bit host addresses, use PCIWADDR() instead of PADDR()
[plan9front.git] / sys / lib / ghostscript / gs_typ32.ps
1 %    Copyright (C) 1997 Aladdin Enterprises.  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_typ32.ps,v 1.6 2002/06/02 12:03:28 mpsuzuki Exp $
17 % Initialization file for Type 32 fonts.
18
19 % ------ Type 32 fonts ------ %
20
21 % We need LanguageLevel 2 or higher in order to have defineresource.
22 languagelevel dup 2 .max .setlanguagelevel
23
24 /BitmapFontInit mark
25
26 /.makeglyph32 systemdict /.makeglyph32 get
27 systemdict /.makeglyph32 .undef
28
29 /addglyph {     % ([wx wy llx lly urx ury] |
30                 %     [w0x w0y llx lly urx ury w1x w1y vx vy])
31                 %   <bitmap> <cid> <type32font> addglyph -
32   1 index dup 2 index .removeglyphs
33   22 string .makeglyph32
34                 % Stack: metrics bitmap cid font metstr
35   3 index () ne {
36                 % Use G4 encoding to compress the bitmap.
37                 % Define a string large enough to hold the metrics,
38                 % an uncompressed bitmap (worst case = 5x expansion),
39                 % and the 2 RTC codes (3 bytes).
40     dup length 4 index length 5 mul add 10 add string
41                 % Stack: metrics bitmap cid font metstr buffer
42     dup 0 3 index putinterval
43     dup 2 index length 1 index length 1 index sub getinterval
44                 % Stack: metrics bitmap cid font metstr buffer bitbuf
45     mark /Columns 8 index dup 4 get exch 2 get sub
46       /Rows 10 index dup 5 get exch 3 get sub
47       /K -1 /EndOfBlock true /BlackIs1 true
48     .dicttomark /CCITTFaxEncode filter
49                 % Stack: metrics bitmap cid font metstr buffer filter
50     dup 6 index writestring closefile
51                 % Find the end of the data by scanning backwards for the RTC.
52                 % There are 2 RTCs x 12 bits = 3 bytes to remove.
53     {
54       dup dup length 1 sub get 0 ne { exit } if
55       0 1 index length 1 sub getinterval
56     } loop
57     0 1 index length 3 sub getinterval
58     exch pop    % metstr
59   } if
60   1 index /CharStrings get 3 index 3 -1 roll put
61   pop pop pop pop
62 } obind
63
64 /removeall {            % <type32font> removeall -
65   0 65535 2 index removeglyphs pop
66 } obind
67
68 /.removeglyphs systemdict /.removeglyphs get
69 systemdict /.removeglyphs .undef
70
71 /removeglyphs {         % <cid_min> <cid_max> <type32font> .removeglyphs -
72   3 copy .removeglyphs
73   dup /CharStrings get dup {
74                 % Stack: cidmin cidmax font CharStrings cid bitmap
75     pop dup 5 index ge { dup 4 index le { 2 copy undef } if } if pop
76   } forall pop pop pop pop
77 } obind
78
79 .dicttomark /ProcSet defineresource pop
80
81 /.cidfonttypes where { pop } { /.cidfonttypes 6 dict def } ifelse
82 .cidfonttypes begin
83
84 4       % CIDFontType 4 = FontType 32
85 { dup /FontType 32 put
86   dup /CharStrings 20 dict put
87   1 index exch .buildfont32 exch pop
88 } bind def
89
90 end             % .cidfonttypes
91
92 % Define the BuildGlyph procedure.
93 % Since Type 32 fonts are indexed by CID, there is no BuildChar procedure.
94 % The name %Type32BuildGlyph is known to the interpreter.
95 (%Type32BuildGlyph) cvn {       % <font> <cid> %Type32BuildGlyph -
96   1 index /CharStrings get
97                 % Stack: font cid CharStrings
98   dup 2 index .knownget
99  { exch pop } { 0 get } ifelse
100                 % Stack: font cid cstr
101   dup //.getmetrics32   % use // because of .undef below
102   dup 14 gt {
103     8 index 8 index 13 3 roll setcachedevice2
104   } {
105     4 index 4 index 9 3 roll setcachedevice
106   } ifelse
107                 % Stack: font cid cstr w h nmetrics llx lly
108   6 -1 roll 4 -1 roll 1 index length 1 index sub getinterval
109                 % Stack: font cid w h llx lly bitstr
110   dup () eq {
111     pop pop pop
112   } {
113     mark /Columns 6 index /Rows 7 index /K -1 /EndOfBlock false /BlackIs1 true
114     .dicttomark /CCITTFaxDecode filter 4 index 4 index true
115                 % Stack: font cid w h llx lly filter w h true
116     [ 1 0 0 1 11 -2 roll exch neg exch neg ] 5 -1 roll imagemask
117   } ifelse
118   pop pop pop pop
119 } bind def
120
121 systemdict /.getmetrics32 .undef
122
123 buildfontdict 32 /.buildfont32 cvx put
124
125 32 dup /FontType defineresource pop
126
127 .setlanguagelevel