ROOT logo
// @(#)root/graf:$Id$
// Author: Olivier Couet     01/10/02
// Author: Fons Rademakers   21/11/98

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TTF
#define ROOT_TTF


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TTF                                                                  //
//                                                                      //
// Interface to the Freetype 2 library.                                 //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif

#ifndef __CINT__
#  include <ft2build.h>
#  include FT_FREETYPE_H
#  include FT_GLYPH_H
#else
   typedef void* FT_Library;
   typedef void* FT_Face;
   typedef void* FT_CharMap;
   typedef void* FT_Glyph;
   typedef signed long FT_Pos;
   struct FT_Vector { FT_Pos x, y; };
   struct FT_BBox { FT_Pos xMin, yMin, xMax, yMax; };
   struct FT_Matrix;
   struct FT_Bitmap;
#endif


// Class (actually structure) containing glyphs description
class TTGlyph {
public:
   UInt_t     fIndex; // glyph index in face
   FT_Vector  fPos;   // position of glyph origin
   FT_Glyph   fImage; // glyph image
};


class TGX11TTF;
class TGWin32;
class TMathTextRenderer;


class TTF {

friend class TGX11TTF;
friend class TGWin32;
friend class TMathTextRenderer;

protected:
   enum { kTTMaxFonts = 32, kMaxGlyphs = 1024 };

   static Int_t       fgAscent;                // string ascent, used to compute Y alignment
   static FT_BBox     fgCBox;                  // string control box
   static FT_CharMap  fgCharMap[kTTMaxFonts];  // font character map
   static Int_t       fgCurFontIdx;            // current font index
   static Int_t       fgSymbItaFontIdx;        // Symbol italic font index
   static Int_t       fgFontCount;             // number of fonts loaded
   static char       *fgFontName[kTTMaxFonts]; // font name
   static FT_Face     fgFace[kTTMaxFonts];     // font face
   static TTGlyph     fgGlyphs[kMaxGlyphs];    // glyphs
   static Bool_t      fgHinting;               // use hinting (true by default)
   static Bool_t      fgInit;                  // true if the Init has been called
   static Bool_t      fgKerning;               // use kerning (true by default)
   static FT_Library  fgLibrary;               // FreeType font library
   static Int_t       fgNumGlyphs;             // number of glyphs in the string
   static FT_Matrix  *fgRotMatrix;             // rotation matrix
   static Bool_t      fgSmoothing;             // use anti-aliasing (true when >8 planes, false otherwise)
   static Int_t       fgTBlankW;               // trailing blanks width
   static Int_t       fgWidth;                 // string width, used to compute X alignment

public:
   static Short_t CharToUnicode(UInt_t code);
   static void    LayoutGlyphs();
   static void    PrepareString(const char *string);
   static void    PrepareString(const wchar_t *string);
   static void    SetRotationMatrix(Float_t angle);

public:
   TTF() { }
   virtual ~TTF();

   static void           Init();
   static void           Cleanup();
   static Int_t          GetAscent();
   static const FT_BBox &GetBox();
   static TTGlyph       *GetGlyphs();
   static Bool_t         GetHinting();
   static Bool_t         GetKerning();
   static Int_t          GetNumGlyphs();
   static FT_Matrix     *GetRotMatrix();
   static Bool_t         GetSmoothing();
   static Int_t          GetWidth();
   static void           SetHinting(Bool_t state);
   static void           SetKerning(Bool_t state);
   static void           SetSmoothing(Bool_t state);
   static void           GetTextExtent(UInt_t &w, UInt_t &h, char *text);
   static void           GetTextExtent(UInt_t &w, UInt_t &h, wchar_t *text);
   static void           GetTextAdvance(UInt_t &a, char *text);
   static void           SetTextFont(Font_t fontnumber);
   static Int_t          SetTextFont(const char *fontname, Int_t italic=0);
   static void           SetTextSize(Float_t textsize);
   static Bool_t         IsInitialized();
   static void           Version(Int_t &major, Int_t &minor, Int_t &patch);

   ClassDef(TTF,0)  //Interface to TTF font handling
};

#endif
 TTF.h:1
 TTF.h:2
 TTF.h:3
 TTF.h:4
 TTF.h:5
 TTF.h:6
 TTF.h:7
 TTF.h:8
 TTF.h:9
 TTF.h:10
 TTF.h:11
 TTF.h:12
 TTF.h:13
 TTF.h:14
 TTF.h:15
 TTF.h:16
 TTF.h:17
 TTF.h:18
 TTF.h:19
 TTF.h:20
 TTF.h:21
 TTF.h:22
 TTF.h:23
 TTF.h:24
 TTF.h:25
 TTF.h:26
 TTF.h:27
 TTF.h:28
 TTF.h:29
 TTF.h:30
 TTF.h:31
 TTF.h:32
 TTF.h:33
 TTF.h:34
 TTF.h:35
 TTF.h:36
 TTF.h:37
 TTF.h:38
 TTF.h:39
 TTF.h:40
 TTF.h:41
 TTF.h:42
 TTF.h:43
 TTF.h:44
 TTF.h:45
 TTF.h:46
 TTF.h:47
 TTF.h:48
 TTF.h:49
 TTF.h:50
 TTF.h:51
 TTF.h:52
 TTF.h:53
 TTF.h:54
 TTF.h:55
 TTF.h:56
 TTF.h:57
 TTF.h:58
 TTF.h:59
 TTF.h:60
 TTF.h:61
 TTF.h:62
 TTF.h:63
 TTF.h:64
 TTF.h:65
 TTF.h:66
 TTF.h:67
 TTF.h:68
 TTF.h:69
 TTF.h:70
 TTF.h:71
 TTF.h:72
 TTF.h:73
 TTF.h:74
 TTF.h:75
 TTF.h:76
 TTF.h:77
 TTF.h:78
 TTF.h:79
 TTF.h:80
 TTF.h:81
 TTF.h:82
 TTF.h:83
 TTF.h:84
 TTF.h:85
 TTF.h:86
 TTF.h:87
 TTF.h:88
 TTF.h:89
 TTF.h:90
 TTF.h:91
 TTF.h:92
 TTF.h:93
 TTF.h:94
 TTF.h:95
 TTF.h:96
 TTF.h:97
 TTF.h:98
 TTF.h:99
 TTF.h:100
 TTF.h:101
 TTF.h:102
 TTF.h:103
 TTF.h:104
 TTF.h:105
 TTF.h:106
 TTF.h:107
 TTF.h:108
 TTF.h:109
 TTF.h:110
 TTF.h:111
 TTF.h:112
 TTF.h:113
 TTF.h:114
 TTF.h:115
 TTF.h:116
 TTF.h:117
 TTF.h:118
 TTF.h:119
 TTF.h:120
 TTF.h:121
 TTF.h:122
 TTF.h:123
 TTF.h:124
 TTF.h:125