TTF.h

Go to the documentation of this file.
00001 // @(#)root/graf:$Id: TTF.h 32449 2010-03-04 10:30:03Z couet $
00002 // Author: Olivier Couet     01/10/02
00003 // Author: Fons Rademakers   21/11/98
00004 
00005 /*************************************************************************
00006  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00007  * All rights reserved.                                                  *
00008  *                                                                       *
00009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00011  *************************************************************************/
00012 
00013 #ifndef ROOT_TTF
00014 #define ROOT_TTF
00015 
00016 
00017 //////////////////////////////////////////////////////////////////////////
00018 //                                                                      //
00019 // TTF                                                                  //
00020 //                                                                      //
00021 // Interface to the Freetype 2 library.                                 //
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 // Class (actually structure) containing glyphs description
00047 class TTGlyph {
00048 public:
00049    UInt_t     fIndex; // glyph index in face
00050    FT_Vector  fPos;   // position of glyph origin
00051    FT_Glyph   fImage; // glyph image
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;                // string ascent, used to compute Y alignment
00068    static FT_BBox     fgCBox;                  // string control box
00069    static FT_CharMap  fgCharMap[kTTMaxFonts];  // font character map
00070    static Int_t       fgCurFontIdx;            // current font index
00071    static Int_t       fgSymbItaFontIdx;        // Symbol italic font index
00072    static Int_t       fgFontCount;             // number of fonts loaded
00073    static char       *fgFontName[kTTMaxFonts]; // font name
00074    static FT_Face     fgFace[kTTMaxFonts];     // font face
00075    static TTGlyph     fgGlyphs[kMaxGlyphs];    // glyphs
00076    static Bool_t      fgHinting;               // use hinting (true by default)
00077    static Bool_t      fgInit;                  // true if the Init has been called
00078    static Bool_t      fgKerning;               // use kerning (true by default)
00079    static FT_Library  fgLibrary;               // FreeType font library
00080    static Int_t       fgNumGlyphs;             // number of glyphs in the string
00081    static FT_Matrix  *fgRotMatrix;             // rotation matrix
00082    static Bool_t      fgSmoothing;             // use anti-aliasing (true when >8 planes, false otherwise)
00083    static Int_t       fgTBlankW;               // trailing blanks width
00084    static Int_t       fgWidth;                 // string width, used to compute X alignment
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)  //Interface to TTF font handling
00119 };
00120 
00121 #endif

Generated on Tue Jul 5 14:14:11 2011 for ROOT_528-00b_version by  doxygen 1.5.1