summaryrefslogtreecommitdiff
path: root/pxl/pxsymbol.ps
blob: d283c4c22fa0d100b8373cc763c4f14f0a6331c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
%!
% Copyright (C) 2001-2012 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
% implied.
%
% This software is distributed under license and may not be copied,
% modified or distributed except as expressly authorized under the terms
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
% Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134, San Rafael,
% CA  94903, U.S.A., +1(415)492-9861, for further information.
%

% Construct the PCL XL symbol set mappings.
% This generates both a .c and a .h file.

% Load all known encodings.
(../gs_???_e.ps)
 { (r) file
   dup token pop dup /currentglobal eq
    {		% The next 4 tokens are standard.
      5 { pop dup token pop } repeat
    }
   if
                % stack: file token
   /Encoding resourcestatus
    { pop 2 ne
       { closefile }
       { dup 0 setfileposition run }
      ifelse
    }
    { dup 0 setfileposition run
    }
   ifelse
 }
100 string filenameforall

% Construct a list of all the glyphs.
/glyphs 1000 dict def
(*)
 { /Encoding findresource { glyphs exch dup put } forall
 }
100 string /Encoding resourceforall
glyphs /.notdef undef

% Write the copyright notice and initial boilerplate.
(/* Copyright (C) 2012 Artifex Software Inc.  All rights reserved.
   Unauthorized use, copying, and/or distribution prohibited.
 */
) print

/HEADER where { pop HEADER } { false } ifelse
 { (
/* pxsymbol.h */
/* PCL XL symbol set table declarations */

) print
   (*)
    { (extern const unsigned short px) print =only ([];
) print
    }
   100 string /Encoding resourceforall
   flush quit
 }
if

(
/* pxsymbol.c */
/* PCL XL symbol set mapping definitions */

#include "pxsymbol.h"
) print

% Write the enumeration of the glyphs.
% It would be too much work to really sort them, so we only sort by
% the first character.
(
typedef enum {
  pxg__notdef = 0) print

65 1 122
 { /first exch def
   glyphs
    { =string cvs 0 get first eq
       { (,
  pxg_) print =only }
       { pop }
      ifelse
    }
   forall
 }
for
(
} px_glyph_t;
) print

% Write the actual encodings.
(*)
 { (
const unsigned short px) print dup =only ([257] = {) print
   /Encoding findresource
   0 4 255
    { (
 ) print
      dup 1 exch 3 add
       { ( pxg_) print 2 copy get dup /.notdef eq { pop (_notdef) } if
         =only (,) print pop
       }
      for
    }
   for
   (
  pxg__notdef
};
) print pop
 }
100 string /Encoding resourceforall

% All done.
flush quit