Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

GlobalParams.h

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

Generated on Sat Nov 5 16:18:15 2005 for OPIE by  doxygen 1.4.2