Logo ROOT  
Reference Guide
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
378Int_t TTF::SetTextFont(const char *fontname, Int_t italic)
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 = 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;
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 ID | X11 | TTF |
474/// |---------|---------------------------|------------------|
475/// | 1 | times-medium-i-normal | timesi.ttf |
476/// | 2 | times-bold-r-normal | timesbd.ttf |
477/// | 3 | times-bold-i-normal | timesbi.ttf |
478/// | 4 | helvetica-medium-r-normal | arial.ttf |
479/// | 5 | helvetica-medium-o-normal | ariali.ttf |
480/// | 6 | helvetica-bold-r-normal | arialbd.ttf |
481/// | 7 | helvetica-bold-o-normal | arialbi.ttf |
482/// | 8 | courier-medium-r-normal | cour.ttf |
483/// | 9 | courier-medium-o-normal | couri.ttf |
484/// | 10 | courier-bold-r-normal | courbd.ttf |
485/// | 11 | courier-bold-o-normal | courbi.ttf |
486/// | 12 | symbol-medium-r-normal | symbol.ttf |
487/// | 13 | times-medium-r-normal | times.ttf |
488/// | 14 | | wingding.ttf |
489/// | 15 | symbol oblique is emulated from symbol.ttf | |
490
491void TTF::SetTextFont(Font_t fontnumber)
492{
493 // Added by cholm for use of DFSG - fonts - based on Kevins fix.
494 // Table of Microsoft and (for non-MSFT operating systems) backup
495 // FreeFont TTF fonts.
496 static const char *fonttable[][2] = {
497 { "Root.TTFont.0", "FreeSansBold.otf" },
498 { "Root.TTFont.1", "FreeSerifItalic.otf" },
499 { "Root.TTFont.2", "FreeSerifBold.otf" },
500 { "Root.TTFont.3", "FreeSerifBoldItalic.otf" },
501 { "Root.TTFont.4", "FreeSans.otf" },
502 { "Root.TTFont.5", "FreeSansOblique.otf" },
503 { "Root.TTFont.6", "FreeSansBold.otf" },
504 { "Root.TTFont.7", "FreeSansBoldOblique.otf" },
505 { "Root.TTFont.8", "FreeMono.otf" },
506 { "Root.TTFont.9", "FreeMonoOblique.otf" },
507 { "Root.TTFont.10", "FreeMonoBold.otf" },
508 { "Root.TTFont.11", "FreeMonoBoldOblique.otf" },
509 { "Root.TTFont.12", "symbol.ttf" },
510 { "Root.TTFont.13", "FreeSerif.otf" },
511 { "Root.TTFont.14", "wingding.ttf" },
512 { "Root.TTFont.15", "symbol.ttf" },
513 { "Root.TTFont.STIXGen", "STIXGeneral.otf" },
514 { "Root.TTFont.STIXGenIt", "STIXGeneralItalic.otf" },
515 { "Root.TTFont.STIXGenBd", "STIXGeneralBol.otf" },
516 { "Root.TTFont.STIXGenBdIt", "STIXGeneralBolIta.otf" },
517 { "Root.TTFont.STIXSiz1Sym", "STIXSiz1Sym.otf" },
518 { "Root.TTFont.STIXSiz1SymBd", "STIXSiz1SymBol.otf" },
519 { "Root.TTFont.STIXSiz2Sym", "STIXSiz2Sym.otf" },
520 { "Root.TTFont.STIXSiz2SymBd", "STIXSiz2SymBol.otf" },
521 { "Root.TTFont.STIXSiz3Sym", "STIXSiz3Sym.otf" },
522 { "Root.TTFont.STIXSiz3SymBd", "STIXSiz3SymBol.otf" },
523 { "Root.TTFont.STIXSiz4Sym", "STIXSiz4Sym.otf" },
524 { "Root.TTFont.STIXSiz4SymBd", "STIXSiz4SymBol.otf" },
525 { "Root.TTFont.STIXSiz5Sym", "STIXSiz5Sym.otf" },
526 { "Root.TTFont.ME", "DroidSansFallback.ttf" },
527 { "Root.TTFont.CJKMing", "DroidSansFallback.ttf" },
528 { "Root.TTFont.CJKGothic", "DroidSansFallback.ttf" }
529 };
530
531 static int fontset = -1;
532 int thisset = fontset;
533
534 int fontid = fontnumber / 10;
535 if (fontid < 0 || fontid > 31) fontid = 0;
536
537 if (thisset == -1) {
538 // try to load font (font must be in Root.TTFontPath resource)
539 // to see which fontset we have available
540 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
542 char *ttfont = gSystem->Which(ttpath, gEnv->GetValue(fonttable[fontid][0], fonttable[fontid][1]), kReadPermission);
543 if (ttfont) {
544 delete [] ttfont;
545 thisset = 0;
546 } else {
547 // try backup free font
548 thisset = 1;
549 }
550 }
551 Int_t italic = 0;
552 if (fontid==15) italic = 1;
553 int ret = SetTextFont(gEnv->GetValue(fonttable[fontid][thisset], fonttable[fontid][1]), italic);
554 // Do not define font set is we're loading the symbol.ttf - it's
555 // the same in both cases.
556 if (ret == 0 && fontid != 12) fontset = thisset;
557}
558
559////////////////////////////////////////////////////////////////////////////////
560/// Set current text size.
561
563{
564 if (!fgInit) Init();
565 if (textsize < 0) return;
566
567 if (fgCurFontIdx < 0 || fgFontCount <= fgCurFontIdx) {
568 Error("TTF::SetTextSize", "current font index out of bounds");
569 fgCurFontIdx = 0;
570 return;
571 }
572
573 Int_t tsize = (Int_t)(textsize*kScale+0.5) << 6;
574 if (FT_Set_Char_Size(fgFace[fgCurFontIdx], tsize, tsize, 72, 72))
575 Error("TTF::SetTextSize", "error in FT_Set_Char_Size");
576}
577
578////////////////////////////////////////////////////////////////////////////////
579
580void TTF::Version(Int_t &major, Int_t &minor, Int_t &patch)
581{
582 FT_Library_Version(fgLibrary, &major, &minor, &patch);
583}
584
585////////////////////////////////////////////////////////////////////////////////
586
588{
589 return fgHinting;
590}
591
592////////////////////////////////////////////////////////////////////////////////
593
595{
596 return fgKerning;
597}
598
599////////////////////////////////////////////////////////////////////////////////
600
602{
603 return fgSmoothing;
604}
605
606////////////////////////////////////////////////////////////////////////////////
607
609{
610 return fgInit;
611}
612
613////////////////////////////////////////////////////////////////////////////////
614
616{
617 return fgWidth;
618}
619
620////////////////////////////////////////////////////////////////////////////////
621
623{
624 return fgAscent;
625}
626
627////////////////////////////////////////////////////////////////////////////////
628
630{
631 return fgNumGlyphs;
632}
633
634////////////////////////////////////////////////////////////////////////////////
635
637{
638 return fgRotMatrix;
639}
640
641////////////////////////////////////////////////////////////////////////////////
642
643const FT_BBox &TTF::GetBox()
644{
645 return fgCBox;
646}
647
648////////////////////////////////////////////////////////////////////////////////
649
651{
652 return fgGlyphs;
653}
#define h(i)
Definition: RSha256.hxx:106
unsigned short UShort_t
Definition: RtypesCore.h:36
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
short Font_t
Definition: RtypesCore.h:75
short Short_t
Definition: RtypesCore.h:35
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
void Error(const char *location, const char *msgfmt,...)
void Warning(const char *location, const char *msgfmt,...)
double cos(double)
double sin(double)
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2490
@ kReadPermission
Definition: TSystem.h:48
R__EXTERN TSystem * gSystem
Definition: TSystem.h:560
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:3124
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:942
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition: TSystem.cxx:1537
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
static Bool_t IsInitialized()
Definition: TTF.cxx:608
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:594
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:580
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:491
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:622
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:650
static Int_t GetNumGlyphs()
Definition: TTF.cxx:629
static Int_t fgAscent
string ascent, used to compute Y alignment
Definition: TTF.h:75
@ kMaxGlyphs
Definition: TTF.h:73
@ kTTMaxFonts
Definition: TTF.h:73
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:615
static const FT_BBox & GetBox()
Definition: TTF.cxx:643
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:587
static Bool_t GetSmoothing()
Definition: TTF.cxx:601
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:562
static FT_Matrix * GetRotMatrix()
Definition: TTF.cxx:636
static FT_BBox fgCBox
string control box
Definition: TTF.h:76
TText * text
const Int_t n
Definition: legend1.C:16
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
Double_t Cos(Double_t)
Definition: TMath.h:631
constexpr Double_t Pi()
Definition: TMath.h:38
Double_t Sin(Double_t)
Definition: TMath.h:627
auto * a
Definition: textangle.C:12