Logo ROOT   6.08/07
Reference Guide
TTF.h
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Olivier Couet 01/10/02
3 // Author: Fons Rademakers 21/11/98
4 
5 /*************************************************************************
6  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
7  * All rights reserved. *
8  * *
9  * For the licensing terms see $ROOTSYS/LICENSE. *
10  * For the list of contributors see $ROOTSYS/README/CREDITS. *
11  *************************************************************************/
12 
13 #ifndef ROOT_TTF
14 #define ROOT_TTF
15 
16 
17 #ifndef ROOT_Rtypes
18 #include "Rtypes.h"
19 #endif
20 
21 /// @cond DOXYGEN_IGNORE
22 // Forward declare for the headers:
23 // # include <ft2build.h>
24 // # include FT_FREETYPE_H
25 // # include FT_GLYPH_H
26 extern "C" {
27  struct FT_LibraryRec_;
28  struct FT_FaceRec_;
29  struct FT_CharMapRec_;
30  struct FT_GlyphRec_;
31  struct FT_Matrix_;
32  struct FT_Bitmap_;
33  typedef struct FT_LibraryRec_* FT_Library;
34  typedef struct FT_FaceRec_* FT_Face;
35  typedef struct FT_CharMapRec_* FT_CharMap;
36  typedef struct FT_GlyphRec_* FT_Glyph;
37  typedef struct FT_Matrix_ FT_Matrix;
38  typedef struct FT_Bitmap_ FT_Bitmap; // Forward declared for TGX11TTF.h's benefit
39  typedef signed long FT_Pos;
40  #ifndef FT_FREETYPE_H
41  struct FT_Vector_ { FT_Pos x, y; };
42  struct FT_BBox_ { FT_Pos xMin, yMin, xMax, yMax; };
43  #endif
44  typedef struct FT_Vector_ FT_Vector;
45  typedef struct FT_BBox_ FT_BBox;
46 }
47 /// @endcond
48 
49 
50 class TGX11TTF;
51 class TGWin32;
52 class TMathTextRenderer;
53 
54 
55 class TTF {
56 
57 friend class TGX11TTF;
58 friend class TGWin32;
59 friend class TMathTextRenderer;
60 
61 public:
62 
63 /** \class TTGlyph
64 TTF helper class containing glyphs description.
65 */
66 
67  class TTGlyph {
68  public:
69  UInt_t fIndex; ///< glyph index in face
70  FT_Vector fPos; ///< position of glyph origin
71  FT_Glyph fImage; ///< glyph image
72  };
73 
74 protected:
75  enum { kTTMaxFonts = 32, kMaxGlyphs = 1024 };
76 
77  static Int_t fgAscent; ///< string ascent, used to compute Y alignment
78  static FT_BBox fgCBox; ///< string control box
79  static FT_CharMap fgCharMap[kTTMaxFonts]; ///< font character map
80  static Int_t fgCurFontIdx; ///< current font index
81  static Int_t fgSymbItaFontIdx; ///< Symbol italic font index
82  static Int_t fgFontCount; ///< number of fonts loaded
83  static char *fgFontName[kTTMaxFonts]; ///< font name
84  static FT_Face fgFace[kTTMaxFonts]; ///< font face
85  static TTF::TTGlyph fgGlyphs[kMaxGlyphs]; ///< glyphs
86  static Bool_t fgHinting; ///< use hinting (true by default)
87  static Bool_t fgInit; ///< true if the Init has been called
88  static Bool_t fgKerning; ///< use kerning (true by default)
89  static FT_Library fgLibrary; ///< FreeType font library
90  static Int_t fgNumGlyphs; ///< number of glyphs in the string
91  static FT_Matrix *fgRotMatrix; ///< rotation matrix
92  static Bool_t fgSmoothing; ///< use anti-aliasing (true when >8 planes, false otherwise)
93  static Int_t fgTBlankW; ///< trailing blanks width
94  static Int_t fgWidth; ///< string width, used to compute X alignment
95 
96 public:
97  static Short_t CharToUnicode(UInt_t code);
98  static void LayoutGlyphs();
99  static void PrepareString(const char *string);
100  static void PrepareString(const wchar_t *string);
101  static void SetRotationMatrix(Float_t angle);
102 
103 public:
104  TTF() { }
105  virtual ~TTF();
106 
107  static void Init();
108  static void Cleanup();
109  static Int_t GetAscent();
110  static const FT_BBox &GetBox();
111  static TTGlyph *GetGlyphs();
112  static Bool_t GetHinting();
113  static Bool_t GetKerning();
114  static Int_t GetNumGlyphs();
115  static FT_Matrix *GetRotMatrix();
116  static Bool_t GetSmoothing();
117  static Int_t GetWidth();
118  static void SetHinting(Bool_t state);
119  static void SetKerning(Bool_t state);
120  static void SetSmoothing(Bool_t state);
121  static void GetTextExtent(UInt_t &w, UInt_t &h, char *text);
122  static void GetTextExtent(UInt_t &w, UInt_t &h, wchar_t *text);
123  static void GetTextAdvance(UInt_t &a, char *text);
124  static void SetTextFont(Font_t fontnumber);
125  static Int_t SetTextFont(const char *fontname, Int_t italic=0);
126  static void SetTextSize(Float_t textsize);
127  static Bool_t IsInitialized();
128  static void Version(Int_t &major, Int_t &minor, Int_t &patch);
129 
130  ClassDef(TTF,0) //Interface to TTF font handling
131 };
132 
133 #endif
FT_Vector fPos
position of glyph origin
Definition: TTF.h:70
static FT_Matrix * fgRotMatrix
rotation matrix
Definition: TTF.h:91
float Float_t
Definition: RtypesCore.h:53
static Int_t fgFontCount
number of fonts loaded
Definition: TTF.h:82
FT_Glyph fImage
glyph image
Definition: TTF.h:71
TH1 * h
Definition: legend2.C:5
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Interface to the freetype 2 library.
Definition: TTF.h:55
TArc * a
Definition: textangle.C:12
const char * Version
This class is the basic interface to the Win32 graphics system.
Definition: TGWin32.h:71
UInt_t fIndex
glyph index in face
Definition: TTF.h:69
short Font_t
Definition: RtypesCore.h:75
Interface to low level X11 (Xlib).
Definition: TGX11TTF.h:33
static Int_t fgAscent
string ascent, used to compute Y alignment
Definition: TTF.h:77
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
TTF()
Definition: TTF.h:104
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:119
static FT_BBox fgCBox
string control box
Definition: TTF.h:78
static Int_t fgTBlankW
trailing blanks width
Definition: TTF.h:93
static Int_t fgCurFontIdx
current font index
Definition: TTF.h:80
static FT_Library fgLibrary
FreeType font library.
Definition: TTF.h:89
th1 SetTextSize(0.12)
pt SetTextFont(42)
static Bool_t fgKerning
use kerning (true by default)
Definition: TTF.h:88
static Bool_t fgInit
true if the Init has been called
Definition: TTF.h:87
unsigned int UInt_t
Definition: RtypesCore.h:42
TTF helper class containing glyphs description.
Definition: TTF.h:67
short Short_t
Definition: RtypesCore.h:35
static Bool_t fgHinting
use hinting (true by default)
Definition: TTF.h:86
static Int_t fgSymbItaFontIdx
Symbol italic font index.
Definition: TTF.h:81
TText * text
Double_t y[n]
Definition: legend1.C:17
static Bool_t fgSmoothing
use anti-aliasing (true when >8 planes, false otherwise)
Definition: TTF.h:92
static Int_t fgNumGlyphs
number of glyphs in the string
Definition: TTF.h:90
static Int_t fgWidth
string width, used to compute X alignment
Definition: TTF.h:94