filters

GlobalParams.h

00001 //========================================================================
00002 //
00003 // GlobalParams.h
00004 //
00005 // Copyright 2001-2002 Glyph & Cog, LLC
00006 //
00007 //========================================================================
00008 
00009 #ifndef GLOBALPARAMS_H
00010 #define GLOBALPARAMS_H
00011 
00012 #include <aconf.h>
00013 
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017 
00018 #include <stdio.h>
00019 #include "gtypes.h"
00020 #include "CharTypes.h"
00021 
00022 class GString;
00023 class GList;
00024 class GHash;
00025 class NameToCharCode;
00026 class CharCodeToUnicode;
00027 class CIDToUnicodeCache;
00028 class UnicodeMap;
00029 class UnicodeMapCache;
00030 class CMap;
00031 class CMapCache;
00032 class GlobalParams;
00033 
00034 //------------------------------------------------------------------------
00035 
00036 // The global parameters object.
00037 extern GlobalParams *globalParams;
00038 
00039 //------------------------------------------------------------------------
00040 
00041 enum DisplayFontParamKind {
00042   displayFontX,
00043   displayFontT1,
00044   displayFontTT
00045 };
00046 
00047 class DisplayFontParam {
00048 public:
00049 
00050   GString *name;        // font name for 8-bit fonts and named
00051                 //   CID fonts; collection name for
00052                 //   generic CID fonts
00053   DisplayFontParamKind kind;
00054   union {
00055     struct {
00056       GString *xlfd;
00057       GString *encoding;
00058     } x;
00059     struct {
00060       GString *fileName;
00061     } t1;
00062     struct {
00063       GString *fileName;
00064     } tt;
00065   };
00066 
00067   DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
00068   DisplayFontParam(const char *nameA, const char *xlfdA, const char *encodingA);
00069   ~DisplayFontParam();
00070 };
00071 
00072 // Font rasterizer control.
00073 enum FontRastControl {
00074   fontRastNone,         // don't use this rasterizer
00075   fontRastPlain,        // use it, without anti-aliasing
00076   fontRastAALow,        // use it, with low-level anti-aliasing
00077   fontRastAAHigh        // use it, with high-level anti-aliasing
00078 };
00079 
00080 //------------------------------------------------------------------------
00081 
00082 class PSFontParam {
00083 public:
00084 
00085   GString *pdfFontName;     // PDF font name for 8-bit fonts and
00086                 //   named 16-bit fonts; char collection
00087                 //   name for generic 16-bit fonts
00088   int wMode;            // writing mode (0=horiz, 1=vert) for
00089                 //   16-bit fonts
00090   GString *psFontName;      // PostScript font name
00091   GString *encoding;        // encoding, for 16-bit fonts only
00092 
00093   PSFontParam(GString *pdfFontNameA, int wModeA,
00094           GString *psFontNameA, GString *encodingA);
00095   ~PSFontParam();
00096 };
00097 
00098 //------------------------------------------------------------------------
00099 
00100 enum PSLevel {
00101   psLevel1,
00102   psLevel1Sep,
00103   psLevel2,
00104   psLevel2Sep,
00105   psLevel3,
00106   psLevel3Sep
00107 };
00108 
00109 //------------------------------------------------------------------------
00110 
00111 enum EndOfLineKind {
00112   eolUnix,          // LF
00113   eolDOS,           // CR+LF
00114   eolMac            // CR
00115 };
00116 
00117 //------------------------------------------------------------------------
00118 
00119 class GlobalParams {
00120 public:
00121 
00122   // Initialize the global parameters by attempting to read a config
00123   // file.
00124   GlobalParams(const char *cfgFileName);
00125 
00126   ~GlobalParams();
00127 
00128   //----- accessors
00129 
00130   CharCode getMacRomanCharCode(const char *charName);
00131 
00132   Unicode mapNameToUnicode(const char *charName);
00133   FILE *getCIDToUnicodeFile(const GString *collection);
00134   UnicodeMap *getResidentUnicodeMap(const GString *encodingName);
00135   FILE *getUnicodeMapFile(const GString *encodingName);
00136   FILE *findCMapFile(const GString *collection, const GString *cMapName);
00137   FILE *findToUnicodeFile(const GString *name);
00138   DisplayFontParam *getDisplayFont(const GString *fontName);
00139   DisplayFontParam *getDisplayCIDFont(const GString *fontName,
00140                                       const GString *collection);
00141   GString *getPSFile() { return psFile; }
00142   int getPSPaperWidth() { return psPaperWidth; }
00143   int getPSPaperHeight() { return psPaperHeight; }
00144   GBool getPSDuplex() { return psDuplex; }
00145   PSLevel getPSLevel() { return psLevel; }
00146   PSFontParam *getPSFont(GString *fontName);
00147   PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
00148   GBool getPSEmbedType1() { return psEmbedType1; }
00149   GBool getPSEmbedTrueType() { return psEmbedTrueType; }
00150   GBool getPSEmbedCIDPostScript() { return psEmbedCIDPostScript; }
00151   GBool getPSEmbedCIDTrueType() { return psEmbedCIDTrueType; }
00152   GBool getPSOPI() { return psOPI; }
00153   GBool getPSASCIIHex() { return psASCIIHex; }
00154   GString *getTextEncodingName() { return textEncoding; }
00155   EndOfLineKind getTextEOL() { return textEOL; }
00156   GBool getTextKeepTinyChars() { return textKeepTinyChars; }
00157   GString *findFontFile(const GString *fontName, const char *ext1, const char *ext2);
00158   GString *getInitialZoom() { return initialZoom; }
00159   FontRastControl getT1libControl() { return t1libControl; }
00160   FontRastControl getFreeTypeControl() { return freetypeControl; }
00161   GString *getURLCommand() { return urlCommand; }
00162   GString *getMovieCommand() { return movieCommand; }
00163   GBool getMapNumericCharNames() { return mapNumericCharNames; }
00164   GBool getPrintCommands() { return printCommands; }
00165   GBool getErrQuiet() { return errQuiet; }
00166 
00167   CharCodeToUnicode *getCIDToUnicode(GString *collection);
00168   UnicodeMap *getUnicodeMap(GString *encodingName);
00169   CMap *getCMap(GString *collection, GString *cMapName);
00170   UnicodeMap *getTextEncoding();
00171 
00172   //----- functions to set parameters
00173 
00174   void addDisplayFont(DisplayFontParam *param);
00175   void setPSFile(char *file);
00176   GBool setPSPaperSize(char *size);
00177   void setPSPaperWidth(int width);
00178   void setPSPaperHeight(int height);
00179   void setPSDuplex(GBool duplex);
00180   void setPSLevel(PSLevel level);
00181   void setPSEmbedType1(GBool embed);
00182   void setPSEmbedTrueType(GBool embed);
00183   void setPSEmbedCIDPostScript(GBool embed);
00184   void setPSEmbedCIDTrueType(GBool embed);
00185   void setPSOPI(GBool opi);
00186   void setPSASCIIHex(GBool hex);
00187   void setTextEncoding(char *encodingName);
00188   GBool setTextEOL(char *s);
00189   void setTextKeepTinyChars(GBool keep);
00190   void setInitialZoom(char *s);
00191   GBool setT1libControl(char *s);
00192   GBool setFreeTypeControl(char *s);
00193   void setMapNumericCharNames(GBool map);
00194   void setPrintCommands(GBool printCommandsA);
00195   void setErrQuiet(GBool errQuietA);
00196 
00197 private:
00198 
00199   void parseFile(GString *fileName, FILE *f);
00200   void parseNameToUnicode(GList *tokens, GString *fileName, int line);
00201   void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
00202   void parseUnicodeMap(GList *tokens, GString *fileName, int line);
00203   void parseCMapDir(GList *tokens, GString *fileName, int line);
00204   void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
00205   void parseDisplayFont(GList *tokens, GHash *fontHash,
00206             DisplayFontParamKind kind,
00207             GString *fileName, int line);
00208   void parsePSFile(GList *tokens, GString *fileName, int line);
00209   void parsePSPaperSize(GList *tokens, GString *fileName, int line);
00210   void parsePSLevel(GList *tokens, GString *fileName, int line);
00211   void parsePSFont(GList *tokens, GString *fileName, int line);
00212   void parsePSFont16(const char *cmdName, GList *fontList,
00213              GList *tokens, GString *fileName, int line);
00214   void parseTextEncoding(GList *tokens, GString *fileName, int line);
00215   void parseTextEOL(GList *tokens, GString *fileName, int line);
00216   void parseFontDir(GList *tokens, GString *fileName, int line);
00217   void parseInitialZoom(GList *tokens, GString *fileName, int line);
00218   void parseFontRastControl(const char *cmdName, FontRastControl *val,
00219                 GList *tokens, GString *fileName, int line);
00220   void parseCommand(const char *cmdName, GString **val,
00221             GList *tokens, GString *fileName, int line);
00222   void parseYesNo(const char *cmdName, GBool *flag,
00223           GList *tokens, GString *fileName, int line);
00224   GBool setFontRastControl(FontRastControl *val, const char *s);
00225 
00226   //----- static tables
00227 
00228   NameToCharCode *      // mapping from char name to
00229     macRomanReverseMap;     //   MacRomanEncoding index
00230 
00231   //----- user-modifiable settings
00232 
00233   NameToCharCode *      // mapping from char name to Unicode
00234     nameToUnicode;
00235   GHash *cidToUnicodes;     // files for mappings from char collections
00236                 //   to Unicode, indexed by collection name
00237                 //   [GString]
00238   GHash *residentUnicodeMaps;   // mappings from Unicode to char codes,
00239                 //   indexed by encoding name [UnicodeMap]
00240   GHash *unicodeMaps;       // files for mappings from Unicode to char
00241                 //   codes, indexed by encoding name [GString]
00242   GHash *cMapDirs;      // list of CMap dirs, indexed by collection
00243                 //   name [GList[GString]]
00244   GList *toUnicodeDirs;     // list of ToUnicode CMap dirs [GString]
00245   GHash *displayFonts;      // display font info, indexed by font name
00246                 //   [DisplayFontParam]
00247   GHash *displayCIDFonts;   // display CID font info, indexed by
00248                 //   collection [DisplayFontParam]
00249   GHash *displayNamedCIDFonts;  // display CID font info, indexed by
00250                 //   font name [DisplayFontParam]
00251   GString *psFile;      // PostScript file or command (for xpdf)
00252   int psPaperWidth;     // paper size, in PostScript points, for
00253   int psPaperHeight;        //   PostScript output
00254   GBool psDuplex;       // enable duplexing in PostScript?
00255   PSLevel psLevel;      // PostScript level to generate
00256   GHash *psFonts;       // PostScript font info, indexed by PDF
00257                 //   font name [PSFontParam]
00258   GList *psNamedFonts16;    // named 16-bit fonts [PSFontParam]
00259   GList *psFonts16;     // generic 16-bit fonts [PSFontParam]
00260   GBool psEmbedType1;       // embed Type 1 fonts?
00261   GBool psEmbedTrueType;    // embed TrueType fonts?
00262   GBool psEmbedCIDPostScript;   // embed CID PostScript fonts?
00263   GBool psEmbedCIDTrueType; // embed CID TrueType fonts?
00264   GBool psOPI;          // generate PostScript OPI comments?
00265   GBool psASCIIHex;     // use ASCIIHex instead of ASCII85?
00266   GString *textEncoding;    // encoding (unicodeMap) to use for text
00267                 //   output
00268   EndOfLineKind textEOL;    // type of EOL marker to use for text
00269                 //   output
00270   GBool textKeepTinyChars;  // keep all characters in text output
00271   GList *fontDirs;      // list of font dirs [GString]
00272   GString *initialZoom;     // initial zoom level
00273   FontRastControl t1libControl; // t1lib rasterization mode
00274   FontRastControl       // FreeType rasterization mode
00275     freetypeControl;
00276   GString *urlCommand;      // command executed for URL links
00277   GString *movieCommand;    // command executed for movie annotations
00278   GBool mapNumericCharNames;    // map numeric char names (from font subsets)?
00279   GBool printCommands;      // print the drawing commands
00280   GBool errQuiet;       // suppress error messages?
00281 
00282   CIDToUnicodeCache *cidToUnicodeCache;
00283   UnicodeMapCache *unicodeMapCache;
00284   CMapCache *cMapCache;
00285 };
00286 
00287 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys