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/// Compute the trailing blanks width. It is use to compute the text width in GetTextExtent
131/// `n` is the number of trailing blanks in a string.
132
134{
135 fgTBlankW = 0;
136 if (n) {
137 FT_Face face = fgFace[fgCurFontIdx];
138 char space = ' ';
139 FT_UInt load_flags = FT_LOAD_DEFAULT;
140 if (!fgHinting) load_flags |= FT_LOAD_NO_HINTING;
141 FT_Load_Char(face, space, load_flags);
142
143 FT_GlyphSlot slot = face->glyph;
144 FT_Pos advance_x = slot->advance.x;
145 Int_t advance_x_pixels = advance_x >> 6;
146
147 fgTBlankW = advance_x_pixels * n;
148 }
149}
150
151////////////////////////////////////////////////////////////////////////////////
152/// Get width (w) and height (h) when text is horizontal.
153
155{
156 if (!fgInit) Init();
157
160 LayoutGlyphs();
161 Int_t Xoff = 0; if (fgCBox.xMin < 0) Xoff = -fgCBox.xMin;
162 Int_t Yoff = 0; if (fgCBox.yMin < 0) Yoff = -fgCBox.yMin;
163 w = fgCBox.xMax + Xoff + GetTrailingBlanksWidth();
164 h = fgCBox.yMax + Yoff;
165}
166
167////////////////////////////////////////////////////////////////////////////////
168/// Get advance (a) when text is horizontal.
169
171{
172 if (!fgInit) Init();
173
176 LayoutGlyphs();
177 a = GetWidth()>>6;
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Get width (w) and height (h) when text is horizontal.
182
184{
185 if (!fgInit) Init();
186
189 LayoutGlyphs();
190 Int_t Xoff = 0; if (fgCBox.xMin < 0) Xoff = -fgCBox.xMin;
191 Int_t Yoff = 0; if (fgCBox.yMin < 0) Yoff = -fgCBox.yMin;
192 w = fgCBox.xMax + Xoff + GetTrailingBlanksWidth();
193 h = fgCBox.yMax + Yoff;
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
198/// Perform the Glyphs transformation.
199/// Compute the string control box.
200/// If required take the "kerning" into account.
201/// SetRotation and PrepareString should have been called before.
202
204{
205 TTGlyph* glyph = fgGlyphs;
206 FT_Vector origin;
207 FT_UInt load_flags;
208 FT_UInt prev_index = 0;
209
210 fgAscent = 0;
211 fgWidth = 0;
212
213 load_flags = FT_LOAD_DEFAULT;
214 if (!fgHinting) load_flags |= FT_LOAD_NO_HINTING;
215
216 fgCBox.xMin = fgCBox.yMin = 32000;
217 fgCBox.xMax = fgCBox.yMax = -32000;
218
219 for (int n = 0; n < fgNumGlyphs; n++, glyph++) {
220
221 // compute glyph origin
222 if (fgKerning) {
223 if (prev_index) {
224 FT_Vector kern;
225 FT_Get_Kerning(fgFace[fgCurFontIdx], prev_index, glyph->fIndex,
226 fgHinting ? ft_kerning_default : ft_kerning_unfitted,
227 &kern);
228 fgWidth += kern.x;
229 }
230 prev_index = glyph->fIndex;
231 }
232
233 origin.x = fgWidth;
234 origin.y = 0;
235
236 // clear existing image if there is one
237 if (glyph->fImage) {
238 FT_Done_Glyph(glyph->fImage);
239 glyph->fImage = nullptr;
240 }
241
242 // load the glyph image (in its native format)
243 if (FT_Load_Glyph(fgFace[fgCurFontIdx], glyph->fIndex, load_flags))
244 continue;
245
246 // extract the glyph image
247 if (FT_Get_Glyph (fgFace[fgCurFontIdx]->glyph, &glyph->fImage))
248 continue;
249
250 glyph->fPos = origin;
251 fgWidth += fgFace[fgCurFontIdx]->glyph->advance.x;
252 fgAscent = TMath::Max((Int_t)(fgFace[fgCurFontIdx]->glyph->metrics.horiBearingY), fgAscent);
253
254 // transform the glyphs
255 FT_Vector_Transform(&glyph->fPos, fgRotMatrix);
256 if (FT_Glyph_Transform(glyph->fImage, fgRotMatrix, &glyph->fPos))
257 continue;
258
259 // compute the string control box
260 FT_BBox bbox;
261 FT_Glyph_Get_CBox(glyph->fImage, ft_glyph_bbox_pixels, &bbox);
262 if (bbox.xMin < fgCBox.xMin) fgCBox.xMin = bbox.xMin;
263 if (bbox.yMin < fgCBox.yMin) fgCBox.yMin = bbox.yMin;
264 if (bbox.xMax > fgCBox.xMax) fgCBox.xMax = bbox.xMax;
265 if (bbox.yMax > fgCBox.yMax) fgCBox.yMax = bbox.yMax;
266 }
267}
268
269////////////////////////////////////////////////////////////////////////////////
270/// Put the characters in "string" in the "glyphs" array.
271
272void TTF::PrepareString(const char *string)
273{
274 const unsigned char *p = (const unsigned char*) string;
275 TTGlyph *glyph = fgGlyphs;
276 UInt_t index; // Unicode value
277 Int_t NbTBlank = 0; // number of trailing blanks
278
279 fgNumGlyphs = 0;
280 while (*p) {
281 index = CharToUnicode((FT_ULong)*p);
282 if (index != 0) {
283 glyph->fIndex = index;
284 glyph++;
285 fgNumGlyphs++;
286 }
287 if (*p == ' ') {
288 NbTBlank++;
289 } else {
290 NbTBlank = 0;
291 }
292 if (fgNumGlyphs >= kMaxGlyphs) break;
293 p++;
294 }
295
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Put the characters in "string" in the "glyphs" array.
301
302void TTF::PrepareString(const wchar_t *string)
303{
304 const wchar_t *p = string;
305 TTGlyph *glyph = fgGlyphs;
306 UInt_t index; // Unicode value
307 Int_t NbTBlank = 0; // number of trailing blanks
308
309 fgNumGlyphs = 0;
310 while (*p) {
311 index = FT_Get_Char_Index(fgFace[fgCurFontIdx], (FT_ULong)*p);
312 if (index != 0) {
313 glyph->fIndex = index;
314 glyph++;
315 fgNumGlyphs++;
316 }
317 if (*p == ' ') {
318 NbTBlank++;
319 } else {
320 NbTBlank = 0;
321 }
322 if (fgNumGlyphs >= kMaxGlyphs) break;
323 p++;
324 }
325
327}
328
329////////////////////////////////////////////////////////////////////////////////
330/// Set hinting flag.
331
333{
334 fgHinting = state;
335}
336
337////////////////////////////////////////////////////////////////////////////////
338/// Set kerning flag.
339
341{
342 fgKerning = state;
343}
344
345////////////////////////////////////////////////////////////////////////////////
346/// Set the rotation matrix used to rotate the font outlines.
347
349{
350 Float_t rangle = Float_t(angle * TMath::Pi() / 180.); // Angle in radian
351#if defined(FREETYPE_PATCH) && \
352 (FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 1) && (FREETYPE_PATCH == 2)
353 Float_t sin = TMath::Sin(rangle);
354 Float_t cos = TMath::Cos(rangle);
355#else
356 Float_t sin = TMath::Sin(-rangle);
357 Float_t cos = TMath::Cos(-rangle);
358#endif
359
360 if (!fgRotMatrix) fgRotMatrix = new FT_Matrix;
361
362 fgRotMatrix->xx = (FT_Fixed) (cos * (1<<16));
363 fgRotMatrix->xy = (FT_Fixed) (sin * (1<<16));
364 fgRotMatrix->yx = -fgRotMatrix->xy;
365 fgRotMatrix->yy = fgRotMatrix->xx;
366}
367
368////////////////////////////////////////////////////////////////////////////////
369/// Set smoothing (anti-aliasing) flag.
370
372{
373 fgSmoothing = state;
374}
375
376////////////////////////////////////////////////////////////////////////////////
377/// Set text font to specified name.
378/// - font : font name
379/// - italic : the fonts should be slanted. Used for symbol font.
380///
381/// Set text font to specified name. This function returns 0 if
382/// the specified font is found, 1 if not.
383
385{
386 if (!fgInit) Init();
387
388 if (!fontname || !fontname[0]) {
389 Warning("TTF::SetTextFont",
390 "no font name specified, using default font %s", fgFontName[0]);
391 fgCurFontIdx = 0;
392 return 0;
393 }
394 const char *basename = gSystem->BaseName(fontname);
395
396 // check if font is in cache
397 int i;
398 for (i = 0; i < fgFontCount; i++) {
399 if (!strcmp(fgFontName[i], basename)) {
400 if (italic) {
401 if (i==fgSymbItaFontIdx) {
402 fgCurFontIdx = i;
403 return 0;
404 }
405 } else {
406 if (i!=fgSymbItaFontIdx) {
407 fgCurFontIdx = i;
408 return 0;
409 }
410 }
411 }
412 }
413
414 // enough space in cache to load font?
415 if (fgFontCount >= kTTMaxFonts) {
416 Error("TTF::SetTextFont", "too many fonts opened (increase kTTMaxFont = %d)",
418 Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
419 fgCurFontIdx = 0; // use font 0 (default font, set in ctor)
420 return 0;
421 }
422
423 // try to load font (font must be in Root.TTFontPath resource)
424 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
426 char *ttfont = gSystem->Which(ttpath, fontname, kReadPermission);
427
428 if (!ttfont) {
429 Error("TTF::SetTextFont", "font file %s not found in path", fontname);
430 if (fgFontCount) {
431 Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
432 fgCurFontIdx = 0; // use font 0 (default font, set in ctor)
433 return 0;
434 } else {
435 return 1;
436 }
437 }
438
439 FT_Face tface = (FT_Face) 0;
440
441 if (FT_New_Face(fgLibrary, ttfont, 0, &tface)) {
442 Error("TTF::SetTextFont", "error loading font %s", ttfont);
443 delete [] ttfont;
444 if (tface) FT_Done_Face(tface);
445 if (fgFontCount) {
446 Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
447 fgCurFontIdx = 0;
448 return 0;
449 } else {
450 return 1;
451 }
452 }
453
454 delete [] ttfont;
455
456 fgFontName[fgFontCount] = StrDup(basename);
458 fgFace[fgCurFontIdx] = tface;
459 fgCharMap[fgCurFontIdx] = (FT_CharMap) 0;
460 fgFontCount++;
461
462 if (italic) {
464 FT_Matrix slantMat;
465 slantMat.xx = (1 << 16);
466 slantMat.xy = ((1 << 16) >> 2);
467 slantMat.yx = 0;
468 slantMat.yy = (1 << 16);
469 FT_Set_Transform( fgFace[fgSymbItaFontIdx], &slantMat, NULL );
470 }
471
472 return 0;
473}
474
475////////////////////////////////////////////////////////////////////////////////
476/// Set specified font.
477/// List of the currently supported fonts (screen and PostScript)
478///
479/// | Font number | TTF Names | PostScript/PDF Names |
480/// |-------------|---------------------------|-------------------------------|
481/// | 1 | Free Serif Italic | Times-Italic |
482/// | 2 | Free Serif Bold | Times-Bold |
483/// | 3 | Free Serif Bold Italic | Times-BoldItalic |
484/// | 4 | Tex Gyre Regular | Helvetica |
485/// | 5 | Tex Gyre Italic | Helvetica-Oblique |
486/// | 6 | Tex Gyre Bold | Helvetica-Bold |
487/// | 7 | Tex Gyre Bold Italic | Helvetica-BoldOblique |
488/// | 8 | Free Mono | Courier |
489/// | 9 | Free Mono Oblique | Courier-Oblique |
490/// | 10 | Free Mono Bold | Courier-Bold |
491/// | 11 | Free Mono Bold Oblique | Courier-BoldOblique |
492/// | 12 | Symbol | Symbol |
493/// | 13 | Free Serif | Times-Roman |
494/// | 14 | Wingdings | ZapfDingbats |
495
497{
498 // Added by cholm for use of DFSG - fonts - based on Kevins fix.
499 // Table of Microsoft and (for non-MSFT operating systems) backup
500 // FreeFont TTF fonts.
501 static const char *fonttable[][2] = {
502 { "Root.TTFont.0", "FreeSansBold.otf" },
503 { "Root.TTFont.1", "FreeSerifItalic.otf" },
504 { "Root.TTFont.2", "FreeSerifBold.otf" },
505 { "Root.TTFont.3", "FreeSerifBoldItalic.otf" },
506 { "Root.TTFont.4", "texgyreheros-regular.otf" },
507 { "Root.TTFont.5", "texgyreheros-italic.otf" },
508 { "Root.TTFont.6", "texgyreheros-bold.otf" },
509 { "Root.TTFont.7", "texgyreheros-bolditalic.otf" },
510 { "Root.TTFont.8", "FreeMono.otf" },
511 { "Root.TTFont.9", "FreeMonoOblique.otf" },
512 { "Root.TTFont.10", "FreeMonoBold.otf" },
513 { "Root.TTFont.11", "FreeMonoBoldOblique.otf" },
514 { "Root.TTFont.12", "symbol.ttf" },
515 { "Root.TTFont.13", "FreeSerif.otf" },
516 { "Root.TTFont.14", "wingding.ttf" },
517 { "Root.TTFont.15", "symbol.ttf" },
518 { "Root.TTFont.STIXGen", "STIXGeneral.otf" },
519 { "Root.TTFont.STIXGenIt", "STIXGeneralItalic.otf" },
520 { "Root.TTFont.STIXGenBd", "STIXGeneralBol.otf" },
521 { "Root.TTFont.STIXGenBdIt", "STIXGeneralBolIta.otf" },
522 { "Root.TTFont.STIXSiz1Sym", "STIXSiz1Sym.otf" },
523 { "Root.TTFont.STIXSiz1SymBd", "STIXSiz1SymBol.otf" },
524 { "Root.TTFont.STIXSiz2Sym", "STIXSiz2Sym.otf" },
525 { "Root.TTFont.STIXSiz2SymBd", "STIXSiz2SymBol.otf" },
526 { "Root.TTFont.STIXSiz3Sym", "STIXSiz3Sym.otf" },
527 { "Root.TTFont.STIXSiz3SymBd", "STIXSiz3SymBol.otf" },
528 { "Root.TTFont.STIXSiz4Sym", "STIXSiz4Sym.otf" },
529 { "Root.TTFont.STIXSiz4SymBd", "STIXSiz4SymBol.otf" },
530 { "Root.TTFont.STIXSiz5Sym", "STIXSiz5Sym.otf" },
531 { "Root.TTFont.ME", "DroidSansFallback.ttf" },
532 { "Root.TTFont.CJKMing", "DroidSansFallback.ttf" },
533 { "Root.TTFont.CJKGothic", "DroidSansFallback.ttf" }
534 };
535
536 static int fontset = -1;
537 int thisset = fontset;
538
539 int fontid = fontnumber / 10;
540 if (fontid < 0 || fontid > 31) fontid = 0;
541
542 if (thisset == -1) {
543 // try to load font (font must be in Root.TTFontPath resource)
544 // to see which fontset we have available
545 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
547 char *ttfont = gSystem->Which(ttpath, gEnv->GetValue(fonttable[fontid][0], fonttable[fontid][1]), kReadPermission);
548 if (ttfont) {
549 delete [] ttfont;
550 thisset = 0;
551 } else {
552 // try backup free font
553 thisset = 1;
554 }
555 }
556 Int_t italic = 0;
557 if (fontid==15) italic = 1;
558 int ret = SetTextFont(gEnv->GetValue(fonttable[fontid][thisset], fonttable[fontid][1]), italic);
559 // Do not define font set is we're loading the symbol.ttf - it's
560 // the same in both cases.
561 if (ret == 0 && fontid != 12) fontset = thisset;
562}
563
564////////////////////////////////////////////////////////////////////////////////
565/// Set current text size.
566
568{
569 if (!fgInit) Init();
570 if (textsize < 0) return;
571
572 if (fgCurFontIdx < 0 || fgFontCount <= fgCurFontIdx) {
573 Error("TTF::SetTextSize", "current font index out of bounds");
574 fgCurFontIdx = 0;
575 return;
576 }
577
578 Int_t tsize = (Int_t)(textsize*kScale+0.5) << 6;
579 FT_Error err = FT_Set_Char_Size(fgFace[fgCurFontIdx], tsize, tsize, 72, 72);
580 if (err)
581 Error("TTF::SetTextSize", "error in FT_Set_Char_Size: 0x%x (input size %f, calc. size 0x%x)", err, textsize,
582 tsize);
583}
584
585////////////////////////////////////////////////////////////////////////////////
586
587void TTF::Version(Int_t &major, Int_t &minor, Int_t &patch)
588{
589 FT_Library_Version(fgLibrary, &major, &minor, &patch);
590}
591
592////////////////////////////////////////////////////////////////////////////////
593
595{
596 return fgHinting;
597}
598
599////////////////////////////////////////////////////////////////////////////////
600
602{
603 return fgKerning;
604}
605
606////////////////////////////////////////////////////////////////////////////////
607
609{
610 return fgSmoothing;
611}
612
613////////////////////////////////////////////////////////////////////////////////
614
616{
617 return fgInit;
618}
619
620////////////////////////////////////////////////////////////////////////////////
621
623{
624 return fgWidth;
625}
626
627////////////////////////////////////////////////////////////////////////////////
628
630{
631 return fgAscent;
632}
633
634////////////////////////////////////////////////////////////////////////////////
635
637{
638 return fgNumGlyphs;
639}
640
641////////////////////////////////////////////////////////////////////////////////
642
644{
645 return fgRotMatrix;
646}
647
648////////////////////////////////////////////////////////////////////////////////
649
651{
652 return fgTBlankW;
653}
654
655////////////////////////////////////////////////////////////////////////////////
656
657const FT_BBox &TTF::GetBox()
658{
659 return fgCBox;
660}
661
662////////////////////////////////////////////////////////////////////////////////
663
665{
666 return fgGlyphs;
667}
#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:81
short Short_t
Definition RtypesCore.h:39
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassImp(name)
Definition Rtypes.h:382
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:561
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:3193
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:340
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:615
static void GetTextAdvance(UInt_t &a, char *text)
Get advance (a) when text is horizontal.
Definition TTF.cxx:170
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition TTF.cxx:272
static TTF::TTGlyph fgGlyphs[kMaxGlyphs]
glyphs
Definition TTF.h:83
static Bool_t GetKerning()
Definition TTF.cxx:601
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:587
static Int_t GetTrailingBlanksWidth()
Definition TTF.cxx:650
static void SetHinting(Bool_t state)
Set hinting flag.
Definition TTF.cxx:332
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:203
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition TTF.cxx:371
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:348
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:496
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:629
static void GetTextExtent(UInt_t &w, UInt_t &h, char *text)
Get width (w) and height (h) when text is horizontal.
Definition TTF.cxx:154
static TTGlyph * GetGlyphs()
Definition TTF.cxx:664
static Int_t GetNumGlyphs()
Definition TTF.cxx:636
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
static void ComputeTrailingBlanksWidth(Int_t n)
Compute the trailing blanks width.
Definition TTF.cxx:133
virtual ~TTF()
Cleanup TTF environment.
Definition TTF.cxx:57
static Int_t GetWidth()
Definition TTF.cxx:622
static const FT_BBox & GetBox()
Definition TTF.cxx:657
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:594
static Bool_t GetSmoothing()
Definition TTF.cxx:608
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:567
static FT_Matrix * GetRotMatrix()
Definition TTF.cxx:643
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