Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TTF.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/graf:$Id$
0002 // Author: Olivier Couet     01/10/02
0003 // Author: Fons Rademakers   21/11/98
0004 
0005 /*************************************************************************
0006  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0007  * All rights reserved.                                                  *
0008  *                                                                       *
0009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0011  *************************************************************************/
0012 
0013 #ifndef ROOT_TTF
0014 #define ROOT_TTF
0015 
0016 
0017 #include "Rtypes.h"
0018 
0019 /// @cond DOXYGEN_IGNORE
0020 // Forward declare for the headers:
0021 // #  include <ft2build.h>
0022 // #  include FT_FREETYPE_H
0023 // #  include FT_GLYPH_H
0024 extern "C" {
0025    struct FT_LibraryRec_;
0026    struct FT_FaceRec_;
0027    struct FT_CharMapRec_;
0028    struct FT_GlyphRec_;
0029    struct FT_Matrix_;
0030    struct FT_Bitmap_;
0031    typedef struct FT_LibraryRec_* FT_Library;
0032    typedef struct FT_FaceRec_* FT_Face;
0033    typedef struct FT_CharMapRec_* FT_CharMap;
0034    typedef struct FT_GlyphRec_* FT_Glyph;
0035    typedef struct FT_Matrix_ FT_Matrix;
0036    typedef struct FT_Bitmap_ FT_Bitmap; // Forward declared for TGX11TTF.h's benefit
0037    typedef signed long FT_Pos;
0038    #ifndef FT_FREETYPE_H
0039    struct FT_Vector_ { FT_Pos x, y; };
0040    struct FT_BBox_ { FT_Pos xMin, yMin, xMax, yMax; };
0041    #endif
0042    typedef struct FT_Vector_ FT_Vector;
0043    typedef struct FT_BBox_ FT_BBox;
0044 }
0045 /// @endcond
0046 
0047 
0048 class TGX11TTF;
0049 class TGWin32;
0050 class TMathTextRenderer;
0051 
0052 
0053 class TTF {
0054 
0055 friend class TGX11TTF;
0056 friend class TGWin32;
0057 friend class TMathTextRenderer;
0058 
0059 public:
0060 
0061 /** \class TTGlyph
0062 TTF helper class containing glyphs description.
0063 */
0064 
0065    class TTGlyph {
0066    public:
0067       UInt_t     fIndex{0};     ///< glyph index in face
0068       FT_Vector  fPos;          ///< position of glyph origin
0069       FT_Glyph   fImage{nullptr}; ///< glyph image
0070    };
0071 
0072 protected:
0073    enum { kTTMaxFonts = 32, kMaxGlyphs = 1024 };
0074 
0075    static Int_t          fgAscent;                ///< string ascent, used to compute Y alignment
0076    static FT_BBox        fgCBox;                  ///< string control box
0077    static FT_CharMap     fgCharMap[kTTMaxFonts];  ///< font character map
0078    static Int_t          fgCurFontIdx;            ///< current font index
0079    static Int_t          fgSymbItaFontIdx;        ///< Symbol italic font index
0080    static Int_t          fgFontCount;             ///< number of fonts loaded
0081    static char          *fgFontName[kTTMaxFonts]; ///< font name
0082    static FT_Face        fgFace[kTTMaxFonts];     ///< font face
0083    static TTF::TTGlyph   fgGlyphs[kMaxGlyphs];    ///< glyphs
0084    static Bool_t         fgHinting;               ///< use hinting (true by default)
0085    static Bool_t         fgInit;                  ///< true if the Init has been called
0086    static Bool_t         fgKerning;               ///< use kerning (true by default)
0087    static FT_Library     fgLibrary;               ///< FreeType font library
0088    static Int_t          fgNumGlyphs;             ///< number of glyphs in the string
0089    static FT_Matrix     *fgRotMatrix;             ///< rotation matrix
0090    static Bool_t         fgSmoothing;             ///< use anti-aliasing (true when >8 planes, false otherwise)
0091    static Int_t          fgTBlankW;               ///< trailing blanks width
0092    static Int_t          fgWidth;                 ///< string width, used to compute X alignment
0093 
0094 public:
0095    static Short_t CharToUnicode(UInt_t code);
0096    static void    LayoutGlyphs();
0097    static void    PrepareString(const char *string);
0098    static void    PrepareString(const wchar_t *string);
0099    static void    SetRotationMatrix(Float_t angle);
0100 
0101 public:
0102    TTF() { }
0103    virtual ~TTF();
0104 
0105    static void           Init();
0106    static void           Cleanup();
0107    static Int_t          GetAscent();
0108    static const FT_BBox &GetBox();
0109    static TTGlyph       *GetGlyphs();
0110    static Bool_t         GetHinting();
0111    static Bool_t         GetKerning();
0112    static Int_t          GetNumGlyphs();
0113    static FT_Matrix     *GetRotMatrix();
0114    static Bool_t         GetSmoothing();
0115    static Int_t          GetWidth();
0116    static void           SetHinting(Bool_t state);
0117    static void           SetKerning(Bool_t state);
0118    static void           SetSmoothing(Bool_t state);
0119    static void           GetTextExtent(UInt_t &w, UInt_t &h, char *text);
0120    static void           GetTextExtent(UInt_t &w, UInt_t &h, wchar_t *text);
0121    static void           GetTextAdvance(UInt_t &a, char *text);
0122    static void           SetTextFont(Font_t fontnumber);
0123    static Int_t          SetTextFont(const char *fontname, Int_t italic=0);
0124    static void           SetTextSize(Float_t textsize);
0125    static Bool_t         IsInitialized();
0126    static void           Version(Int_t &major, Int_t &minor, Int_t &patch);
0127 
0128    ClassDef(TTF,0)  //Interface to TTF font handling
0129 };
0130 
0131 #endif