filters

T1Font.h

00001 //========================================================================
00002 //
00003 // T1Font.h
00004 //
00005 // An X wrapper for the t1lib Type 1 font rasterizer.
00006 //
00007 // Copyright 2001-2002 Glyph & Cog, LLC
00008 //
00009 //========================================================================
00010 
00011 #ifndef T1FONT_H
00012 #define T1FONT_H
00013 
00014 #include <aconf.h>
00015 
00016 #if HAVE_T1LIB_H
00017 
00018 #ifdef USE_GCC_PRAGMAS
00019 #pragma interface
00020 #endif
00021 
00022 #include <X11/Xlib.h>
00023 #include <t1lib.h>
00024 #include "SFont.h"
00025 
00026 class GfxState;
00027 
00028 //------------------------------------------------------------------------
00029 
00030 class T1FontEngine: public SFontEngine {
00031 public:
00032 
00033   T1FontEngine(Display *displayA, Visual *visualA, int depthA,
00034            Colormap colormapA, GBool aaA, GBool aaHighA);
00035   GBool isOk() { return ok; }
00036   virtual ~T1FontEngine();
00037 
00038 private:
00039 
00040   GBool aa;         // use anti-aliasing?
00041   GBool aaHigh;         // use high-res anti-aliasing?
00042   GBool ok;
00043 
00044   static int t1libInitCount;
00045 
00046   friend class T1FontFile;
00047   friend class T1Font;
00048 };
00049 
00050 //------------------------------------------------------------------------
00051 
00052 class T1FontFile: public SFontFile {
00053 public:
00054 
00055   T1FontFile(T1FontEngine *engineA, char *fontFileName,
00056          char **fontEnc, double *bboxA);
00057   GBool isOk() { return ok; }
00058   virtual ~T1FontFile();
00059 
00060 private:
00061 
00062   T1FontEngine *engine;
00063   int id;           // t1lib font ID
00064   char **enc;
00065   char *encStr;
00066   double bbox[4];
00067   GBool ok;
00068 
00069   friend class T1Font;
00070 };
00071 
00072 //------------------------------------------------------------------------
00073 
00074 struct T1FontCacheTag {
00075   Gushort code;
00076   Gushort mru;          // valid bit (0x8000) and MRU index
00077   int x, y, w, h;       // offset and size of glyph
00078 };
00079 
00080 class T1Font: public SFont {
00081 public:
00082 
00083   T1Font(T1FontFile *fontFileA, double *m);
00084   GBool isOk() { return ok; }
00085   virtual ~T1Font();
00086   virtual GBool drawChar(Drawable d, int w, int h, GC gc,
00087              int x, int y, int r, int g, int b,
00088              CharCode c, Unicode u);
00089   virtual GBool getCharPath(CharCode c, Unicode u, GfxState *state);
00090 
00091 private:
00092 
00093   Guchar *getGlyphPixmap(CharCode c, int *x, int *y, int *w, int *h);
00094 
00095   T1FontFile *fontFile;
00096   int id;
00097   float size;
00098   XImage *image;
00099   int glyphW, glyphH;       // size of glyph pixmaps
00100   int glyphSize;        // size of glyph pixmaps, in bytes
00101   Guchar *cache;        // glyph pixmap cache
00102   T1FontCacheTag *cacheTags;    // cache tags, i.e., char codes
00103   int cacheSets;        // number of sets in cache
00104   int cacheAssoc;       // cache associativity (glyphs per set)
00105   GBool ok;
00106 };
00107 
00108 #endif // HAVE_T1LIB_H
00109 
00110 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys