summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qpdf/xpdf/GlobalParams.h
Unidiff
Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/GlobalParams.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/xpdf/GlobalParams.h242
1 files changed, 242 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/GlobalParams.h b/noncore/unsupported/qpdf/xpdf/GlobalParams.h
new file mode 100644
index 0000000..ecbb5fc
--- a/dev/null
+++ b/noncore/unsupported/qpdf/xpdf/GlobalParams.h
@@ -0,0 +1,242 @@
1//========================================================================
2//
3// GlobalParams.h
4//
5// Copyright 2001 Derek B. Noonburg
6//
7//========================================================================
8
9#ifndef GLOBALPARAMS_H
10#define GLOBALPARAMS_H
11
12#ifdef __GNUC__
13#pragma interface
14#endif
15
16#include <stdio.h>
17#include "gtypes.h"
18#include "CharTypes.h"
19
20class GString;
21class GList;
22class GHash;
23class NameToCharCode;
24class CharCodeToUnicode;
25class CIDToUnicodeCache;
26class UnicodeMap;
27class UnicodeMapCache;
28class CMap;
29class CMapCache;
30class GlobalParams;
31
32//------------------------------------------------------------------------
33
34// The global parameters object.
35extern GlobalParams *globalParams;
36
37//------------------------------------------------------------------------
38
39enum DisplayFontParamKind {
40 displayFontX,
41 displayFontT1,
42 displayFontTT
43};
44
45class DisplayFontParam {
46public:
47
48 GString *name; // font name for 8-bit fonts;
49 // collection name for CID fonts
50 DisplayFontParamKind kind;
51 union {
52 struct {
53 GString *xlfd;
54 GString *encoding;
55 } x;
56 struct {
57 GString *fileName;
58 } t1;
59 struct {
60 GString *fileName;
61 } tt;
62 };
63
64 DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
65 DisplayFontParam(char *nameA, char *xlfdA, char *encodingA);
66 ~DisplayFontParam();
67};
68
69// Font rasterizer control.
70enum FontRastControl {
71 fontRastNone, // don't use this rasterizer
72 fontRastPlain, // use it, without anti-aliasing
73 fontRastAALow, // use it, with low-level anti-aliasing
74 fontRastAAHigh // use it, with high-level anti-aliasing
75};
76
77//------------------------------------------------------------------------
78
79class PSFontParam {
80public:
81
82 GString *pdfFontName;
83 GString *psFontName;
84
85 PSFontParam(GString *pdfFontNameA, GString *psFontNameA);
86 ~PSFontParam();
87};
88
89//------------------------------------------------------------------------
90
91enum PSLevel {
92 psLevel1,
93 psLevel1Sep,
94 psLevel2,
95 psLevel2Sep
96};
97
98//------------------------------------------------------------------------
99
100enum EndOfLineKind {
101 eolUnix, // LF
102 eolDOS, // CR+LF
103 eolMac // CR
104};
105
106//------------------------------------------------------------------------
107
108class GlobalParams {
109public:
110
111 // Initialize the global parameters by attempting to read a config
112 // file.
113 GlobalParams(char *cfgFileName);
114
115 ~GlobalParams();
116
117 //----- accessors
118
119 CharCode getMacRomanCharCode(char *charName);
120
121 Unicode mapNameToUnicode(char *charName);
122 FILE *getCIDToUnicodeFile(GString *collection);
123 UnicodeMap *getResidentUnicodeMap(GString *encodingName);
124 FILE *getUnicodeMapFile(GString *encodingName);
125 FILE *findCMapFile(GString *collection, GString *cMapName);
126 FILE *findToUnicodeFile(GString *name);
127 DisplayFontParam *getDisplayFont(GString *fontName);
128 DisplayFontParam *getDisplayCIDFont(GString *collection);
129 GString *getPSFile() { return psFile; }
130 int getPSPaperWidth() { return psPaperWidth; }
131 int getPSPaperHeight() { return psPaperHeight; }
132 GBool getPSDuplex() { return psDuplex; }
133 PSLevel getPSLevel() { return psLevel; }
134 PSFontParam *getPSFont(GString *fontName);
135 GBool getPSEmbedType1() { return psEmbedType1; }
136 GBool getPSEmbedTrueType() { return psEmbedTrueType; }
137 GBool getPSOPI() { return psOPI; }
138 GString *getTextEncodingName() { return textEncoding; }
139 EndOfLineKind getTextEOL() { return textEOL; }
140 GString *findFontFile(GString *fontName, char *ext1, char *ext2);
141 FontRastControl getT1libControl() { return t1libControl; }
142 FontRastControl getFreeTypeControl() { return freetypeControl; }
143 GString *getURLCommand() { return urlCommand; }
144 GBool getMapNumericCharNames() { return mapNumericCharNames; }
145 GBool getErrQuiet() { return errQuiet; }
146
147 CharCodeToUnicode *getCIDToUnicode(GString *collection);
148 UnicodeMap *getUnicodeMap(GString *encodingName);
149 CMap *getCMap(GString *collection, GString *cMapName);
150 UnicodeMap *getTextEncoding();
151
152 //----- functions to set parameters
153
154 void setPSFile(char *file);
155 GBool setPSPaperSize(char *size);
156 void setPSPaperWidth(int width);
157 void setPSPaperHeight(int height);
158 void setPSDuplex(GBool duplex);
159 void setPSLevel(PSLevel level);
160 void setPSEmbedType1(GBool embed);
161 void setPSEmbedTrueType(GBool embed);
162 void setPSOPI(GBool opi);
163 void setTextEncoding(char *encodingName);
164 GBool setTextEOL(char *s);
165 GBool setT1libControl(char *s);
166 GBool setFreeTypeControl(char *s);
167 void setErrQuiet(GBool errQuietA);
168
169private:
170
171 void parseNameToUnicode(GList *tokens, GString *fileName, int line);
172 void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
173 void parseUnicodeMap(GList *tokens, GString *fileName, int line);
174 void parseCMapDir(GList *tokens, GString *fileName, int line);
175 void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
176 void parseDisplayFont(GList *tokens, GBool isCID, DisplayFontParamKind kind,
177 GString *fileName, int line);
178 void parsePSFile(GList *tokens, GString *fileName, int line);
179 void parsePSPaperSize(GList *tokens, GString *fileName, int line);
180 void parsePSLevel(GList *tokens, GString *fileName, int line);
181 void parsePSFont(GList *tokens, GString *fileName, int line);
182 void parseTextEncoding(GList *tokens, GString *fileName, int line);
183 void parseTextEOL(GList *tokens, GString *fileName, int line);
184 void parseFontDir(GList *tokens, GString *fileName, int line);
185 void parseFontRastControl(char *cmdName, FontRastControl *val,
186 GList *tokens, GString *fileName, int line);
187 void parseURLCommand(GList *tokens, GString *fileName, int line);
188 void parseYesNo(char *cmdName, GBool *flag,
189 GList *tokens, GString *fileName, int line);
190 GBool setFontRastControl(FontRastControl *val, char *s);
191
192 //----- static tables
193
194 NameToCharCode * // mapping from char name to
195 macRomanReverseMap; // MacRomanEncoding index
196
197 //----- user-modifiable settings
198
199 NameToCharCode * // mapping from char name to Unicode
200 nameToUnicode;
201 GHash *cidToUnicodes; // files for mappings from char collections
202 // to Unicode, indexed by collection name
203 // [GString]
204 GHash *residentUnicodeMaps;// mappings from Unicode to char codes,
205 // indexed by encoding name [UnicodeMap]
206 GHash *unicodeMaps; // files for mappings from Unicode to char
207 // codes, indexed by encoding name [GString]
208 GHash *cMapDirs; // list of CMap dirs, indexed by collection
209 // name [GList[GString]]
210 GList *toUnicodeDirs; // list of ToUnicode CMap dirs [GString]
211 GHash *displayFonts; // display font info, indexed by font name
212 // [DisplayFontParam]
213 GHash *displayCIDFonts;// display CID font info, indexed by
214 // collection [DisplayFontParam]
215 GString *psFile; // PostScript file or command (for xpdf)
216 int psPaperWidth; // paper size, in PostScript points, for
217 int psPaperHeight; // PostScript output
218 GBool psDuplex; // enable duplexing in PostScript?
219 PSLevel psLevel; // PostScript level to generate
220 GHash *psFonts; // PostScript font info, indexed by PDF
221 // font name [PSFontParam]
222 GBool psEmbedType1; // embed Type 1 fonts?
223 GBool psEmbedTrueType;// embed TrueType fonts?
224 GBool psOPI; // generate PostScript OPI comments?
225 GString *textEncoding;// encoding (unicodeMap) to use for text
226 // output
227 EndOfLineKind textEOL;// type of EOL marker to use for text
228 // output
229 GList *fontDirs; // list of font dirs [GString]
230 FontRastControl t1libControl;// t1lib rasterization mode
231 FontRastControl // FreeType rasterization mode
232 freetypeControl;
233 GString *urlCommand; // command executed for URL links
234 GBool mapNumericCharNames;// map numeric char names (from font subsets)?
235 GBool errQuiet; // suppress error messages?
236
237 CIDToUnicodeCache *cidToUnicodeCache;
238 UnicodeMapCache *unicodeMapCache;
239 CMapCache *cMapCache;
240};
241
242#endif