Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TTF.cxx
Go to the documentation of this file.
1// @(#)root/graf:$Id$
2// Author: Olivier Couet 01/10/02
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TTF
13\ingroup BasicGraphics
14
15Interface to the freetype 2 library.
16*/
17
18# include <ft2build.h>
19# include FT_FREETYPE_H
20# include FT_GLYPH_H
21#include "TROOT.h"
22#include "TTF.h"
23#include "TSystem.h"
24#include "TEnv.h"
25#include "TMath.h"
26#include "TError.h"
27
28// to scale fonts to the same size as the old TT version
29const Float_t kScale = 0.93376068;
30
31TTF gCleanupTTF; // Allows to call "Cleanup" at the end of the session
32
44char *TTF::fgFontName[kTTMaxFonts];
45FT_Matrix *TTF::fgRotMatrix = nullptr;
46FT_Library TTF::fgLibrary;
47FT_BBox TTF::fgCBox;
48FT_Face TTF::fgFace[kTTMaxFonts];
49FT_CharMap TTF::fgCharMap[kTTMaxFonts];
50TTF::TTGlyph TTF::fgGlyphs[kMaxGlyphs];
51
53
54////////////////////////////////////////////////////////////////////////////////
55/// Cleanup TTF environment.
56
58{
59 Cleanup();
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// Initialise the TrueType fonts interface.
64
66{
67 fgInit = kTRUE;
68
69 // initialize FTF library
70 if (FT_Init_FreeType(&fgLibrary)) {
71 Error("TTF::Init", "error initializing FreeType");
72 return;
73 }
74
75 // load default font (arialbd)
76 SetTextFont(62);
77}
78
79////////////////////////////////////////////////////////////////////////////////
80/// Cleanup. Is called by the gCleanupTTF destructor.
81
83{
84 if (!fgInit) return;
85
86 for (int i = 0; i < fgFontCount; i++) {
87 delete [] fgFontName[i];
88 FT_Done_Face(fgFace[i]);
89 }
90 if (fgRotMatrix) delete fgRotMatrix;
91 FT_Done_FreeType(fgLibrary);
92
93 fgInit = kFALSE;
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// Map char to unicode. Returns 0 in case no mapping exists.
98
100{
101 if (!fgCharMap[fgCurFontIdx]) {
102 UShort_t i, platform, encoding;
103 FT_CharMap charmap;
104
105 if (!fgFace[fgCurFontIdx]) return 0;
106 Int_t n = fgFace[fgCurFontIdx]->num_charmaps;
107 for (i = 0; i < n; i++) {
108 if (!fgFace[fgCurFontIdx]) continue;
109 charmap = fgFace[fgCurFontIdx]->charmaps[i];
110 platform = charmap->platform_id;
111 encoding = charmap->encoding_id;
112 if ((platform == 3 && encoding == 1) ||
113 (platform == 0 && encoding == 0) ||
114 (platform == 1 && encoding == 0 &&
115 !strcmp(fgFontName[fgCurFontIdx], "wingding.ttf")) ||
116 (platform == 1 && encoding == 0 &&
117 !strcmp(fgFontName[fgCurFontIdx], "symbol.ttf")))
118 {
119 fgCharMap[fgCurFontIdx] = charmap;
120 if (FT_Set_Charmap(fgFace[fgCurFontIdx], fgCharMap[fgCurFontIdx]))
121 Error("TTF::CharToUnicode", "error in FT_Set_CharMap");
122 return FT_Get_Char_Index(fgFace[fgCurFontIdx], (FT_ULong)code);
123 }
124 }
125 }
126 return FT_Get_Char_Index(fgFace[fgCurFontIdx], (FT_ULong)code);
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// Get width (w) and height (h) when text is horizontal.
131
133{
134 if (!fgInit) Init();
135
138 LayoutGlyphs();
139 Int_t Xoff = 0; if (fgCBox.xMin < 0) Xoff = -fgCBox.xMin;
140 Int_t Yoff = 0; if (fgCBox.yMin < 0) Yoff = -fgCBox.yMin;
141 w = fgCBox.xMax + Xoff + fgTBlankW;
142 h = fgCBox.yMax + Yoff;
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Get advance (a) when text is horizontal.
147
149{
150 if (!fgInit) Init();
151
154 LayoutGlyphs();
155 a = GetWidth()>>6;
156}
157
158////////////////////////////////////////////////////////////////////////////////
159/// Get width (w) and height (h) when text is horizontal.
160
162{
163 if (!fgInit) Init();
164
167 LayoutGlyphs();
168 Int_t Xoff = 0; if (fgCBox.xMin < 0) Xoff = -fgCBox.xMin;
169 Int_t Yoff = 0; if (fgCBox.yMin < 0) Yoff = -fgCBox.yMin;
170 w = fgCBox.xMax + Xoff + fgTBlankW;
171 h = fgCBox.yMax + Yoff;
172}
173
174////////////////////////////////////////////////////////////////////////////////
175/// Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
176/// Perform the Glyphs transformation.
177/// Compute the string control box.
178/// If required take the "kerning" into account.
179/// SetRotation and PrepareString should have been called before.
180
182{
183 TTGlyph* glyph = fgGlyphs;
184 FT_Vector origin;
185 FT_UInt load_flags;
186 FT_UInt prev_index = 0;
187
188 fgAscent = 0;
189 fgWidth = 0;
190
191 load_flags = FT_LOAD_DEFAULT;
192 if (!fgHinting) load_flags |= FT_LOAD_NO_HINTING;
193
194 fgCBox.xMin = fgCBox.yMin = 32000;
195 fgCBox.xMax = fgCBox.yMax = -32000;
196
197 for (int n = 0; n < fgNumGlyphs; n++, glyph++) {
198
199 // compute glyph origin
200 if (fgKerning) {
201 if (prev_index) {
202 FT_Vector kern;
203 FT_Get_Kerning(fgFace[fgCurFontIdx], prev_index, glyph->fIndex,
204 fgHinting ? ft_kerning_default : ft_kerning_unfitted,
205 &kern);
206 fgWidth += kern.x;
207 }
208 prev_index = glyph->fIndex;
209 }
210
211 origin.x = fgWidth;
212 origin.y = 0;
213
214 // clear existing image if there is one
215 if (glyph->fImage) {
216 FT_Done_Glyph(glyph->fImage);
217 glyph->fImage = nullptr;
218 }
219
220 // load the glyph image (in its native format)
221 if (FT_Load_Glyph(fgFace[fgCurFontIdx], glyph->fIndex, load_flags))
222 continue;
223
224 // extract the glyph image
225 if (FT_Get_Glyph (fgFace[fgCurFontIdx]->glyph, &glyph->fImage))
226 continue;
227
228 glyph->fPos = origin;
229 fgWidth += fgFace[fgCurFontIdx]->glyph->advance.x;
230 fgAscent = TMath::Max((Int_t)(fgFace[fgCurFontIdx]->glyph->metrics.horiBearingY), fgAscent);
231
232 // transform the glyphs
233 FT_Vector_Transform(&glyph->fPos, fgRotMatrix);
234 if (FT_Glyph_Transform(glyph->fImage, fgRotMatrix, &glyph->fPos))
235 continue;
236
237 // compute the string control box
238 FT_BBox bbox;
239 FT_Glyph_Get_CBox(glyph->fImage, ft_glyph_bbox_pixels, &bbox);
240 if (bbox.xMin < fgCBox.xMin) fgCBox.xMin = bbox.xMin;
241 if (bbox.yMin < fgCBox.yMin) fgCBox.yMin = bbox.yMin;
242 if (bbox.xMax > fgCBox.xMax) fgCBox.xMax = bbox.xMax;
243 if (bbox.yMax > fgCBox.yMax) fgCBox.yMax = bbox.yMax;
244 }
245}
246
247////////////////////////////////////////////////////////////////////////////////
248/// Put the characters in "string" in the "glyphs" array.
249
250void TTF::PrepareString(const char *string)
251{
252 const unsigned char *p = (const unsigned char*) string;
253 TTGlyph *glyph = fgGlyphs;
254 UInt_t index; // Unicode value
255 Int_t NbTBlank = 0; // number of trailing blanks
256
257 fgTBlankW = 0;
258 fgNumGlyphs = 0;
259 while (*p) {
260 index = CharToUnicode((FT_ULong)*p);
261 if (index != 0) {
262 glyph->fIndex = index;
263 glyph++;
264 fgNumGlyphs++;
265 }
266 if (*p == ' ') {
267 NbTBlank++;
268 } else {
269 NbTBlank = 0;
270 }
271 if (fgNumGlyphs >= kMaxGlyphs) break;
272 p++;
273 }
274
275 // compute the trailing blanks width. It is use to compute the text
276 // width in GetTextExtent
277 if (NbTBlank) {
278 FT_UInt load_flags = FT_LOAD_DEFAULT;
279 if (!fgHinting) load_flags |= FT_LOAD_NO_HINTING;
280 if (FT_Load_Glyph(fgFace[fgCurFontIdx], 3, load_flags)) return;
281 fgTBlankW = (Int_t)((fgFace[fgCurFontIdx]->glyph->advance.x)>>6)*NbTBlank;
282 }
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Put the characters in "string" in the "glyphs" array.
287
288void TTF::PrepareString(const wchar_t *string)
289{
290 const wchar_t *p = string;
291 TTGlyph *glyph = fgGlyphs;
292 UInt_t index; // Unicode value
293 Int_t NbTBlank = 0; // number of trailing blanks
294
295 fgTBlankW = 0;
296 fgNumGlyphs = 0;
297 while (*p) {
298 index = FT_Get_Char_Index(fgFace[fgCurFontIdx], (FT_ULong)*p);
299 if (index != 0) {
300 glyph->fIndex = index;
301 glyph++;
302 fgNumGlyphs++;
303 }
304 if (*p == ' ') {
305 NbTBlank++;
306 } else {
307 NbTBlank = 0;
308 }
309 if (fgNumGlyphs >= kMaxGlyphs) break;
310 p++;
311 }
312
313 // compute the trailing blanks width. It is use to compute the text
314 // width in GetTextExtent
315 if (NbTBlank) {
316 FT_UInt load_flags = FT_LOAD_DEFAULT;
317 if (!fgHinting) load_flags |= FT_LOAD_NO_HINTING;
318 if (FT_Load_Glyph(fgFace[fgCurFontIdx], 3, load_flags)) return;
319 fgTBlankW = (Int_t)((fgFace[fgCurFontIdx]->glyph->advance.x)>>6)*NbTBlank;
320 }
321}
322
323////////////////////////////////////////////////////////////////////////////////
324/// Set hinting flag.
325
327{
328 fgHinting = state;
329}
330
331////////////////////////////////////////////////////////////////////////////////
332/// Set kerning flag.
333
335{
336 fgKerning = state;
337}
338
339////////////////////////////////////////////////////////////////////////////////
340/// Set the rotation matrix used to rotate the font outlines.
341
343{
344 Float_t rangle = Float_t(angle * TMath::Pi() / 180.); // Angle in radian
345#if defined(FREETYPE_PATCH) && \
346 (FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 1) && (FREETYPE_PATCH == 2)
347 Float_t sin = TMath::Sin(rangle);
348 Float_t cos = TMath::Cos(rangle);
349#else
350 Float_t sin = TMath::Sin(-rangle);
351 Float_t cos = TMath::Cos(-rangle);
352#endif
353
354 if (!fgRotMatrix) fgRotMatrix = new FT_Matrix;
355
356 fgRotMatrix->xx = (FT_Fixed) (cos * (1<<16));
357 fgRotMatrix->xy = (FT_Fixed) (sin * (1<<16));
358 fgRotMatrix->yx = -fgRotMatrix->xy;
359 fgRotMatrix->yy = fgRotMatrix->xx;
360}
361
362////////////////////////////////////////////////////////////////////////////////
363/// Set smoothing (anti-aliasing) flag.
364
366{
367 fgSmoothing = state;
368}
369
370////////////////////////////////////////////////////////////////////////////////
371/// Set text font to specified name.
372/// - font : font name
373/// - italic : the fonts should be slanted. Used for symbol font.
374///
375/// Set text font to specified name. This function returns 0 if
376/// the specified font is found, 1 if not.
377
379{
380 if (!fgInit) Init();
381
382 if (!fontname || !fontname[0]) {
383 Warning("TTF::SetTextFont",
384 "no font name specified, using default font %s", fgFontName[0]);
385 fgCurFontIdx = 0;
386 return 0;
387 }
388 const char *basename = gSystem->BaseName(fontname);
389
390 // check if font is in cache
391 int i;
392 for (i = 0; i < fgFontCount; i++) {
393 if (!strcmp(fgFontName[i], basename)) {
394 if (italic) {
395 if (i==fgSymbItaFontIdx) {
396 fgCurFontIdx = i;
397 return 0;
398 }
399 } else {
400 if (i!=fgSymbItaFontIdx) {
401 fgCurFontIdx = i;
402 return 0;
403 }
404 }
405 }
406 }
407
408 // enough space in cache to load font?
409 if (fgFontCount >= kTTMaxFonts) {
410 Error("TTF::SetTextFont", "too many fonts opened (increase kTTMaxFont = %d)",
412 Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
413 fgCurFontIdx = 0; // use font 0 (default font, set in ctor)
414 return 0;
415 }
416
417 // try to load font (font must be in Root.TTFontPath resource)
418 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
420 char *ttfont = gSystem->Which(ttpath, fontname, kReadPermission);
421
422 if (!ttfont) {
423 Error("TTF::SetTextFont", "font file %s not found in path", fontname);
424 if (fgFontCount) {
425 Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
426 fgCurFontIdx = 0; // use font 0 (default font, set in ctor)
427 return 0;
428 } else {
429 return 1;
430 }
431 }
432
433 FT_Face tface = (FT_Face) 0;
434
435 if (FT_New_Face(fgLibrary, ttfont, 0, &tface)) {
436 Error("TTF::SetTextFont", "error loading font %s", ttfont);
437 delete [] ttfont;
438 if (tface) FT_Done_Face(tface);
439 if (fgFontCount) {
440 Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
441 fgCurFontIdx = 0;
442 return 0;
443 } else {
444 return 1;
445 }
446 }
447
448 delete [] ttfont;
449
450 fgFontName[fgFontCount] = StrDup(basename);
452 fgFace[fgCurFontIdx] = tface;
453 fgCharMap[fgCurFontIdx] = (FT_CharMap) 0;
454 fgFontCount++;
455
456 if (italic) {
458 FT_Matrix slantMat;
459 slantMat.xx = (1 << 16);
460 slantMat.xy = ((1 << 16) >> 2);
461 slantMat.yx = 0;
462 slantMat.yy = (1 << 16);
463 FT_Set_Transform( fgFace[fgSymbItaFontIdx], &slantMat, NULL );
464 }
465
466 return 0;
467}
468
469////////////////////////////////////////////////////////////////////////////////
470/// Set specified font.
471/// List of the currently supported fonts (screen and PostScript)
472///
473/// | Font number | TTF Names | PostScript/PDF Names |
474/// |-------------|---------------------------|-------------------------------|
475/// | 1 | Free Serif Italic | Times-Italic |
476/// | 2 | Free Serif Bold | Times-Bold |
477/// | 3 | Free Serif Bold Italic | Times-BoldItalic |
478/// | 4 | Tex Gyre Regular | Helvetica |
479/// | 5 | Tex Gyre Italic | Helvetica-Oblique |
480/// | 6 | Tex Gyre Bold | Helvetica-Bold |
481/// | 7 | Tex Gyre Bold Italic | Helvetica-BoldOblique |
482/// | 8 | Free Mono | Courier |
483/// | 9 | Free Mono Oblique | Courier-Oblique |
484/// | 10 | Free Mono Bold | Courier-Bold |
485/// | 11 | Free Mono Bold Oblique | Courier-BoldOblique |
486/// | 12 | Symbol | Symbol |
487/// | 13 | Free Serif | Times-Roman |
488/// | 14 | Wingdings | ZapfDingbats |
489
491{
492 // Added by cholm for use of DFSG - fonts - based on Kevins fix.
493 // Table of Microsoft and (for non-MSFT operating systems) backup
494 // FreeFont TTF fonts.
495 static const char *fonttable[][2] = {
496 { "Root.TTFont.0", "FreeSansBold.otf" },
497 { "Root.TTFont.1", "FreeSerifItalic.otf" },
498 { "Root.TTFont.2", "FreeSerifBold.otf" },
499 { "Root.TTFont.3", "FreeSerifBoldItalic.otf" },
500 { "Root.TTFont.4", "texgyreheros-regular.otf" },
501 { "Root.TTFont.5", "texgyreheros-italic.otf" },
502 { "Root.TTFont.6", "texgyreheros-bold.otf" },
503 { "Root.TTFont.7", "texgyreheros-bolditalic.otf" },
504 { "Root.TTFont.8", "FreeMono.otf" },
505 { "Root.TTFont.9", "FreeMonoOblique.otf" },
506 { "Root.TTFont.10", "FreeMonoBold.otf" },
507 { "Root.TTFont.11", "FreeMonoBoldOblique.otf" },
508 { "Root.TTFont.12", "symbol.ttf" },
509 { "Root.TTFont.13", "FreeSerif.otf" },
510 { "Root.TTFont.14", "wingding.ttf" },
511 { "Root.TTFont.15", "symbol.ttf" },
512 { "Root.TTFont.STIXGen", "STIXGeneral.otf" },
513 { "Root.TTFont.STIXGenIt", "STIXGeneralItalic.otf" },
514 { "Root.TTFont.STIXGenBd", "STIXGeneralBol.otf" },
515 { "Root.TTFont.STIXGenBdIt", "STIXGeneralBolIta.otf" },
516 { "Root.TTFont.STIXSiz1Sym", "STIXSiz1Sym.otf" },
517 { "Root.TTFont.STIXSiz1SymBd", "STIXSiz1SymBol.otf" },
518 { "Root.TTFont.STIXSiz2Sym", "STIXSiz2Sym.otf" },
519 { "Root.TTFont.STIXSiz2SymBd", "STIXSiz2SymBol.otf" },
520 { "Root.TTFont.STIXSiz3Sym", "STIXSiz3Sym.otf" },
521 { "Root.TTFont.STIXSiz3SymBd", "STIXSiz3SymBol.otf" },
522 { "Root.TTFont.STIXSiz4Sym", "STIXSiz4Sym.otf" },
523 { "Root.TTFont.STIXSiz4SymBd", "STIXSiz4SymBol.otf" },
524 { "Root.TTFont.STIXSiz5Sym", "STIXSiz5Sym.otf" },
525 { "Root.TTFont.ME", "DroidSansFallback.ttf" },
526 { "Root.TTFont.CJKMing", "DroidSansFallback.ttf" },
527 { "Root.TTFont.CJKGothic", "DroidSansFallback.ttf" }
528 };
529
530 static int fontset = -1;
531 int thisset = fontset;
532
533 int fontid = fontnumber / 10;
534 if (fontid < 0 || fontid > 31) fontid = 0;
535
536 if (thisset == -1) {
537 // try to load font (font must be in Root.TTFontPath resource)
538 // to see which fontset we have available
539 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
541 char *ttfont = gSystem->Which(ttpath, gEnv->GetValue(fonttable[fontid][0], fonttable[fontid][1]), kReadPermission);
542 if (ttfont) {
543 delete [] ttfont;
544 thisset = 0;
545 } else {
546 // try backup free font
547 thisset = 1;
548 }
549 }
550 Int_t italic = 0;
551 if (fontid==15) italic = 1;
552 int ret = SetTextFont(gEnv->GetValue(fonttable[fontid][thisset], fonttable[fontid][1]), italic);
553 // Do not define font set is we're loading the symbol.ttf - it's
554 // the same in both cases.
555 if (ret == 0 && fontid != 12) fontset = thisset;
556}
557
558////////////////////////////////////////////////////////////////////////////////
559/// Set current text size.
560
562{
563 if (!fgInit) Init();
564 if (textsize < 0) return;
565
566 if (fgCurFontIdx < 0 || fgFontCount <= fgCurFontIdx) {
567 Error("TTF::SetTextSize", "current font index out of bounds");
568 fgCurFontIdx = 0;
569 return;
570 }
571
572 Int_t tsize = (Int_t)(textsize*kScale+0.5) << 6;
573 FT_Error err = FT_Set_Char_Size(fgFace[fgCurFontIdx], tsize, tsize, 72, 72);
574 if (err)
575 Error("TTF::SetTextSize", "error in FT_Set_Char_Size: 0x%x (input size %f, calc. size 0x%x)", err, textsize,
576 tsize);
577}
578
579////////////////////////////////////////////////////////////////////////////////
580
581void TTF::Version(Int_t &major, Int_t &minor, Int_t &patch)
582{
583 FT_Library_Version(fgLibrary, &major, &minor, &patch);
584}
585
586////////////////////////////////////////////////////////////////////////////////
587
589{
590 return fgHinting;
591}
592
593////////////////////////////////////////////////////////////////////////////////
594
596{
597 return fgKerning;
598}
599
600////////////////////////////////////////////////////////////////////////////////
601
603{
604 return fgSmoothing;
605}
606
607////////////////////////////////////////////////////////////////////////////////
608
610{
611 return fgInit;
612}
613
614////////////////////////////////////////////////////////////////////////////////
615
617{
618 return fgWidth;
619}
620
621////////////////////////////////////////////////////////////////////////////////
622
624{
625 return fgAscent;
626}
627
628////////////////////////////////////////////////////////////////////////////////
629
631{
632 return fgNumGlyphs;
633}
634
635////////////////////////////////////////////////////////////////////////////////
636
638{
639 return fgRotMatrix;
640}
641
642////////////////////////////////////////////////////////////////////////////////
643
644const FT_BBox &TTF::GetBox()
645{
646 return fgCBox;
647}
648
649////////////////////////////////////////////////////////////////////////////////
650
652{
653 return fgGlyphs;
654}
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
unsigned short UShort_t
Definition RtypesCore.h:40
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
short Font_t
Definition RtypesCore.h:88
short Short_t
Definition RtypesCore.h:39
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
const Float_t kScale
Definition TASImage.cxx:135
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
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
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2557
@ kReadPermission
Definition TSystem.h:45
R__EXTERN TSystem * gSystem
Definition TSystem.h:555
const Float_t kScale
Definition TTF.cxx:29
TTF gCleanupTTF
Definition TTF.cxx:31
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
Definition TROOT.cxx:3189
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:934
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1548
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
UInt_t fIndex
glyph index in face
Definition TTF.h:67
Interface to the freetype 2 library.
Definition TTF.h:53
static void SetKerning(Bool_t state)
Set kerning flag.
Definition TTF.cxx:334
static Bool_t fgHinting
use hinting (true by default)
Definition TTF.h:84
@ kMaxGlyphs
Definition TTF.h:73
@ kTTMaxFonts
Definition TTF.h:73
static Bool_t IsInitialized()
Definition TTF.cxx:609
static void GetTextAdvance(UInt_t &a, char *text)
Get advance (a) when text is horizontal.
Definition TTF.cxx:148
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition TTF.cxx:250
static TTF::TTGlyph fgGlyphs[kMaxGlyphs]
glyphs
Definition TTF.h:83
static Bool_t GetKerning()
Definition TTF.cxx:595
static Bool_t fgSmoothing
use anti-aliasing (true when >8 planes, false otherwise)
Definition TTF.h:90
static void Version(Int_t &major, Int_t &minor, Int_t &patch)
Definition TTF.cxx:581
static void SetHinting(Bool_t state)
Set hinting flag.
Definition TTF.cxx:326
static void Init()
Initialise the TrueType fonts interface.
Definition TTF.cxx:65
static FT_Face fgFace[kTTMaxFonts]
font face
Definition TTF.h:82
static FT_CharMap fgCharMap[kTTMaxFonts]
font character map
Definition TTF.h:77
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition TTF.cxx:181
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition TTF.cxx:365
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:342
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:490
static Short_t CharToUnicode(UInt_t code)
Map char to unicode. Returns 0 in case no mapping exists.
Definition TTF.cxx:99
static Int_t GetAscent()
Definition TTF.cxx:623
static void GetTextExtent(UInt_t &w, UInt_t &h, char *text)
Get width (w) and height (h) when text is horizontal.
Definition TTF.cxx:132
static TTGlyph * GetGlyphs()
Definition TTF.cxx:651
static Int_t GetNumGlyphs()
Definition TTF.cxx:630
static Int_t fgAscent
string ascent, used to compute Y alignment
Definition TTF.h:75
static Int_t fgWidth
string width, used to compute X alignment
Definition TTF.h:92
static Bool_t fgInit
true if the Init has been called
Definition TTF.h:85
static Int_t fgCurFontIdx
current font index
Definition TTF.h:78
static Int_t fgSymbItaFontIdx
Symbol italic font index.
Definition TTF.h:79
static void Cleanup()
Cleanup. Is called by the gCleanupTTF destructor.
Definition TTF.cxx:82
virtual ~TTF()
Cleanup TTF environment.
Definition TTF.cxx:57
static Int_t GetWidth()
Definition TTF.cxx:616
static const FT_BBox & GetBox()
Definition TTF.cxx:644
static char * fgFontName[kTTMaxFonts]
font name
Definition TTF.h:81
static FT_Library fgLibrary
FreeType font library.
Definition TTF.h:87
static Int_t fgNumGlyphs
number of glyphs in the string
Definition TTF.h:88
static FT_Matrix * fgRotMatrix
rotation matrix
Definition TTF.h:89
static Bool_t fgKerning
use kerning (true by default)
Definition TTF.h:86
static Int_t fgTBlankW
trailing blanks width
Definition TTF.h:91
static Bool_t GetHinting()
Definition TTF.cxx:588
static Bool_t GetSmoothing()
Definition TTF.cxx:602
static Int_t fgFontCount
number of fonts loaded
Definition TTF.h:80
static void SetTextSize(Float_t textsize)
Set current text size.
Definition TTF.cxx:561
static FT_Matrix * GetRotMatrix()
Definition TTF.cxx:637
static FT_BBox fgCBox
string control box
Definition TTF.h:76
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:594
constexpr Double_t Pi()
Definition TMath.h:37
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:588