1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
//========================================================================
//
// T1Font.h
//
// An X wrapper for the t1lib Type 1 font rasterizer.
//
// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef T1FONT_H
#define T1FONT_H
#include <aconf.h>
#if HAVE_T1LIB_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include <X11/Xlib.h>
#include <t1lib.h>
#include "SFont.h"
class GfxState;
//------------------------------------------------------------------------
class T1FontEngine: public SFontEngine {
public:
T1FontEngine(Display *displayA, Visual *visualA, int depthA,
Colormap colormapA, GBool aaA, GBool aaHighA);
GBool isOk() { return ok; }
virtual ~T1FontEngine();
private:
GBool aa; // use anti-aliasing?
GBool aaHigh; // use high-res anti-aliasing?
GBool ok;
static int t1libInitCount;
friend class T1FontFile;
friend class T1Font;
};
//------------------------------------------------------------------------
class T1FontFile: public SFontFile {
public:
T1FontFile(T1FontEngine *engineA, char *fontFileName,
char **fontEnc, double *bboxA);
GBool isOk() { return ok; }
virtual ~T1FontFile();
private:
T1FontEngine *engine;
int id; // t1lib font ID
char **enc;
char *encStr;
double bbox[4];
GBool ok;
friend class T1Font;
};
//------------------------------------------------------------------------
struct T1FontCacheTag {
Gushort code;
Gushort mru; // valid bit (0x8000) and MRU index
int x, y, w, h; // offset and size of glyph
};
class T1Font: public SFont {
public:
T1Font(T1FontFile *fontFileA, double *m);
GBool isOk() { return ok; }
virtual ~T1Font();
virtual GBool drawChar(Drawable d, int w, int h, GC gc,
int x, int y, int r, int g, int b,
CharCode c, Unicode u);
virtual GBool getCharPath(CharCode c, Unicode u, GfxState *state);
private:
Guchar *getGlyphPixmap(CharCode c, int *x, int *y, int *w, int *h,
GBool *tempBitmap);
T1FontFile *fontFile;
int id;
float size;
XImage *image;
int glyphW, glyphH; // size of glyph pixmaps
int glyphSize; // size of glyph pixmaps, in bytes
Guchar *cache; // glyph pixmap cache
T1FontCacheTag *cacheTags; // cache tags, i.e., char codes
int cacheSets; // number of sets in cache
int cacheAssoc; // cache associativity (glyphs per set)
GBool ok;
};
#endif // HAVE_T1LIB_H
#endif
|