Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

GlobalParams.h

Go to the documentation of this file.
00001 //========================================================================
00002 //
00003 // GlobalParams.h
00004 //
00005 // Copyright 2001-2003 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 #if MULTITHREADED
00023 #include "GMutex.h"
00024 #endif
00025 
00026 class GString;
00027 class GList;
00028 class GHash;
00029 class NameToCharCode;
00030 class CharCodeToUnicode;
00031 class CharCodeToUnicodeCache;
00032 class UnicodeMap;
00033 class UnicodeMapCache;
00034 class CMap;
00035 class CMapCache;
00036 class GlobalParams;
00037 
00038 //------------------------------------------------------------------------
00039 
00040 // The global parameters object.
00041 extern GlobalParams *globalParams;
00042 
00043 //------------------------------------------------------------------------
00044 
00045 enum DisplayFontParamKind {
00046   displayFontT1,
00047   displayFontTT
00048 };
00049 
00050 class DisplayFontParam {
00051 public:
00052 
00053   GString *name;                // font name for 8-bit fonts and named
00054                                 //   CID fonts; collection name for
00055                                 //   generic CID fonts
00056   DisplayFontParamKind kind;
00057   union {
00058     struct {
00059       GString *fileName;
00060     } t1;
00061     struct {
00062       GString *fileName;
00063     } tt;
00064   };
00065 
00066   DisplayFontParam(GString *nameA, DisplayFontParamKind kindA);
00067   ~DisplayFontParam();
00068 };
00069 
00070 //------------------------------------------------------------------------
00071 
00072 class PSFontParam {
00073 public:
00074 
00075   GString *pdfFontName;         // PDF font name for 8-bit fonts and
00076                                 //   named 16-bit fonts; char collection
00077                                 //   name for generic 16-bit fonts
00078   int wMode;                    // writing mode (0=horiz, 1=vert) for
00079                                 //   16-bit fonts
00080   GString *psFontName;          // PostScript font name
00081   GString *encoding;            // encoding, for 16-bit fonts only
00082 
00083   PSFontParam(GString *pdfFontNameA, int wModeA,
00084               GString *psFontNameA, GString *encodingA);
00085   ~PSFontParam();
00086 };
00087 
00088 //------------------------------------------------------------------------
00089 
00090 enum PSLevel {
00091   psLevel1,
00092   psLevel1Sep,
00093   psLevel2,
00094   psLevel2Sep,
00095   psLevel3,
00096   psLevel3Sep
00097 };
00098 
00099 //------------------------------------------------------------------------
00100 
00101 enum EndOfLineKind {
00102   eolUnix,                      // LF
00103   eolDOS,                       // CR+LF
00104   eolMac                        // CR
00105 };
00106 
00107 //------------------------------------------------------------------------
00108 
00109 class GlobalParams {
00110 public:
00111 
00112   // Initialize the global parameters by attempting to read a config
00113   // file.
00114   GlobalParams(char *cfgFileName);
00115 
00116   ~GlobalParams();
00117 
00118   void setupBaseFonts(char *dir);
00119 
00120   //----- accessors
00121 
00122   CharCode getMacRomanCharCode(char *charName);
00123 
00124   Unicode mapNameToUnicode(char *charName);
00125   UnicodeMap *getResidentUnicodeMap(GString *encodingName);
00126   FILE *getUnicodeMapFile(GString *encodingName);
00127   FILE *findCMapFile(GString *collection, GString *cMapName);
00128   FILE *findToUnicodeFile(GString *name);
00129   DisplayFontParam *getDisplayFont(GString *fontName);
00130   DisplayFontParam *getDisplayCIDFont(GString *fontName, GString *collection);
00131   GString *getPSFile();
00132   int getPSPaperWidth();
00133   int getPSPaperHeight();
00134   void getPSImageableArea(int *llx, int *lly, int *urx, int *ury);
00135   GBool getPSDuplex();
00136   GBool getPSCrop();
00137   GBool getPSExpandSmaller();
00138   GBool getPSShrinkLarger();
00139   GBool getPSCenter();
00140   PSLevel getPSLevel();
00141   PSFontParam *getPSFont(GString *fontName);
00142   PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
00143   GBool getPSEmbedType1();
00144   GBool getPSEmbedTrueType();
00145   GBool getPSEmbedCIDPostScript();
00146   GBool getPSEmbedCIDTrueType();
00147   GBool getPSOPI();
00148   GBool getPSASCIIHex();
00149   GString *getTextEncodingName();
00150   EndOfLineKind getTextEOL();
00151   GBool getTextPageBreaks();
00152   GBool getTextKeepTinyChars();
00153   GString *findFontFile(GString *fontName, char **exts);
00154   GString *getInitialZoom();
00155   GBool getEnableT1lib();
00156   GBool getEnableFreeType();
00157   GBool getAntialias();
00158   GString *getURLCommand() { return urlCommand; }
00159   GString *getMovieCommand() { return movieCommand; }
00160   GBool getMapNumericCharNames();
00161   GBool getPrintCommands();
00162   GBool getErrQuiet();
00163 
00164   CharCodeToUnicode *getCIDToUnicode(GString *collection);
00165   CharCodeToUnicode *getUnicodeToUnicode(GString *fontName);
00166   UnicodeMap *getUnicodeMap(GString *encodingName);
00167   CMap *getCMap(GString *collection, GString *cMapName);
00168   UnicodeMap *getTextEncoding();
00169 
00170   //----- functions to set parameters
00171 
00172   void addDisplayFont(DisplayFontParam *param);
00173   void setPSFile(char *file);
00174   GBool setPSPaperSize(char *size);
00175   void setPSPaperWidth(int width);
00176   void setPSPaperHeight(int height);
00177   void setPSImageableArea(int llx, int lly, int urx, int ury);
00178   void setPSDuplex(GBool duplex);
00179   void setPSCrop(GBool crop);
00180   void setPSExpandSmaller(GBool expand);
00181   void setPSShrinkLarger(GBool shrink);
00182   void setPSCenter(GBool center);
00183   void setPSLevel(PSLevel level);
00184   void setPSEmbedType1(GBool embed);
00185   void setPSEmbedTrueType(GBool embed);
00186   void setPSEmbedCIDPostScript(GBool embed);
00187   void setPSEmbedCIDTrueType(GBool embed);
00188   void setPSOPI(GBool opi);
00189   void setPSASCIIHex(GBool hex);
00190   void setTextEncoding(char *encodingName);
00191   GBool setTextEOL(char *s);
00192   void setTextPageBreaks(GBool pageBreaks);
00193   void setTextKeepTinyChars(GBool keep);
00194   void setInitialZoom(char *s);
00195   GBool setEnableT1lib(char *s);
00196   GBool setEnableFreeType(char *s);
00197   GBool setAntialias(char *s);
00198   void setMapNumericCharNames(GBool map);
00199   void setPrintCommands(GBool printCommandsA);
00200   void setErrQuiet(GBool errQuietA);
00201 
00202 private:
00203 
00204   void parseFile(GString *fileName, FILE *f);
00205   void parseNameToUnicode(GList *tokens, GString *fileName, int line);
00206   void parseCIDToUnicode(GList *tokens, GString *fileName, int line);
00207   void parseUnicodeToUnicode(GList *tokens, GString *fileName, int line);
00208   void parseUnicodeMap(GList *tokens, GString *fileName, int line);
00209   void parseCMapDir(GList *tokens, GString *fileName, int line);
00210   void parseToUnicodeDir(GList *tokens, GString *fileName, int line);
00211   void parseDisplayFont(GList *tokens, GHash *fontHash,
00212                         DisplayFontParamKind kind,
00213                         GString *fileName, int line);
00214   void parsePSFile(GList *tokens, GString *fileName, int line);
00215   void parsePSPaperSize(GList *tokens, GString *fileName, int line);
00216   void parsePSImageableArea(GList *tokens, GString *fileName, int line);
00217   void parsePSLevel(GList *tokens, GString *fileName, int line);
00218   void parsePSFont(GList *tokens, GString *fileName, int line);
00219   void parsePSFont16(char *cmdName, GList *fontList,
00220                      GList *tokens, GString *fileName, int line);
00221   void parseTextEncoding(GList *tokens, GString *fileName, int line);
00222   void parseTextEOL(GList *tokens, GString *fileName, int line);
00223   void parseFontDir(GList *tokens, GString *fileName, int line);
00224   void parseInitialZoom(GList *tokens, GString *fileName, int line);
00225   void parseCommand(char *cmdName, GString **val,
00226                     GList *tokens, GString *fileName, int line);
00227   void parseYesNo(char *cmdName, GBool *flag,
00228                   GList *tokens, GString *fileName, int line);
00229   GBool parseYesNo2(char *token, GBool *flag);
00230   UnicodeMap *getUnicodeMap2(GString *encodingName);
00231 
00232   //----- static tables
00233 
00234   NameToCharCode *              // mapping from char name to
00235     macRomanReverseMap;         //   MacRomanEncoding index
00236 
00237   //----- user-modifiable settings
00238 
00239   NameToCharCode *              // mapping from char name to Unicode
00240     nameToUnicode;
00241   GHash *cidToUnicodes;         // files for mappings from char collections
00242                                 //   to Unicode, indexed by collection name
00243                                 //   [GString]
00244   GHash *unicodeToUnicodes;     // files for Unicode-to-Unicode mappings,
00245                                 //   indexed by font name pattern [GString]
00246   GHash *residentUnicodeMaps;   // mappings from Unicode to char codes,
00247                                 //   indexed by encoding name [UnicodeMap]
00248   GHash *unicodeMaps;           // files for mappings from Unicode to char
00249                                 //   codes, indexed by encoding name [GString]
00250   GHash *cMapDirs;              // list of CMap dirs, indexed by collection
00251                                 //   name [GList[GString]]
00252   GList *toUnicodeDirs;         // list of ToUnicode CMap dirs [GString]
00253   GHash *displayFonts;          // display font info, indexed by font name
00254                                 //   [DisplayFontParam]
00255   GHash *displayCIDFonts;       // display CID font info, indexed by
00256                                 //   collection [DisplayFontParam]
00257   GHash *displayNamedCIDFonts;  // display CID font info, indexed by
00258                                 //   font name [DisplayFontParam]
00259   GString *psFile;              // PostScript file or command (for xpdf)
00260   int psPaperWidth;             // paper size, in PostScript points, for
00261   int psPaperHeight;            //   PostScript output
00262   int psImageableLLX,           // imageable area, in PostScript points,
00263       psImageableLLY,           //   for PostScript output
00264       psImageableURX,
00265       psImageableURY;
00266   GBool psCrop;                 // crop PS output to CropBox
00267   GBool psExpandSmaller;        // expand smaller pages to fill paper
00268   GBool psShrinkLarger;         // shrink larger pages to fit paper
00269   GBool psCenter;               // center pages on the paper
00270   GBool psDuplex;               // enable duplexing in PostScript?
00271   PSLevel psLevel;              // PostScript level to generate
00272   GHash *psFonts;               // PostScript font info, indexed by PDF
00273                                 //   font name [PSFontParam]
00274   GList *psNamedFonts16;        // named 16-bit fonts [PSFontParam]
00275   GList *psFonts16;             // generic 16-bit fonts [PSFontParam]
00276   GBool psEmbedType1;           // embed Type 1 fonts?
00277   GBool psEmbedTrueType;        // embed TrueType fonts?
00278   GBool psEmbedCIDPostScript;   // embed CID PostScript fonts?
00279   GBool psEmbedCIDTrueType;     // embed CID TrueType fonts?
00280   GBool psOPI;                  // generate PostScript OPI comments?
00281   GBool psASCIIHex;             // use ASCIIHex instead of ASCII85?
00282   GString *textEncoding;        // encoding (unicodeMap) to use for text
00283                                 //   output
00284   EndOfLineKind textEOL;        // type of EOL marker to use for text
00285                                 //   output
00286   GBool textPageBreaks;         // insert end-of-page markers?
00287   GBool textKeepTinyChars;      // keep all characters in text output
00288   GList *fontDirs;              // list of font dirs [GString]
00289   GString *initialZoom;         // initial zoom level
00290   GBool enableT1lib;            // t1lib enable flag
00291   GBool enableFreeType;         // FreeType enable flag
00292   GBool antialias;              // anti-aliasing enable flag
00293   GString *urlCommand;          // command executed for URL links
00294   GString *movieCommand;        // command executed for movie annotations
00295   GBool mapNumericCharNames;    // map numeric char names (from font subsets)?
00296   GBool printCommands;          // print the drawing commands
00297   GBool errQuiet;               // suppress error messages?
00298 
00299   CharCodeToUnicodeCache *cidToUnicodeCache;
00300   CharCodeToUnicodeCache *unicodeToUnicodeCache;
00301   UnicodeMapCache *unicodeMapCache;
00302   CMapCache *cMapCache;
00303 
00304 #if MULTITHREADED
00305   GMutex mutex;
00306   GMutex unicodeMapCacheMutex;
00307   GMutex cMapCacheMutex;
00308 #endif
00309 };
00310 
00311 #endif

Generated on Wed Nov 3 12:58:57 2004 for Lemur Toolkit by doxygen1.2.18