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