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#if !defined(ROOT_TTFsupport) && !defined(G__DICTIONARY)
18#warning "This header is deprecated and will be removed after ROOT 7. Use instead TTFhandle public interface."
19#endif
20
21
22#include "Rtypes.h"
23
24
25/// @cond DOXYGEN_IGNORE
26// Forward declare for the headers:
27// # include <ft2build.h>
28// # include FT_FREETYPE_H
29// # include FT_GLYPH_H
30extern "C" {
31 struct FT_LibraryRec_;
32 struct FT_FaceRec_;
33 struct FT_CharMapRec_;
34 struct FT_GlyphRec_;
35 struct FT_Matrix_;
36 struct FT_Bitmap_;
37 struct FT_BitmapGlyphRec_;
38 typedef struct FT_LibraryRec_* FT_Library;
39 typedef struct FT_FaceRec_* FT_Face;
40 typedef struct FT_CharMapRec_* FT_CharMap;
41 typedef struct FT_GlyphRec_* FT_Glyph;
42 typedef struct FT_Matrix_ FT_Matrix;
43 typedef struct FT_Bitmap_ FT_Bitmap; // Forward declared for TGX11TTF.h's benefit
44 typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph;
45 typedef signed long FT_Pos;
46 #ifndef FT_FREETYPE_H
47 struct FT_Vector_ { FT_Pos x, y; };
48 struct FT_BBox_ { FT_Pos xMin, yMin, xMax, yMax; };
49 #endif
50 typedef struct FT_Vector_ FT_Vector;
51 typedef struct FT_BBox_ FT_BBox;
52}
53/// @endcond
54
55
56#include "TTFhandle.h"
57
58
59
60class TTF {
61
62 friend class TTFhandle;
63
64public:
65
66 /** \class TTGlyph
67 TTF helper class containing glyphs description.
68 */
69
70 class TTGlyph {
71 public:
72 UInt_t fIndex{0}; ///< glyph index in face
73 FT_Vector fPos; ///< position of glyph origin
74 FT_Glyph fImage{nullptr}; ///< glyph image
75 TTGlyph(UInt_t indx = 0) : fIndex(indx) {}
77 };
78
79 TTF() {}
80 virtual ~TTF();
81
82 // old static methods which are fully replaced by TTFhandle
83 // remain here only for backward compatibility until ROOT7
84
85 // minimal static interface to initialize library and handle fonts
86 static void Init();
87 static void Cleanup();
88 static Bool_t IsInitialized();
89
90 static Short_t CharToUnicode(UInt_t code);
91 static void LayoutGlyphs();
92 static void PrepareString(const char *string);
93 static void PrepareString(const wchar_t *string);
94 static void SetRotationMatrix(Float_t angle);
95
97 static Int_t GetAscent();
98 static const FT_BBox &GetBox();
99 static TTGlyph *GetGlyphs();
100 static Bool_t GetHinting();
101 static Bool_t GetKerning();
102 static Int_t GetNumGlyphs();
103 static FT_Matrix *GetRotMatrix();
104 static Bool_t GetSmoothing();
106 static Int_t GetWidth();
107 static void SetHinting(Bool_t state);
108 static void SetKerning(Bool_t state);
109 static void SetSmoothing(Bool_t state);
110 static void GetTextExtent(UInt_t &w, UInt_t &h, const char *text);
111 static void GetTextExtent(UInt_t &w, UInt_t &h, const wchar_t *text);
112 static void GetTextAdvance(UInt_t &a, const char *text);
113 static void SetTextFont(Font_t fontnumber);
114 static Int_t SetTextFont(const char *fontname, Int_t italic=0);
115 static void SetTextSize(Float_t textsize);
116
117 static void Version(Int_t &major, Int_t &minor, Int_t &patch);
118
119 // new temporary methods, can be removed at the end
120 static void CleanupGlyphs();
121
122 ClassDef(TTF,0) //Interface to TTF font handling
123};
124
125#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
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:70
FT_Vector fPos
position of glyph origin
Definition TTF.h:73
FT_Glyph fImage
glyph image
Definition TTF.h:74
TTGlyph(UInt_t indx=0)
Definition TTF.h:75
UInt_t fIndex
glyph index in face
Definition TTF.h:72
~TTGlyph()
Definition TTF.h:76
Interface to the freetype 2 library.
Definition TTF.h:60
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:79
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