Logo ROOT   6.08/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 // RConfigure.h is needed for TTFFONTDIR
19 #include "RConfigure.h"
20 
21 # include <ft2build.h>
22 # include FT_FREETYPE_H
23 # include FT_GLYPH_H
24 #include "TTF.h"
25 #include "TSystem.h"
26 #include "TEnv.h"
27 #include "TMath.h"
28 #include "TError.h"
29 
30 // to scale fonts to the same size as the old TT version
31 const Float_t kScale = 0.93376068;
32 
33 TTF gCleanupTTF; // Allows to call "Cleanup" at the end of the session
34 
46 char *TTF::fgFontName[kTTMaxFonts];
47 FT_Matrix *TTF::fgRotMatrix;
48 FT_Library TTF::fgLibrary;
49 FT_BBox TTF::fgCBox;
50 FT_Face TTF::fgFace[kTTMaxFonts];
51 FT_CharMap TTF::fgCharMap[kTTMaxFonts];
52 TTF::TTGlyph TTF::fgGlyphs[kMaxGlyphs];
53 
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Cleanup TTF environment.
58 
59 TTF::~TTF()
60 {
61  Cleanup();
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Initialise the TrueType fonts interface.
66 
67 void TTF::Init()
68 {
69  fgInit = kTRUE;
70 
71  // initialize FTF library
72  if (FT_Init_FreeType(&fgLibrary)) {
73  Error("TTF::Init", "error initializing FreeType");
74  return;
75  }
76 
77  // load default font (arialbd)
78  SetTextFont(62);
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Cleanup. Is called by the gCleanupTTF destructor.
83 
85 {
86  if (!fgInit) return;
87 
88  for (int i = 0; i < fgFontCount; i++) {
89  delete [] fgFontName[i];
90  FT_Done_Face(fgFace[i]);
91  }
92  if (fgRotMatrix) delete fgRotMatrix;
93  FT_Done_FreeType(fgLibrary);
94 
95  fgInit = kFALSE;
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// Map char to unicode. Returns 0 in case no mapping exists.
100 
102 {
103  if (!fgCharMap[fgCurFontIdx]) {
104  UShort_t i, platform, encoding;
105  FT_CharMap charmap;
106 
107  if (!fgFace[fgCurFontIdx]) return 0;
108  Int_t n = fgFace[fgCurFontIdx]->num_charmaps;
109  for (i = 0; i < n; i++) {
110  if (!fgFace[fgCurFontIdx]) continue;
111  charmap = fgFace[fgCurFontIdx]->charmaps[i];
112  platform = charmap->platform_id;
113  encoding = charmap->encoding_id;
114  if ((platform == 3 && encoding == 1) ||
115  (platform == 0 && encoding == 0) ||
116  (platform == 1 && encoding == 0 &&
117  !strcmp(fgFontName[fgCurFontIdx], "wingding.ttf")) ||
118  (platform == 1 && encoding == 0 &&
119  !strcmp(fgFontName[fgCurFontIdx], "symbol.ttf")))
120  {
121  fgCharMap[fgCurFontIdx] = charmap;
122  if (FT_Set_Charmap(fgFace[fgCurFontIdx], fgCharMap[fgCurFontIdx]))
123  Error("TTF::CharToUnicode", "error in FT_Set_CharMap");
124  return FT_Get_Char_Index(fgFace[fgCurFontIdx], (FT_ULong)code);
125  }
126  }
127  }
128  return FT_Get_Char_Index(fgFace[fgCurFontIdx], (FT_ULong)code);
129 }
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Get width (w) and height (h) when text is horizontal.
133 
135 {
136  if (!fgInit) Init();
137 
139  PrepareString(text);
140  LayoutGlyphs();
141  Int_t Xoff = 0; if (fgCBox.xMin < 0) Xoff = -fgCBox.xMin;
142  Int_t Yoff = 0; if (fgCBox.yMin < 0) Yoff = -fgCBox.yMin;
143  w = fgCBox.xMax + Xoff + fgTBlankW;
144  h = fgCBox.yMax + Yoff;
145 }
146 
147 ////////////////////////////////////////////////////////////////////////////////
148 /// Get advance (a) when text is horizontal.
149 
151 {
152  if (!fgInit) Init();
153 
155  PrepareString(text);
156  LayoutGlyphs();
157  a = GetWidth()>>6;
158 }
159 
160 ////////////////////////////////////////////////////////////////////////////////
161 /// Get width (w) and height (h) when text is horizontal.
162 
163 void TTF::GetTextExtent(UInt_t &w, UInt_t &h, wchar_t *text)
164 {
165  if (!fgInit) Init();
166 
168  PrepareString(text);
169  LayoutGlyphs();
170  Int_t Xoff = 0; if (fgCBox.xMin < 0) Xoff = -fgCBox.xMin;
171  Int_t Yoff = 0; if (fgCBox.yMin < 0) Yoff = -fgCBox.yMin;
172  w = fgCBox.xMax + Xoff + fgTBlankW;
173  h = fgCBox.yMax + Yoff;
174 }
175 
176 ////////////////////////////////////////////////////////////////////////////////
177 /// Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
178 /// Perform the Glyphs transformation.
179 /// Compute the string control box.
180 /// If required take the "kerning" into account.
181 /// SetRotation and PrepareString should have been called before.
182 
184 {
185  TTGlyph* glyph = fgGlyphs;
186  FT_Vector origin;
187  FT_UInt load_flags;
188  FT_UInt prev_index = 0;
189 
190  fgAscent = 0;
191  fgWidth = 0;
192 
193  load_flags = FT_LOAD_DEFAULT;
194  if (!fgHinting) load_flags |= FT_LOAD_NO_HINTING;
195 
196  fgCBox.xMin = fgCBox.yMin = 32000;
197  fgCBox.xMax = fgCBox.yMax = -32000;
198 
199  for (int n = 0; n < fgNumGlyphs; n++, glyph++) {
200 
201  // compute glyph origin
202  if (fgKerning) {
203  if (prev_index) {
204  FT_Vector kern;
205  FT_Get_Kerning(fgFace[fgCurFontIdx], prev_index, glyph->fIndex,
206  fgHinting ? ft_kerning_default : ft_kerning_unfitted,
207  &kern);
208  fgWidth += kern.x;
209  }
210  prev_index = glyph->fIndex;
211  }
212 
213  origin.x = fgWidth;
214  origin.y = 0;
215 
216  // clear existing image if there is one
217  if (glyph->fImage) FT_Done_Glyph(glyph->fImage);
218 
219  // load the glyph image (in its native format)
220  if (FT_Load_Glyph(fgFace[fgCurFontIdx], glyph->fIndex, load_flags))
221  continue;
222 
223  // extract the glyph image
224  if (FT_Get_Glyph (fgFace[fgCurFontIdx]->glyph, &glyph->fImage))
225  continue;
226 
227  glyph->fPos = origin;
228  fgWidth += fgFace[fgCurFontIdx]->glyph->advance.x;
229  fgAscent = TMath::Max((Int_t)(fgFace[fgCurFontIdx]->glyph->metrics.horiBearingY), fgAscent);
230 
231  // transform the glyphs
232  FT_Vector_Transform(&glyph->fPos, fgRotMatrix);
233  if (FT_Glyph_Transform(glyph->fImage, fgRotMatrix, &glyph->fPos))
234  continue;
235 
236  // compute the string control box
237  FT_BBox bbox;
238  FT_Glyph_Get_CBox(glyph->fImage, ft_glyph_bbox_pixels, &bbox);
239  if (bbox.xMin < fgCBox.xMin) fgCBox.xMin = bbox.xMin;
240  if (bbox.yMin < fgCBox.yMin) fgCBox.yMin = bbox.yMin;
241  if (bbox.xMax > fgCBox.xMax) fgCBox.xMax = bbox.xMax;
242  if (bbox.yMax > fgCBox.yMax) fgCBox.yMax = bbox.yMax;
243  }
244 }
245 
246 ////////////////////////////////////////////////////////////////////////////////
247 /// Put the characters in "string" in the "glyphs" array.
248 
249 void TTF::PrepareString(const char *string)
250 {
251  const unsigned char *p = (const unsigned char*) string;
252  TTGlyph *glyph = fgGlyphs;
253  UInt_t index; // Unicode value
254  Int_t NbTBlank = 0; // number of trailing blanks
255 
256  fgTBlankW = 0;
257  fgNumGlyphs = 0;
258  while (*p) {
259  index = CharToUnicode((FT_ULong)*p);
260  if (index != 0) {
261  glyph->fIndex = index;
262  glyph++;
263  fgNumGlyphs++;
264  }
265  if (*p == ' ') {
266  NbTBlank++;
267  } else {
268  NbTBlank = 0;
269  }
270  if (fgNumGlyphs >= kMaxGlyphs) break;
271  p++;
272  }
273 
274  // compute the trailing blanks width. It is use to compute the text
275  // width in GetTextExtent
276  if (NbTBlank) {
277  FT_UInt load_flags = FT_LOAD_DEFAULT;
278  if (!fgHinting) load_flags |= FT_LOAD_NO_HINTING;
279  if (FT_Load_Glyph(fgFace[fgCurFontIdx], 3, load_flags)) return;
280  fgTBlankW = (Int_t)((fgFace[fgCurFontIdx]->glyph->advance.x)>>6)*NbTBlank;
281  }
282 }
283 
284 ////////////////////////////////////////////////////////////////////////////////
285 /// Put the characters in "string" in the "glyphs" array.
286 
287 void TTF::PrepareString(const wchar_t *string)
288 {
289  const wchar_t *p = string;
290  TTGlyph *glyph = fgGlyphs;
291  UInt_t index; // Unicode value
292  Int_t NbTBlank = 0; // number of trailing blanks
293 
294  fgTBlankW = 0;
295  fgNumGlyphs = 0;
296  while (*p) {
297  index = FT_Get_Char_Index(fgFace[fgCurFontIdx], (FT_ULong)*p);
298  if (index != 0) {
299  glyph->fIndex = index;
300  glyph++;
301  fgNumGlyphs++;
302  }
303  if (*p == ' ') {
304  NbTBlank++;
305  } else {
306  NbTBlank = 0;
307  }
308  if (fgNumGlyphs >= kMaxGlyphs) break;
309  p++;
310  }
311 
312  // compute the trailing blanks width. It is use to compute the text
313  // width in GetTextExtent
314  if (NbTBlank) {
315  FT_UInt load_flags = FT_LOAD_DEFAULT;
316  if (!fgHinting) load_flags |= FT_LOAD_NO_HINTING;
317  if (FT_Load_Glyph(fgFace[fgCurFontIdx], 3, load_flags)) return;
318  fgTBlankW = (Int_t)((fgFace[fgCurFontIdx]->glyph->advance.x)>>6)*NbTBlank;
319  }
320 }
321 
322 ////////////////////////////////////////////////////////////////////////////////
323 /// Set hinting flag.
324 
326 {
327  fgHinting = state;
328 }
329 
330 ////////////////////////////////////////////////////////////////////////////////
331 /// Set kerning flag.
332 
334 {
335  fgKerning = state;
336 }
337 
338 ////////////////////////////////////////////////////////////////////////////////
339 /// Set the rotation matrix used to rotate the font outlines.
340 
342 {
343  Float_t rangle = Float_t(angle * TMath::Pi() / 180.); // Angle in radian
344 #if defined(FREETYPE_PATCH) && \
345  (FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 1) && (FREETYPE_PATCH == 2)
346  Float_t sin = TMath::Sin(rangle);
347  Float_t cos = TMath::Cos(rangle);
348 #else
349  Float_t sin = TMath::Sin(-rangle);
350  Float_t cos = TMath::Cos(-rangle);
351 #endif
352 
353  if (!fgRotMatrix) fgRotMatrix = new FT_Matrix;
354 
355  fgRotMatrix->xx = (FT_Fixed) (cos * (1<<16));
356  fgRotMatrix->xy = (FT_Fixed) (sin * (1<<16));
357  fgRotMatrix->yx = -fgRotMatrix->xy;
358  fgRotMatrix->yy = fgRotMatrix->xx;
359 }
360 
361 ////////////////////////////////////////////////////////////////////////////////
362 /// Set smoothing (anti-aliasing) flag.
363 
365 {
366  fgSmoothing = state;
367 }
368 
369 ////////////////////////////////////////////////////////////////////////////////
370 /// Set text font to specified name.
371 /// - font : font name
372 /// - italic : the fonts should be slanted. Used for symbol font.
373 ///
374 /// Set text font to specified name. This function returns 0 if
375 /// the specified font is found, 1 if not.
376 
377 Int_t TTF::SetTextFont(const char *fontname, Int_t italic)
378 {
379  if (!fgInit) Init();
380 
381  if (!fontname || !fontname[0]) {
382  Warning("TTF::SetTextFont",
383  "no font name specified, using default font %s", fgFontName[0]);
384  fgCurFontIdx = 0;
385  return 0;
386  }
387  const char *basename = gSystem->BaseName(fontname);
388 
389  // check if font is in cache
390  int i;
391  for (i = 0; i < fgFontCount; i++) {
392  if (!strcmp(fgFontName[i], basename)) {
393  if (italic) {
394  if (i==fgSymbItaFontIdx) {
395  fgCurFontIdx = i;
396  return 0;
397  }
398  } else {
399  if (i!=fgSymbItaFontIdx) {
400  fgCurFontIdx = i;
401  return 0;
402  }
403  }
404  }
405  }
406 
407  // enough space in cache to load font?
408  if (fgFontCount >= kTTMaxFonts) {
409  Error("TTF::SetTextFont", "too many fonts opened (increase kTTMaxFont = %d)",
410  kTTMaxFonts);
411  Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
412  fgCurFontIdx = 0; // use font 0 (default font, set in ctor)
413  return 0;
414  }
415 
416  // try to load font (font must be in Root.TTFontPath resource)
417  const char *ttpath = gEnv->GetValue("Root.TTFontPath",
418 # ifdef TTFFONTDIR
419  TTFFONTDIR
420 # else
421  "$(ROOTSYS)/fonts"
422 # endif
423  );
424 
425  char *ttfont = gSystem->Which(ttpath, fontname, kReadPermission);
426 
427  if (!ttfont) {
428  Error("TTF::SetTextFont", "font file %s not found in path", fontname);
429  if (fgFontCount) {
430  Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
431  fgCurFontIdx = 0; // use font 0 (default font, set in ctor)
432  return 0;
433  } else {
434  return 1;
435  }
436  }
437 
438  FT_Face tface = 0;
439 
440  if (FT_New_Face(fgLibrary, ttfont, 0, &tface)) {
441  Error("TTF::SetTextFont", "error loading font %s", ttfont);
442  delete [] ttfont;
443  if (tface) FT_Done_Face(tface);
444  if (fgFontCount) {
445  Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
446  fgCurFontIdx = 0;
447  return 0;
448  } else {
449  return 1;
450  }
451  }
452 
453  delete [] ttfont;
454 
455  fgFontName[fgFontCount] = StrDup(basename);
457  fgFace[fgCurFontIdx] = tface;
458  fgCharMap[fgCurFontIdx] = 0;
459  fgFontCount++;
460 
461  if (italic) {
463  FT_Matrix slantMat;
464  slantMat.xx = (1 << 16);
465  slantMat.xy = ((1 << 16) >> 2);
466  slantMat.yx = 0;
467  slantMat.yy = (1 << 16);
468  FT_Set_Transform( fgFace[fgSymbItaFontIdx], &slantMat, NULL );
469  }
470 
471  return 0;
472 }
473 
474 ////////////////////////////////////////////////////////////////////////////////
475 /// Set specified font.
476 /// List of the currently supported fonts (screen and PostScript)
477 ///
478 /// | Font ID | X11 | TTF |
479 /// |---------|---------------------------|------------------|
480 /// | 1 | times-medium-i-normal | timesi.ttf |
481 /// | 2 | times-bold-r-normal | timesbd.ttf |
482 /// | 3 | times-bold-i-normal | timesi.ttf |
483 /// | 4 | helvetica-medium-r-normal | arial.ttf |
484 /// | 5 | helvetica-medium-o-normal | ariali.ttf |
485 /// | 6 | helvetica-bold-r-normal | arialbd.ttf |
486 /// | 7 | helvetica-bold-o-normal | arialbi.ttf |
487 /// | 8 | courier-medium-r-normal | cour.ttf |
488 /// | 9 | courier-medium-o-normal | couri.ttf |
489 /// | 10 | courier-bold-r-normal | courbd.ttf |
490 /// | 11 | courier-bold-o-normal | courbi.ttf |
491 /// | 12 | symbol-medium-r-normal | symbol.ttf |
492 /// | 13 | times-medium-r-normal | times.ttf |
493 /// | 14 | | wingding.ttf |
494 /// | 15 | symbol oblique is emulated from symbol.ttf | |
495 
496 void TTF::SetTextFont(Font_t fontnumber)
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", "FreeSans.otf" },
507  { "Root.TTFont.5", "FreeSansOblique.otf" },
508  { "Root.TTFont.6", "FreeSansBold.otf" },
509  { "Root.TTFont.7", "FreeSansBoldOblique.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",
546 #ifdef TTFFONTDIR
547  TTFFONTDIR
548 #else
549  "$(ROOTSYS)/fonts"
550 #endif
551  );
552  char *ttfont = gSystem->Which(ttpath, gEnv->GetValue(fonttable[fontid][0], fonttable[fontid][1]), kReadPermission);
553  if (ttfont) {
554  delete [] ttfont;
555  thisset = 0;
556  } else {
557  // try backup free font
558  thisset = 1;
559  }
560  }
561  Int_t italic = 0;
562  if (fontid==15) italic = 1;
563  int ret = SetTextFont(gEnv->GetValue(fonttable[fontid][thisset], fonttable[fontid][1]), italic);
564  // Do not define font set is we're loading the symbol.ttf - it's
565  // the same in both cases.
566  if (ret == 0 && fontid != 12) fontset = thisset;
567 }
568 
569 ////////////////////////////////////////////////////////////////////////////////
570 /// Set current text size.
571 
572 void TTF::SetTextSize(Float_t textsize)
573 {
574  if (!fgInit) Init();
575  if (textsize < 0) return;
576 
577  if (fgCurFontIdx < 0 || fgFontCount <= fgCurFontIdx) {
578  Error("TTF::SetTextSize", "current font index out of bounds");
579  fgCurFontIdx = 0;
580  return;
581  }
582 
583  Int_t tsize = (Int_t)(textsize*kScale+0.5) << 6;
584  if (FT_Set_Char_Size(fgFace[fgCurFontIdx], tsize, tsize, 72, 72))
585  Error("TTF::SetTextSize", "error in FT_Set_Char_Size");
586 }
587 
588 ////////////////////////////////////////////////////////////////////////////////
589 
590 void TTF::Version(Int_t &major, Int_t &minor, Int_t &patch)
591 {
592  FT_Library_Version(fgLibrary, &major, &minor, &patch);
593 }
594 
595 ////////////////////////////////////////////////////////////////////////////////
596 
598 {
599  return fgHinting;
600 }
601 
602 ////////////////////////////////////////////////////////////////////////////////
603 
605 {
606  return fgKerning;
607 }
608 
609 ////////////////////////////////////////////////////////////////////////////////
610 
612 {
613  return fgSmoothing;
614 }
615 
616 ////////////////////////////////////////////////////////////////////////////////
617 
619 {
620  return fgInit;
621 }
622 
623 ////////////////////////////////////////////////////////////////////////////////
624 
626 {
627  return fgWidth;
628 }
629 
630 ////////////////////////////////////////////////////////////////////////////////
631 
633 {
634  return fgAscent;
635 }
636 
637 ////////////////////////////////////////////////////////////////////////////////
638 
640 {
641  return fgNumGlyphs;
642 }
643 
644 ////////////////////////////////////////////////////////////////////////////////
645 
646 FT_Matrix *TTF::GetRotMatrix()
647 {
648  return fgRotMatrix;
649 }
650 
651 ////////////////////////////////////////////////////////////////////////////////
652 
653 const FT_BBox &TTF::GetBox()
654 {
655  return fgCBox;
656 }
657 
658 ////////////////////////////////////////////////////////////////////////////////
659 
661 {
662  return fgGlyphs;
663 }
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:929
static void Init()
Initialise the TrueType fonts interface.
Definition: TTF.cxx:67
FT_Vector fPos
position of glyph origin
Definition: TTF.h:70
static FT_Matrix * fgRotMatrix
rotation matrix
Definition: TTF.h:91
float Float_t
Definition: RtypesCore.h:53
static Int_t fgFontCount
number of fonts loaded
Definition: TTF.h:82
static Bool_t IsInitialized()
Definition: TTF.cxx:618
FT_Glyph fImage
glyph image
Definition: TTF.h:71
unsigned short UShort_t
Definition: RtypesCore.h:36
TH1 * h
Definition: legend2.C:5
const Float_t kScale
Definition: TTF.cxx:31
static void Cleanup()
Cleanup. Is called by the gCleanupTTF destructor.
Definition: TTF.cxx:84
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Interface to the freetype 2 library.
Definition: TTF.h:55
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition: TSystem.cxx:1512
static void Version(Int_t &major, Int_t &minor, Int_t &patch)
Definition: TTF.cxx:590
UInt_t fIndex
glyph index in face
Definition: TTF.h:69
short Font_t
Definition: RtypesCore.h:75
static FT_CharMap fgCharMap[kTTMaxFonts]
font character map
Definition: TTF.h:79
double cos(double)
static Int_t fgAscent
string ascent, used to compute Y alignment
Definition: TTF.h:77
static TTF::TTGlyph fgGlyphs[kMaxGlyphs]
glyphs
Definition: TTF.h:85
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition: TTF.cxx:183
static Bool_t GetHinting()
Definition: TTF.cxx:597
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition: TTF.cxx:496
static void GetTextExtent(UInt_t &w, UInt_t &h, char *text)
Get width (w) and height (h) when text is horizontal.
Definition: TTF.cxx:134
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition: TTF.cxx:249
static FT_BBox fgCBox
string control box
Definition: TTF.h:78
static void GetTextAdvance(UInt_t &a, char *text)
Get advance (a) when text is horizontal.
Definition: TTF.cxx:150
static TTGlyph * GetGlyphs()
Definition: TTF.cxx:660
double sin(double)
void Error(const char *location, const char *msgfmt,...)
static Int_t fgTBlankW
trailing blanks width
Definition: TTF.h:93
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition: TTF.cxx:364
static Int_t fgCurFontIdx
current font index
Definition: TTF.h:80
static Int_t GetWidth()
Definition: TTF.cxx:625
static FT_Library fgLibrary
FreeType font library.
Definition: TTF.h:89
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:496
static Bool_t GetKerning()
Definition: TTF.cxx:604
static Bool_t fgKerning
use kerning (true by default)
Definition: TTF.h:88
static Bool_t fgInit
true if the Init has been called
Definition: TTF.h:87
static FT_Matrix * GetRotMatrix()
Definition: TTF.cxx:646
unsigned int UInt_t
Definition: RtypesCore.h:42
TTF helper class containing glyphs description.
Definition: TTF.h:67
short Short_t
Definition: RtypesCore.h:35
static void SetHinting(Bool_t state)
Set hinting flag.
Definition: TTF.cxx:325
void Warning(const char *location, const char *msgfmt,...)
static void SetKerning(Bool_t state)
Set kerning flag.
Definition: TTF.cxx:333
static char * fgFontName[kTTMaxFonts]
font name
Definition: TTF.h:83
Double_t Cos(Double_t)
Definition: TMath.h:424
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2514
Double_t Pi()
Definition: TMath.h:44
static Bool_t fgHinting
use hinting (true by default)
Definition: TTF.h:86
static Int_t fgSymbItaFontIdx
Symbol italic font index.
Definition: TTF.h:81
#define ClassImp(name)
Definition: Rtypes.h:279
static Int_t GetAscent()
Definition: TTF.cxx:632
TText * text
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
TTF gCleanupTTF
Definition: TTF.cxx:33
static Bool_t fgSmoothing
use anti-aliasing (true when >8 planes, false otherwise)
Definition: TTF.h:92
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition: TTF.cxx:341
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
Double_t Sin(Double_t)
Definition: TMath.h:421
#define NULL
Definition: Rtypes.h:82
static FT_Face fgFace[kTTMaxFonts]
font face
Definition: TTF.h:84
static Int_t fgNumGlyphs
number of glyphs in the string
Definition: TTF.h:90
static void SetTextSize(Float_t textsize)
Set current text size.
Definition: TTF.cxx:572
static Short_t CharToUnicode(UInt_t code)
Map char to unicode. Returns 0 in case no mapping exists.
Definition: TTF.cxx:101
static Int_t GetNumGlyphs()
Definition: TTF.cxx:639
const Bool_t kTRUE
Definition: Rtypes.h:91
const Int_t n
Definition: legend1.C:16
static Int_t fgWidth
string width, used to compute X alignment
Definition: TTF.h:94
static const FT_BBox & GetBox()
Definition: TTF.cxx:653
static Bool_t GetSmoothing()
Definition: TTF.cxx:611