1 //========================================================================
5 // An X wrapper for the FreeType font rasterizer.
7 // Copyright 2001-2002 Glyph & Cog, LLC
9 //========================================================================
14 #if FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
20 #include <freetype/freetype.h>
21 #include "CharTypes.h"
24 //------------------------------------------------------------------------
26 class FTFontEngine: public SFontEngine {
29 FTFontEngine(Display *displayA, Visual *visualA, int depthA,
30 Colormap colormapA, GBool aaA);
31 GBool isOk() { return ok; }
32 virtual ~FTFontEngine();
41 friend class FTFontFile;
45 //------------------------------------------------------------------------
47 enum FTFontIndexMode {
50 ftFontModeCharCodeOffset,
52 ftFontModeCodeMapDirect,
53 ftFontModeCIDToGIDMap,
57 class FTFontFile: public SFontFile {
60 // 8-bit font, TrueType or Type 1/1C
61 FTFontFile(FTFontEngine *engineA, char *fontFileName,
62 char **fontEnc, GBool pdfFontHasEncoding);
65 FTFontFile(FTFontEngine *engineA, char *fontFileName,
66 Gushort *cidToGIDA, int cidToGIDLenA);
68 // CID font, Type 0C (CFF)
69 FTFontFile(FTFontEngine *engineA, char *fontFileName);
71 GBool isOk() { return ok; }
72 virtual ~FTFontFile();
88 //------------------------------------------------------------------------
90 struct FTFontCacheTag {
92 Gushort mru; // valid bit (0x8000) and MRU index
93 int x, y, w, h; // offset and size of glyph
96 class FTFont: public SFont {
99 FTFont(FTFontFile *fontFileA, double *m);
100 GBool isOk() { return ok; }
102 virtual GBool drawChar(Drawable d, int w, int h, GC gc,
103 int x, int y, int r, int g, int b,
104 CharCode c, Unicode u);
105 virtual GBool getCharPath(CharCode c, Unicode u, GfxState *state);
109 Guchar *getGlyphPixmap(CharCode c, Unicode u,
110 int *x, int *y, int *w, int *h);
111 static int charPathMoveTo(FT_Vector *pt, void *state);
112 static int charPathLineTo(FT_Vector *pt, void *state);
113 static int charPathConicTo(FT_Vector *ctrl, FT_Vector *pt, void *state);
114 static int charPathCubicTo(FT_Vector *ctrl1, FT_Vector *ctrl2,
115 FT_Vector *pt, void *state);
116 FT_UInt getGlyphIndex(CharCode c, Unicode u);
118 FTFontFile *fontFile;
122 int glyphW, glyphH; // size of glyph pixmaps
123 int glyphSize; // size of glyph pixmaps, in bytes
124 Guchar *cache; // glyph pixmap cache
125 FTFontCacheTag *cacheTags; // cache tags, i.e., char codes
126 int cacheSets; // number of sets in cache
127 int cacheAssoc; // cache associativity (glyphs per set)
131 #endif // FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)