00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef FTFONT_H
00012 #define FTFONT_H
00013
00014 #include <aconf.h>
00015
00016 #if FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
00017
00018 #ifdef USE_GCC_PRAGMAS
00019 #pragma interface
00020 #endif
00021
00022 #include <freetype/freetype.h>
00023 #include "CharTypes.h"
00024 #include "SFont.h"
00025
00026
00027
00028 class FTFontEngine: public SFontEngine {
00029 public:
00030
00031 FTFontEngine(Display *displayA, Visual *visualA, int depthA,
00032 Colormap colormapA, GBool aaA);
00033 GBool isOk() { return ok; }
00034 virtual ~FTFontEngine();
00035
00036 private:
00037
00038 FT_Library lib;
00039 GBool aa;
00040 Gulong palette[5];
00041 GBool ok;
00042
00043 friend class FTFontFile;
00044 friend class FTFont;
00045 };
00046
00047
00048
00049 enum FTFontIndexMode {
00050 ftFontModeUnicode,
00051 ftFontModeCharCode,
00052 ftFontModeCharCodeOffset,
00053 ftFontModeCodeMap,
00054 ftFontModeCodeMapDirect,
00055 ftFontModeCIDToGIDMap,
00056 ftFontModeCFFCharset
00057 };
00058
00059 class FTFontFile: public SFontFile {
00060 public:
00061
00062
00063 FTFontFile(FTFontEngine *engineA, char *fontFileName,
00064 char **fontEnc, GBool pdfFontHasEncoding);
00065
00066
00067 FTFontFile(FTFontEngine *engineA, char *fontFileName,
00068 Gushort *cidToGIDA, int cidToGIDLenA);
00069
00070
00071 FTFontFile(FTFontEngine *engineA, char *fontFileName);
00072
00073 GBool isOk() { return ok; }
00074 virtual ~FTFontFile();
00075
00076 private:
00077
00078 FTFontEngine *engine;
00079 FT_Face face;
00080 FTFontIndexMode mode;
00081 int charMapOffset;
00082 Guint *codeMap;
00083 Gushort *cidToGID;
00084 int cidToGIDLen;
00085 GBool ok;
00086
00087 friend class FTFont;
00088 };
00089
00090
00091
00092 struct FTFontCacheTag {
00093 Gushort code;
00094 Gushort mru;
00095 int x, y, w, h;
00096 };
00097
00098 class FTFont: public SFont {
00099 public:
00100
00101 FTFont(FTFontFile *fontFileA, double *m);
00102 GBool isOk() { return ok; }
00103 virtual ~FTFont();
00104 virtual GBool drawChar(Drawable d, int w, int h, GC gc,
00105 int x, int y, int r, int g, int b,
00106 CharCode c, Unicode u);
00107 virtual GBool getCharPath(CharCode c, Unicode u, GfxState *state);
00108
00109 private:
00110
00111 Guchar *getGlyphPixmap(CharCode c, Unicode u,
00112 int *x, int *y, int *w, int *h);
00113 static int charPathMoveTo(FT_Vector *pt, void *state);
00114 static int charPathLineTo(FT_Vector *pt, void *state);
00115 static int charPathConicTo(FT_Vector *ctrl, FT_Vector *pt, void *state);
00116 static int charPathCubicTo(FT_Vector *ctrl1, FT_Vector *ctrl2,
00117 FT_Vector *pt, void *state);
00118 FT_UInt getGlyphIndex(CharCode c, Unicode u);
00119
00120 FTFontFile *fontFile;
00121 FT_Size sizeObj;
00122 XImage *image;
00123 FT_Matrix matrix;
00124 int glyphW, glyphH;
00125 int glyphSize;
00126 Guchar *cache;
00127 FTFontCacheTag *cacheTags;
00128 int cacheSets;
00129 int cacheAssoc;
00130 GBool ok;
00131 };
00132
00133 #endif // FREETYPE2 && (HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H)
00134
00135 #endif