Logo ROOT   6.12/07
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 
15 Interface 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
29 const Float_t kScale = 0.93376068;
30 
31 TTF gCleanupTTF; // Allows to call "Cleanup" at the end of the session
32 
44 char *TTF::fgFontName[kTTMaxFonts];
45 FT_Matrix *TTF::fgRotMatrix;
46 FT_Library TTF::fgLibrary;
47 FT_BBox TTF::fgCBox;
48 FT_Face TTF::fgFace[kTTMaxFonts];
49 FT_CharMap TTF::fgCharMap[kTTMaxFonts];
50 TTF::TTGlyph TTF::fgGlyphs[kMaxGlyphs];
51 
52 ClassImp(TTF);
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// Cleanup TTF environment.
56 
58 {
59  Cleanup();
60 }
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// Initialise the TrueType fonts interface.
64 
65 void TTF::Init()
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 
137  PrepareString(text);
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 
153  PrepareString(text);
154  LayoutGlyphs();
155  a = GetWidth()>>6;
156 }
157 
158 ////////////////////////////////////////////////////////////////////////////////
159 /// Get width (w) and height (h) when text is horizontal.
160 
161 void TTF::GetTextExtent(UInt_t &w, UInt_t &h, wchar_t *text)
162 {
163  if (!fgInit) Init();
164 
166  PrepareString(text);
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) FT_Done_Glyph(glyph->fImage);
216 
217  // load the glyph image (in its native format)
218  if (FT_Load_Glyph(fgFace[fgCurFontIdx], glyph->fIndex, load_flags))
219  continue;
220 
221  // extract the glyph image
222  if (FT_Get_Glyph (fgFace[fgCurFontIdx]->glyph, &glyph->fImage))
223  continue;
224 
225  glyph->fPos = origin;
226  fgWidth += fgFace[fgCurFontIdx]->glyph->advance.x;
227  fgAscent = TMath::Max((Int_t)(fgFace[fgCurFontIdx]->glyph->metrics.horiBearingY), fgAscent);
228 
229  // transform the glyphs
230  FT_Vector_Transform(&glyph->fPos, fgRotMatrix);
231  if (FT_Glyph_Transform(glyph->fImage, fgRotMatrix, &glyph->fPos))
232  continue;
233 
234  // compute the string control box
235  FT_BBox bbox;
236  FT_Glyph_Get_CBox(glyph->fImage, ft_glyph_bbox_pixels, &bbox);
237  if (bbox.xMin < fgCBox.xMin) fgCBox.xMin = bbox.xMin;
238  if (bbox.yMin < fgCBox.yMin) fgCBox.yMin = bbox.yMin;
239  if (bbox.xMax > fgCBox.xMax) fgCBox.xMax = bbox.xMax;
240  if (bbox.yMax > fgCBox.yMax) fgCBox.yMax = bbox.yMax;
241  }
242 }
243 
244 ////////////////////////////////////////////////////////////////////////////////
245 /// Put the characters in "string" in the "glyphs" array.
246 
247 void TTF::PrepareString(const char *string)
248 {
249  const unsigned char *p = (const unsigned char*) string;
250  TTGlyph *glyph = fgGlyphs;
251  UInt_t index; // Unicode value
252  Int_t NbTBlank = 0; // number of trailing blanks
253 
254  fgTBlankW = 0;
255  fgNumGlyphs = 0;
256  while (*p) {
257  index = CharToUnicode((FT_ULong)*p);
258  if (index != 0) {
259  glyph->fIndex = index;
260  glyph++;
261  fgNumGlyphs++;
262  }
263  if (*p == ' ') {
264  NbTBlank++;
265  } else {
266  NbTBlank = 0;
267  }
268  if (fgNumGlyphs >= kMaxGlyphs) break;
269  p++;
270  }
271 
272  // compute the trailing blanks width. It is use to compute the text
273  // width in GetTextExtent
274  if (NbTBlank) {
275  FT_UInt load_flags = FT_LOAD_DEFAULT;
276  if (!fgHinting) load_flags |= FT_LOAD_NO_HINTING;
277  if (FT_Load_Glyph(fgFace[fgCurFontIdx], 3, load_flags)) return;
278  fgTBlankW = (Int_t)((fgFace[fgCurFontIdx]->glyph->advance.x)>>6)*NbTBlank;
279  }
280 }
281 
282 ////////////////////////////////////////////////////////////////////////////////
283 /// Put the characters in "string" in the "glyphs" array.
284 
285 void TTF::PrepareString(const wchar_t *string)
286 {
287  const wchar_t *p = string;
288  TTGlyph *glyph = fgGlyphs;
289  UInt_t index; // Unicode value
290  Int_t NbTBlank = 0; // number of trailing blanks
291 
292  fgTBlankW = 0;
293  fgNumGlyphs = 0;
294  while (*p) {
295  index = FT_Get_Char_Index(fgFace[fgCurFontIdx], (FT_ULong)*p);
296  if (index != 0) {
297  glyph->fIndex = index;
298  glyph++;
299  fgNumGlyphs++;
300  }
301  if (*p == ' ') {
302  NbTBlank++;
303  } else {
304  NbTBlank = 0;
305  }
306  if (fgNumGlyphs >= kMaxGlyphs) break;
307  p++;
308  }
309 
310  // compute the trailing blanks width. It is use to compute the text
311  // width in GetTextExtent
312  if (NbTBlank) {
313  FT_UInt load_flags = FT_LOAD_DEFAULT;
314  if (!fgHinting) load_flags |= FT_LOAD_NO_HINTING;
315  if (FT_Load_Glyph(fgFace[fgCurFontIdx], 3, load_flags)) return;
316  fgTBlankW = (Int_t)((fgFace[fgCurFontIdx]->glyph->advance.x)>>6)*NbTBlank;
317  }
318 }
319 
320 ////////////////////////////////////////////////////////////////////////////////
321 /// Set hinting flag.
322 
324 {
325  fgHinting = state;
326 }
327 
328 ////////////////////////////////////////////////////////////////////////////////
329 /// Set kerning flag.
330 
332 {
333  fgKerning = state;
334 }
335 
336 ////////////////////////////////////////////////////////////////////////////////
337 /// Set the rotation matrix used to rotate the font outlines.
338 
340 {
341  Float_t rangle = Float_t(angle * TMath::Pi() / 180.); // Angle in radian
342 #if defined(FREETYPE_PATCH) && \
343  (FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 1) && (FREETYPE_PATCH == 2)
344  Float_t sin = TMath::Sin(rangle);
345  Float_t cos = TMath::Cos(rangle);
346 #else
347  Float_t sin = TMath::Sin(-rangle);
348  Float_t cos = TMath::Cos(-rangle);
349 #endif
350 
351  if (!fgRotMatrix) fgRotMatrix = new FT_Matrix;
352 
353  fgRotMatrix->xx = (FT_Fixed) (cos * (1<<16));
354  fgRotMatrix->xy = (FT_Fixed) (sin * (1<<16));
355  fgRotMatrix->yx = -fgRotMatrix->xy;
356  fgRotMatrix->yy = fgRotMatrix->xx;
357 }
358 
359 ////////////////////////////////////////////////////////////////////////////////
360 /// Set smoothing (anti-aliasing) flag.
361 
363 {
364  fgSmoothing = state;
365 }
366 
367 ////////////////////////////////////////////////////////////////////////////////
368 /// Set text font to specified name.
369 /// - font : font name
370 /// - italic : the fonts should be slanted. Used for symbol font.
371 ///
372 /// Set text font to specified name. This function returns 0 if
373 /// the specified font is found, 1 if not.
374 
375 Int_t TTF::SetTextFont(const char *fontname, Int_t italic)
376 {
377  if (!fgInit) Init();
378 
379  if (!fontname || !fontname[0]) {
380  Warning("TTF::SetTextFont",
381  "no font name specified, using default font %s", fgFontName[0]);
382  fgCurFontIdx = 0;
383  return 0;
384  }
385  const char *basename = gSystem->BaseName(fontname);
386 
387  // check if font is in cache
388  int i;
389  for (i = 0; i < fgFontCount; i++) {
390  if (!strcmp(fgFontName[i], basename)) {
391  if (italic) {
392  if (i==fgSymbItaFontIdx) {
393  fgCurFontIdx = i;
394  return 0;
395  }
396  } else {
397  if (i!=fgSymbItaFontIdx) {
398  fgCurFontIdx = i;
399  return 0;
400  }
401  }
402  }
403  }
404 
405  // enough space in cache to load font?
406  if (fgFontCount >= kTTMaxFonts) {
407  Error("TTF::SetTextFont", "too many fonts opened (increase kTTMaxFont = %d)",
408  kTTMaxFonts);
409  Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
410  fgCurFontIdx = 0; // use font 0 (default font, set in ctor)
411  return 0;
412  }
413 
414  // try to load font (font must be in Root.TTFontPath resource)
415  const char *ttpath = gEnv->GetValue("Root.TTFontPath",
417  char *ttfont = gSystem->Which(ttpath, fontname, kReadPermission);
418 
419  if (!ttfont) {
420  Error("TTF::SetTextFont", "font file %s not found in path", fontname);
421  if (fgFontCount) {
422  Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
423  fgCurFontIdx = 0; // use font 0 (default font, set in ctor)
424  return 0;
425  } else {
426  return 1;
427  }
428  }
429 
430  FT_Face tface = 0;
431 
432  if (FT_New_Face(fgLibrary, ttfont, 0, &tface)) {
433  Error("TTF::SetTextFont", "error loading font %s", ttfont);
434  delete [] ttfont;
435  if (tface) FT_Done_Face(tface);
436  if (fgFontCount) {
437  Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
438  fgCurFontIdx = 0;
439  return 0;
440  } else {
441  return 1;
442  }
443  }
444 
445  delete [] ttfont;
446 
447  fgFontName[fgFontCount] = StrDup(basename);
449  fgFace[fgCurFontIdx] = tface;
450  fgCharMap[fgCurFontIdx] = 0;
451  fgFontCount++;
452 
453  if (italic) {
455  FT_Matrix slantMat;
456  slantMat.xx = (1 << 16);
457  slantMat.xy = ((1 << 16) >> 2);
458  slantMat.yx = 0;
459  slantMat.yy = (1 << 16);
460  FT_Set_Transform( fgFace[fgSymbItaFontIdx], &slantMat, NULL );
461  }
462 
463  return 0;
464 }
465 
466 ////////////////////////////////////////////////////////////////////////////////
467 /// Set specified font.
468 /// List of the currently supported fonts (screen and PostScript)
469 ///
470 /// | Font ID | X11 | TTF |
471 /// |---------|---------------------------|------------------|
472 /// | 1 | times-medium-i-normal | timesi.ttf |
473 /// | 2 | times-bold-r-normal | timesbd.ttf |
474 /// | 3 | times-bold-i-normal | timesbi.ttf |
475 /// | 4 | helvetica-medium-r-normal | arial.ttf |
476 /// | 5 | helvetica-medium-o-normal | ariali.ttf |
477 /// | 6 | helvetica-bold-r-normal | arialbd.ttf |
478 /// | 7 | helvetica-bold-o-normal | arialbi.ttf |
479 /// | 8 | courier-medium-r-normal | cour.ttf |
480 /// | 9 | courier-medium-o-normal | couri.ttf |
481 /// | 10 | courier-bold-r-normal | courbd.ttf |
482 /// | 11 | courier-bold-o-normal | courbi.ttf |
483 /// | 12 | symbol-medium-r-normal | symbol.ttf |
484 /// | 13 | times-medium-r-normal | times.ttf |
485 /// | 14 | | wingding.ttf |
486 /// | 15 | symbol oblique is emulated from symbol.ttf | |
487 
488 void TTF::SetTextFont(Font_t fontnumber)
489 {
490  // Added by cholm for use of DFSG - fonts - based on Kevins fix.
491  // Table of Microsoft and (for non-MSFT operating systems) backup
492  // FreeFont TTF fonts.
493  static const char *fonttable[][2] = {
494  { "Root.TTFont.0", "FreeSansBold.otf" },
495  { "Root.TTFont.1", "FreeSerifItalic.otf" },
496  { "Root.TTFont.2", "FreeSerifBold.otf" },
497  { "Root.TTFont.3", "FreeSerifBoldItalic.otf" },
498  { "Root.TTFont.4", "FreeSans.otf" },
499  { "Root.TTFont.5", "FreeSansOblique.otf" },
500  { "Root.TTFont.6", "FreeSansBold.otf" },
501  { "Root.TTFont.7", "FreeSansBoldOblique.otf" },
502  { "Root.TTFont.8", "FreeMono.otf" },
503  { "Root.TTFont.9", "FreeMonoOblique.otf" },
504  { "Root.TTFont.10", "FreeMonoBold.otf" },
505  { "Root.TTFont.11", "FreeMonoBoldOblique.otf" },
506  { "Root.TTFont.12", "symbol.ttf" },
507  { "Root.TTFont.13", "FreeSerif.otf" },
508  { "Root.TTFont.14", "wingding.ttf" },
509  { "Root.TTFont.15", "symbol.ttf" },
510  { "Root.TTFont.STIXGen", "STIXGeneral.otf" },
511  { "Root.TTFont.STIXGenIt", "STIXGeneralItalic.otf" },
512  { "Root.TTFont.STIXGenBd", "STIXGeneralBol.otf" },
513  { "Root.TTFont.STIXGenBdIt", "STIXGeneralBolIta.otf" },
514  { "Root.TTFont.STIXSiz1Sym", "STIXSiz1Sym.otf" },
515  { "Root.TTFont.STIXSiz1SymBd", "STIXSiz1SymBol.otf" },
516  { "Root.TTFont.STIXSiz2Sym", "STIXSiz2Sym.otf" },
517  { "Root.TTFont.STIXSiz2SymBd", "STIXSiz2SymBol.otf" },
518  { "Root.TTFont.STIXSiz3Sym", "STIXSiz3Sym.otf" },
519  { "Root.TTFont.STIXSiz3SymBd", "STIXSiz3SymBol.otf" },
520  { "Root.TTFont.STIXSiz4Sym", "STIXSiz4Sym.otf" },
521  { "Root.TTFont.STIXSiz4SymBd", "STIXSiz4SymBol.otf" },
522  { "Root.TTFont.STIXSiz5Sym", "STIXSiz5Sym.otf" },
523  { "Root.TTFont.ME", "DroidSansFallback.ttf" },
524  { "Root.TTFont.CJKMing", "DroidSansFallback.ttf" },
525  { "Root.TTFont.CJKGothic", "DroidSansFallback.ttf" }
526  };
527 
528  static int fontset = -1;
529  int thisset = fontset;
530 
531  int fontid = fontnumber / 10;
532  if (fontid < 0 || fontid > 31) fontid = 0;
533 
534  if (thisset == -1) {
535  // try to load font (font must be in Root.TTFontPath resource)
536  // to see which fontset we have available
537  const char *ttpath = gEnv->GetValue("Root.TTFontPath",
539  char *ttfont = gSystem->Which(ttpath, gEnv->GetValue(fonttable[fontid][0], fonttable[fontid][1]), kReadPermission);
540  if (ttfont) {
541  delete [] ttfont;
542  thisset = 0;
543  } else {
544  // try backup free font
545  thisset = 1;
546  }
547  }
548  Int_t italic = 0;
549  if (fontid==15) italic = 1;
550  int ret = SetTextFont(gEnv->GetValue(fonttable[fontid][thisset], fonttable[fontid][1]), italic);
551  // Do not define font set is we're loading the symbol.ttf - it's
552  // the same in both cases.
553  if (ret == 0 && fontid != 12) fontset = thisset;
554 }
555 
556 ////////////////////////////////////////////////////////////////////////////////
557 /// Set current text size.
558 
559 void TTF::SetTextSize(Float_t textsize)
560 {
561  if (!fgInit) Init();
562  if (textsize < 0) return;
563 
564  if (fgCurFontIdx < 0 || fgFontCount <= fgCurFontIdx) {
565  Error("TTF::SetTextSize", "current font index out of bounds");
566  fgCurFontIdx = 0;
567  return;
568  }
569 
570  Int_t tsize = (Int_t)(textsize*kScale+0.5) << 6;
571  if (FT_Set_Char_Size(fgFace[fgCurFontIdx], tsize, tsize, 72, 72))
572  Error("TTF::SetTextSize", "error in FT_Set_Char_Size");
573 }
574 
575 ////////////////////////////////////////////////////////////////////////////////
576 
577 void TTF::Version(Int_t &major, Int_t &minor, Int_t &patch)
578 {
579  FT_Library_Version(fgLibrary, &major, &minor, &patch);
580 }
581 
582 ////////////////////////////////////////////////////////////////////////////////
583 
585 {
586  return fgHinting;
587 }
588 
589 ////////////////////////////////////////////////////////////////////////////////
590 
592 {
593  return fgKerning;
594 }
595 
596 ////////////////////////////////////////////////////////////////////////////////
597 
599 {
600  return fgSmoothing;
601 }
602 
603 ////////////////////////////////////////////////////////////////////////////////
604 
606 {
607  return fgInit;
608 }
609 
610 ////////////////////////////////////////////////////////////////////////////////
611 
613 {
614  return fgWidth;
615 }
616 
617 ////////////////////////////////////////////////////////////////////////////////
618 
620 {
621  return fgAscent;
622 }
623 
624 ////////////////////////////////////////////////////////////////////////////////
625 
627 {
628  return fgNumGlyphs;
629 }
630 
631 ////////////////////////////////////////////////////////////////////////////////
632 
633 FT_Matrix *TTF::GetRotMatrix()
634 {
635  return fgRotMatrix;
636 }
637 
638 ////////////////////////////////////////////////////////////////////////////////
639 
640 const FT_BBox &TTF::GetBox()
641 {
642  return fgCBox;
643 }
644 
645 ////////////////////////////////////////////////////////////////////////////////
646 
648 {
649  return fgGlyphs;
650 }
virtual ~TTF()
Cleanup TTF environment.
Definition: TTF.cxx:57
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:932
static void Init()
Initialise the TrueType fonts interface.
Definition: TTF.cxx:65
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
Definition: TROOT.cxx:3042
FT_Vector fPos
position of glyph origin
Definition: TTF.h:68
static FT_Matrix * fgRotMatrix
rotation matrix
Definition: TTF.h:89
float Float_t
Definition: RtypesCore.h:53
static Int_t fgFontCount
number of fonts loaded
Definition: TTF.h:80
static Bool_t IsInitialized()
Definition: TTF.cxx:605
FT_Glyph fImage
glyph image
Definition: TTF.h:69
unsigned short UShort_t
Definition: RtypesCore.h:36
TH1 * h
Definition: legend2.C:5
const Float_t kScale
Definition: TTF.cxx:29
static void Cleanup()
Cleanup. Is called by the gCleanupTTF destructor.
Definition: TTF.cxx:82
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Interface to the freetype 2 library.
Definition: TTF.h:53
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition: TSystem.cxx:1522
static void Version(Int_t &major, Int_t &minor, Int_t &patch)
Definition: TTF.cxx:577
UInt_t fIndex
glyph index in face
Definition: TTF.h:67
short Font_t
Definition: RtypesCore.h:75
static FT_CharMap fgCharMap[kTTMaxFonts]
font character map
Definition: TTF.h:77
double cos(double)
static Int_t fgAscent
string ascent, used to compute Y alignment
Definition: TTF.h:75
static TTF::TTGlyph fgGlyphs[kMaxGlyphs]
glyphs
Definition: TTF.h:83
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition: TTF.cxx:181
static Bool_t GetHinting()
Definition: TTF.cxx:584
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition: TTF.cxx:488
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 void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition: TTF.cxx:247
static FT_BBox fgCBox
string control box
Definition: TTF.h:76
static void GetTextAdvance(UInt_t &a, char *text)
Get advance (a) when text is horizontal.
Definition: TTF.cxx:148
static TTGlyph * GetGlyphs()
Definition: TTF.cxx:647
constexpr Double_t Pi()
Definition: TMath.h:40
double sin(double)
void Error(const char *location, const char *msgfmt,...)
static Int_t fgTBlankW
trailing blanks width
Definition: TTF.h:91
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition: TTF.cxx:362
static Int_t fgCurFontIdx
current font index
Definition: TTF.h:78
static Int_t GetWidth()
Definition: TTF.cxx:612
static FT_Library fgLibrary
FreeType font library.
Definition: TTF.h:87
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
auto * a
Definition: textangle.C:12
static Bool_t GetKerning()
Definition: TTF.cxx:591
static Bool_t fgKerning
use kerning (true by default)
Definition: TTF.h:86
static Bool_t fgInit
true if the Init has been called
Definition: TTF.h:85
static FT_Matrix * GetRotMatrix()
Definition: TTF.cxx:633
unsigned int UInt_t
Definition: RtypesCore.h:42
TTF helper class containing glyphs description.
Definition: TTF.h:65
short Short_t
Definition: RtypesCore.h:35
static void SetHinting(Bool_t state)
Set hinting flag.
Definition: TTF.cxx:323
void Warning(const char *location, const char *msgfmt,...)
static void SetKerning(Bool_t state)
Set kerning flag.
Definition: TTF.cxx:331
static char * fgFontName[kTTMaxFonts]
font name
Definition: TTF.h:81
Double_t Cos(Double_t)
Definition: TMath.h:550
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2544
const Bool_t kFALSE
Definition: RtypesCore.h:88
static Bool_t fgHinting
use hinting (true by default)
Definition: TTF.h:84
static Int_t fgSymbItaFontIdx
Symbol italic font index.
Definition: TTF.h:79
#define ClassImp(name)
Definition: Rtypes.h:359
static Int_t GetAscent()
Definition: TTF.cxx:619
TText * text
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
TTF gCleanupTTF
Definition: TTF.cxx:31
static Bool_t fgSmoothing
use anti-aliasing (true when >8 planes, false otherwise)
Definition: TTF.h:90
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition: TTF.cxx:339
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:200
Double_t Sin(Double_t)
Definition: TMath.h:547
static FT_Face fgFace[kTTMaxFonts]
font face
Definition: TTF.h:82
static Int_t fgNumGlyphs
number of glyphs in the string
Definition: TTF.h:88
static void SetTextSize(Float_t textsize)
Set current text size.
Definition: TTF.cxx:559
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 GetNumGlyphs()
Definition: TTF.cxx:626
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
const Bool_t kTRUE
Definition: RtypesCore.h:87
const Int_t n
Definition: legend1.C:16
static Int_t fgWidth
string width, used to compute X alignment
Definition: TTF.h:92
static const FT_BBox & GetBox()
Definition: TTF.cxx:640
static Bool_t GetSmoothing()
Definition: TTF.cxx:598