Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TTF.h
Go to the documentation of this file.
1// @(#)root/graf:$Id$
2// Author: Olivier Couet 01/10/2002
3// Author: Fons Rademakers 21/11/1998
4// Author: Sergey Linev 29/04/2026
5
6/*************************************************************************
7 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13
14#ifndef ROOT_TTF
15#define ROOT_TTF
16
17#include "Rtypes.h"
18
19
20/// @cond DOXYGEN_IGNORE
21// Forward declare for the headers:
22// # include <ft2build.h>
23// # include FT_FREETYPE_H
24// # include FT_GLYPH_H
25extern "C" {
26 struct FT_LibraryRec_;
27 struct FT_FaceRec_;
28 struct FT_CharMapRec_;
29 struct FT_GlyphRec_;
30 struct FT_Matrix_;
31 struct FT_Bitmap_;
32 struct FT_BitmapGlyphRec_;
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 struct FT_BitmapGlyphRec_* FT_BitmapGlyph;
40 typedef signed long FT_Pos;
41 #ifndef FT_FREETYPE_H
42 struct FT_Vector_ { FT_Pos x, y; };
43 struct FT_BBox_ { FT_Pos xMin, yMin, xMax, yMax; };
44 #endif
45 typedef struct FT_Vector_ FT_Vector;
46 typedef struct FT_BBox_ FT_BBox;
47}
48/// @endcond
49
50
51#include "TTFhandle.h"
52
53
54
55class TTF {
56
57 friend class TTFhandle;
58
59public:
60
61 /** \class TTGlyph
62 TTF helper class containing glyphs description.
63 */
64
65 class TTGlyph {
66 public:
67 UInt_t fIndex{0}; ///< glyph index in face
68 FT_Vector fPos; ///< position of glyph origin
69 FT_Glyph fImage{nullptr}; ///< glyph image
72 };
73
74 TTF() {}
75 virtual ~TTF();
76
77 // old static methods which are fully replaced by TTFhandle
78 // remain here only for backward compatibility until ROOT7
79
80 // minimal static interface to initialize library and handle fonts
81 static void Init();
82 static void Cleanup();
83 static Bool_t IsInitialized();
84
85 static Short_t CharToUnicode(UInt_t code);
86 static void LayoutGlyphs();
87 static void PrepareString(const char *string);
88 static void PrepareString(const wchar_t *string);
89 static void SetRotationMatrix(Float_t angle);
90
92 static Int_t GetAscent();
93 static const FT_BBox &GetBox();
94 static TTGlyph *GetGlyphs();
95 static Bool_t GetHinting();
96 static Bool_t GetKerning();
97 static Int_t GetNumGlyphs();
98 static FT_Matrix *GetRotMatrix();
99 static Bool_t GetSmoothing();
101 static Int_t GetWidth();
102 static void SetHinting(Bool_t state);
103 static void SetKerning(Bool_t state);
104 static void SetSmoothing(Bool_t state);
105 static void GetTextExtent(UInt_t &w, UInt_t &h, const char *text);
106 static void GetTextExtent(UInt_t &w, UInt_t &h, const wchar_t *text);
107 static void GetTextAdvance(UInt_t &a, const char *text);
108 static void SetTextFont(Font_t fontnumber);
109 static Int_t SetTextFont(const char *fontname, Int_t italic=0);
110 static void SetTextSize(Float_t textsize);
111
112 static void Version(Int_t &major, Int_t &minor, Int_t &patch);
113
114 // new temporary methods, can be removed at the end
115 static void CleanupGlyphs();
116
117 ClassDef(TTF,0) //Interface to TTF font handling
118};
119
120#endif
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
short Font_t
Font number (short)
Definition RtypesCore.h:96
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:54
#define ClassDef(name, id)
Definition Rtypes.h:343
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t SetTextSize
Option_t Option_t fontnumber
Option_t Option_t SetTextFont
Option_t Option_t textsize
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char fontname
Option_t Option_t TPoint TPoint const char text
TTF helper class containing glyphs description.
Definition TTF.h:65
FT_Vector fPos
position of glyph origin
Definition TTF.h:68
FT_Glyph fImage
glyph image
Definition TTF.h:69
TTGlyph(UInt_t indx=0)
Definition TTF.h:70
UInt_t fIndex
glyph index in face
Definition TTF.h:67
~TTGlyph()
Definition TTF.h:71
Interface to the freetype 2 library.
Definition TTF.h:55
static void SetKerning(Bool_t state)
Set kerning flag.
Definition TTF.cxx:180
static Bool_t IsInitialized()
Definition TTF.cxx:76
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition TTF.cxx:226
static void GetTextExtent(UInt_t &w, UInt_t &h, const char *text)
Get width (w) and height (h) when text is horizontal.
Definition TTF.cxx:272
static Bool_t GetKerning()
Definition TTF.cxx:62
static void Version(Int_t &major, Int_t &minor, Int_t &patch)
Definition TTF.cxx:298
static Int_t GetTrailingBlanksWidth()
Definition TTF.cxx:119
static void SetHinting(Bool_t state)
Set hinting flag.
Definition TTF.cxx:171
static void Init()
Init TTF environment.
Definition TTF.cxx:45
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition TTF.cxx:244
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition TTF.cxx:189
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:162
static void CleanupGlyphs()
Remove temporary data created by LayoutGlyphs.
Definition TTF.cxx:263
TTF()
Definition TTF.h:74
static Short_t CharToUnicode(UInt_t code)
Map char to unicode. Returns 0 in case no mapping exists.
Definition TTF.cxx:153
static Int_t GetAscent()
Definition TTF.cxx:90
static TTGlyph * GetGlyphs()
Definition TTF.cxx:140
static Int_t GetNumGlyphs()
Definition TTF.cxx:97
static void ComputeTrailingBlanksWidth(Int_t n)
Compute the trailing blanks width.
Definition TTF.cxx:254
virtual ~TTF()
Cleanup TTF environment.
Definition TTF.cxx:40
static Int_t GetWidth()
Definition TTF.cxx:83
static const FT_BBox & GetBox()
Definition TTF.cxx:126
static void GetTextAdvance(UInt_t &a, const char *text)
Get advance (a) when text is horizontal.
Definition TTF.cxx:281
static void Cleanup()
static Bool_t GetHinting()
Definition TTF.cxx:55
static Bool_t GetSmoothing()
Definition TTF.cxx:69
static FT_Matrix * GetRotMatrix()
Definition TTF.cxx:104
Dynamic handle to work with freetype 2 library.
Definition TTFhandle.h:21
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16