00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ROOT_TTF
00014 #define ROOT_TTF
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ROOT_Rtypes
00026 #include "Rtypes.h"
00027 #endif
00028
00029 #ifndef __CINT__
00030 # include <ft2build.h>
00031 # include FT_FREETYPE_H
00032 # include FT_GLYPH_H
00033 #else
00034 typedef void* FT_Library;
00035 typedef void* FT_Face;
00036 typedef void* FT_CharMap;
00037 typedef void* FT_Glyph;
00038 typedef signed long FT_Pos;
00039 struct FT_Vector { FT_Pos x, y; };
00040 struct FT_BBox { FT_Pos xMin, yMin, xMax, yMax; };
00041 struct FT_Matrix;
00042 struct FT_Bitmap;
00043 #endif
00044
00045
00046
00047 class TTGlyph {
00048 public:
00049 UInt_t fIndex;
00050 FT_Vector fPos;
00051 FT_Glyph fImage;
00052 };
00053
00054
00055 class TGX11TTF;
00056 class TGWin32;
00057
00058
00059 class TTF {
00060
00061 friend class TGX11TTF;
00062 friend class TGWin32;
00063
00064 private:
00065 enum { kTTMaxFonts = 32, kMaxGlyphs = 1024 };
00066
00067 static Int_t fgAscent;
00068 static FT_BBox fgCBox;
00069 static FT_CharMap fgCharMap[kTTMaxFonts];
00070 static Int_t fgCurFontIdx;
00071 static Int_t fgSymbItaFontIdx;
00072 static Int_t fgFontCount;
00073 static char *fgFontName[kTTMaxFonts];
00074 static FT_Face fgFace[kTTMaxFonts];
00075 static TTGlyph fgGlyphs[kMaxGlyphs];
00076 static Bool_t fgHinting;
00077 static Bool_t fgInit;
00078 static Bool_t fgKerning;
00079 static FT_Library fgLibrary;
00080 static Int_t fgNumGlyphs;
00081 static FT_Matrix *fgRotMatrix;
00082 static Bool_t fgSmoothing;
00083 static Int_t fgTBlankW;
00084 static Int_t fgWidth;
00085
00086 public:
00087 static Short_t CharToUnicode(UInt_t code);
00088 static void LayoutGlyphs();
00089 static void PrepareString(const char *string);
00090 static void SetRotationMatrix(Float_t angle);
00091
00092 public:
00093 TTF() { }
00094 virtual ~TTF();
00095
00096 static void Init();
00097 static void Cleanup();
00098 static Int_t GetAscent();
00099 static const FT_BBox &GetBox();
00100 static TTGlyph *GetGlyphs();
00101 static Bool_t GetHinting();
00102 static Bool_t GetKerning();
00103 static Int_t GetNumGlyphs();
00104 static FT_Matrix *GetRotMatrix();
00105 static Bool_t GetSmoothing();
00106 static Int_t GetWidth();
00107 static void SetHinting(Bool_t state);
00108 static void SetKerning(Bool_t state);
00109 static void SetSmoothing(Bool_t state);
00110 static void GetTextExtent(UInt_t &w, UInt_t &h, char *text);
00111 static void GetTextAdvance(UInt_t &a, char *text);
00112 static void SetTextFont(Font_t fontnumber);
00113 static Int_t SetTextFont(const char *fontname, Int_t italic=0);
00114 static void SetTextSize(Float_t textsize);
00115 static Bool_t IsInitialized();
00116 static void Version(Int_t &major, Int_t &minor, Int_t &patch);
00117
00118 ClassDef(TTF,0)
00119 };
00120
00121 #endif