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/2002
3// Author: Sergey Linev 29/04/2026
4
5/*************************************************************************
6 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13
14/** \class TTFhandle
15\ingroup BasicGraphics
16
17Dynamic handle to work with freetype 2 library.
18in ROOT7 TTFhandle will be renamed into TTF class
19*/
20
21
22#include <ft2build.h>
23#include FT_FREETYPE_H
24#include FT_GLYPH_H
25#include "TROOT.h"
26#include "TTF.h"
27#include "TSystem.h"
28#include "TEnv.h"
29#include "TMath.h"
30#include "TError.h"
31
32// to scale fonts to the same size as the old TT version
33const Float_t kScale = 0.93376068;
34
37
38
40 std::string name;
41 FT_Face face = nullptr;
42 FT_CharMap charmap = nullptr;
43 bool is_symbol() const
44 {
45 return (name == "wingding.ttf") || (name.find("symbol.ttf") == 0);
46 }
47};
48
49////////////////////////////////////////////////////////////////////////////////
50
55
56
57////////////////////////////////////////////////////////////////////////////////
58
63
64////////////////////////////////////////////////////////////////////////////////
65/// Initialize or close FreeType library
66/// If argument is 0 - just return current handle
67/// Library initialized per thread
68
70{
71 thread_local FT_Library _library = nullptr;
72 if ((direction > 0) || !_library) {
74 Error("TTFhandle::InitClose", "error initializing FreeType");
75 _library = nullptr;
76 }
77 } else if ((direction < 0) && _library) {
78 // SelectFontHandle(-1); // delete all font handles
80 _library = nullptr;
81 }
82
83 return _library;
84}
85
86////////////////////////////////////////////////////////////////////////////////
87/// Map char to unicode. Returns 0 in case no mapping exists.
88
90{
91 FT_Face face = fFont ? fFont->face : nullptr;
92 if (!face)
93 return 0;
94
95 if (!fFont->charmap) {
96 Int_t n = face->num_charmaps;
97 for (Int_t i = 0; i < n; i++) {
98 FT_CharMap charmap = face->charmaps[i];
99 auto platform = charmap->platform_id;
100 auto encoding = charmap->encoding_id;
101 if ((platform == 3 && encoding == 1) ||
102 (platform == 0 && encoding == 0) ||
103 (platform == 1 && encoding == 0 && fFont->is_symbol()))
104 {
105 fFont->charmap = charmap;
106 if (FT_Set_Charmap(face, charmap))
107 Error("TTF::CharToUnicode", "error in FT_Set_CharMap");
108 break;
109 }
110 }
111 }
112 return FT_Get_Char_Index(face, (FT_ULong)code);
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// Compute the trailing blanks width. It is use to compute the text width in GetTextExtent
117/// `n` is the number of trailing blanks in a string.
118
120{
121 fTBlankW = 0;
122 if (n && fFont) {
123 FT_Face face = fFont->face;
124 char space = ' ';
127 FT_Load_Char(face, space, load_flags);
128
129 FT_GlyphSlot slot = face->glyph;
130 FT_Pos advance_x = slot->advance.x;
132
134 }
135}
136
137////////////////////////////////////////////////////////////////////////////////
138/// Get width (w) and height (h) when text is horizontal.
139
141{
144 LayoutGlyphs();
145 Int_t Xoff = 0; if (fCBox.xMin < 0) Xoff = -fCBox.xMin;
146 Int_t Yoff = 0; if (fCBox.yMin < 0) Yoff = -fCBox.yMin;
147 w = fCBox.xMax + Xoff + GetTrailingBlanksWidth();
148 h = fCBox.yMax + Yoff;
150}
151
152////////////////////////////////////////////////////////////////////////////////
153/// Get advance (a) when text is horizontal.
154
156{
159 LayoutGlyphs();
160 a = GetWidth() >> 6;
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Get width (w) and height (h) when text is horizontal.
166
168{
171 LayoutGlyphs();
172 Int_t Xoff = 0; if (fCBox.xMin < 0) Xoff = -fCBox.xMin;
173 Int_t Yoff = 0; if (fCBox.yMin < 0) Yoff = -fCBox.yMin;
174 w = fCBox.xMax + Xoff + GetTrailingBlanksWidth();
175 h = fCBox.yMax + Yoff;
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
181/// Perform the Glyphs transformation.
182/// Compute the string control box.
183/// If required take the "kerning" into account.
184/// SetRotation and PrepareString should have been called before.
185
187{
188 FT_Vector origin;
191
192 fAscent = 0;
193 fWidth = 0;
194
196 if (!fgHinting)
198
199 fCBox.xMin = fCBox.yMin = 32000;
200 fCBox.xMax = fCBox.yMax = -32000;
201
202 FT_Face face = fFont ? fFont->face : nullptr;
203 if (!face)
204 return;
205
206 for (auto &glyph : fGlyphs) {
207
208 // compute glyph origin
209 if (fKerning) {
210 if (prev_index) {
211 FT_Vector kern;
212 FT_Get_Kerning(face, prev_index, glyph.fIndex,
214 &kern);
215 fWidth += kern.x;
216 }
217 prev_index = glyph.fIndex;
218 }
219
220 origin.x = fWidth;
221 origin.y = 0;
222
223 // clear existing image if there is one
224 if (glyph.fImage) {
225 FT_Done_Glyph(glyph.fImage);
226 glyph.fImage = nullptr;
227 }
228
229 // load the glyph image (in its native format)
230 if (FT_Load_Glyph(face, glyph.fIndex, load_flags))
231 continue;
232
233 // extract the glyph image
234 if (FT_Get_Glyph(face->glyph, &glyph.fImage))
235 continue;
236
237 glyph.fPos = origin;
238 fWidth += face->glyph->advance.x;
239 fAscent = TMath::Max((Int_t)(face->glyph->metrics.horiBearingY), fAscent);
240
241 // transform the glyphs
243 if (FT_Glyph_Transform(glyph.fImage, fRotMatrix.get(), &glyph.fPos))
244 continue;
245
246 // compute the string control box
247 FT_BBox bbox;
249 if (bbox.xMin < fCBox.xMin) fCBox.xMin = bbox.xMin;
250 if (bbox.yMin < fCBox.yMin) fCBox.yMin = bbox.yMin;
251 if (bbox.xMax > fCBox.xMax) fCBox.xMax = bbox.xMax;
252 if (bbox.yMax > fCBox.yMax) fCBox.yMax = bbox.yMax;
253 }
254}
255
256////////////////////////////////////////////////////////////////////////////////
257/// Return bitmap for specified glyph
258
260{
261 if (n >= fGlyphs.size())
262 return nullptr;
263
265 return nullptr;
266
267 return (FT_BitmapGlyph) fGlyphs[n].fImage;
268}
269
270////////////////////////////////////////////////////////////////////////////////
271/// Remove temporary data created by LayoutGlyphs
272
274{
275 bool is_lib = InitClose() != nullptr;
276
277 for(auto &glyph : fGlyphs) {
278 // clear existing image if there is one
279 if (glyph.fImage && is_lib) {
280 FT_Done_Glyph(glyph.fImage);
281 glyph.fImage = nullptr;
282 }
283 }
284 fGlyphs.clear();
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Put the characters in "string" in the "glyphs" array.
289
290void TTFhandle::PrepareString(const char *string)
291{
293
294 const unsigned char *p = (const unsigned char*) string;
295
296 Int_t NbTBlank = 0; // number of trailing blanks
297
298 while (*p) {
300 if (index != 0)
301 fGlyphs.emplace_back(index);
302 if (*p == ' ')
303 NbTBlank++;
304 else
305 NbTBlank = 0;
306 p++;
307 }
308
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Put the characters in "string" in the "glyphs" array.
314
315void TTFhandle::PrepareString(const wchar_t *string)
316{
318
319 FT_Face face = fFont ? fFont->face : nullptr;
320 if (!face)
321 return;
322
323 const wchar_t *p = string;
324
325 Int_t NbTBlank = 0; // number of trailing blanks
326
327 while (*p) {
329 if (index != 0)
330 fGlyphs.emplace_back(index);
331 if (*p == ' ')
332 NbTBlank++;
333 else
334 NbTBlank = 0;
335 p++;
336 }
337
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// Return current font index
343
345{
346 return fFont ? fFont->face : nullptr;
347}
348
349////////////////////////////////////////////////////////////////////////////////
350/// Set the rotation matrix used to rotate the font outlines.
351
353{
354 Float_t rangle = angle * TMath::Pi() / 180.; // Angle in radian
355#if defined(FREETYPE_PATCH) && \
356 (FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 1) && (FREETYPE_PATCH == 2)
359#else
360 Float_t sin = TMath::Sin(-rangle);
361 Float_t cos = TMath::Cos(-rangle);
362#endif
363
364 if (!fRotMatrix)
365 fRotMatrix = std::make_unique<FT_Matrix>();
366
367 fRotMatrix->xx = (FT_Fixed) (cos * (1<<16));
368 fRotMatrix->xy = (FT_Fixed) (sin * (1<<16));
369 fRotMatrix->yx = -fRotMatrix->xy;
370 fRotMatrix->yy = fRotMatrix->xx;
371}
372
373////////////////////////////////////////////////////////////////////////////////
374/// Return thread_local instance of TTFontHandle for speified font
375
377{
378 thread_local std::map<std::string, TTFontHandle> _fonts;
379
380 fFont = nullptr;
381
382 if (arg == 111) {
383 // select any existing font, fallback solution for some errors in SetTextFont
384 if (!_fonts.empty())
385 fFont = &(_fonts.begin()->second);
386 Warning("TTFhandle::SetTextFont", "%s, using %s", name, fFont ? fFont->name.c_str() : "<nothing>");
387 return fFont ? 0 : 1;
388 }
389
390 if (arg >= 0) {
391 auto iter = _fonts.find(name);
392 if (iter != _fonts.end()) {
393 fFont = &iter->second;
394 return 0;
395 }
396 if (arg == 0)
397 return 1;
398 _fonts[name] = { name, nullptr, nullptr };
399 fFont = &_fonts[name];
400 return 0;
401 }
402
403 for (auto &font : _fonts) {
404 if (font.second.face) {
405 FT_Done_Face(font.second.face);
406 font.second.face = nullptr;
407 }
408 }
409 _fonts.clear();
410 return 0;
411}
412
413
414////////////////////////////////////////////////////////////////////////////////
415/// Set text font to specified name.
416/// - font : font name
417/// - italic : the fonts should be slanted. Used for symbol font.
418///
419/// Set text font to specified name. This function returns 0 if
420/// the specified font is found, 1 if not.
421
423{
424 fFont = nullptr;
425
426 if (!fontname || !*fontname)
427 return SelectFontHandle(111, "no font name specified");
428
429 const char *basename = gSystem->BaseName(fontname);
430
431 if (SelectFontHandle(1, TString::Format("%s%s", basename, italic ? ".italic" : ""))) {
432 Fatal("SetTextFont", "Fail to create font handle for font %s", basename);
433 return 1;
434 }
435
436 // font face exists and initialized
437 if (fFont->face)
438 return 0;
439
440 auto lib = InitClose();
441 if (!lib) {
442 Error("SetTextFont", "no free type library initialized");
443 return 1;
444 }
445
446 // try to load font (font must be in Root.TTFontPath resource)
447 const char *ttpath = gEnv->GetValue("Root.TTFontPath", TROOT::GetTTFFontDir());
448
451
452 if (!ttfont)
453 return SelectFontHandle(111, TString::Format("font file %s not found in path %s", fontname, ttpath));
454
455 if (FT_New_Face(lib, ttfont, 0, &fFont->face))
456 return SelectFontHandle(111, TString::Format("error loading font %s", ttfont));
457
458 if (italic) {
460 slantMat.xx = (1 << 16);
461 slantMat.xy = ((1 << 16) >> 2);
462 slantMat.yx = 0;
463 slantMat.yy = (1 << 16);
464 FT_Set_Transform(fFont->face, &slantMat, nullptr);
465 }
466
467 return 0;
468}
469
470////////////////////////////////////////////////////////////////////////////////
471/// Set specified font.
472/// List of the currently supported fonts (screen and PostScript)
473///
474/// | Font number | TTF Names | PostScript/PDF Names |
475/// |-------------|---------------------------|-------------------------------|
476/// | 1 | Free Serif Italic | Times-Italic |
477/// | 2 | Free Serif Bold | Times-Bold |
478/// | 3 | Free Serif Bold Italic | Times-BoldItalic |
479/// | 4 | Tex Gyre Regular | Helvetica |
480/// | 5 | Tex Gyre Italic | Helvetica-Oblique |
481/// | 6 | Tex Gyre Bold | Helvetica-Bold |
482/// | 7 | Tex Gyre Bold Italic | Helvetica-BoldOblique |
483/// | 8 | Free Mono | Courier |
484/// | 9 | Free Mono Oblique | Courier-Oblique |
485/// | 10 | Free Mono Bold | Courier-Bold |
486/// | 11 | Free Mono Bold Oblique | Courier-BoldOblique |
487/// | 12 | Symbol | Symbol |
488/// | 13 | Free Serif | Times-Roman |
489/// | 14 | Wingdings | ZapfDingbats |
490
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", "texgyreheros-regular.otf" },
502 { "Root.TTFont.5", "texgyreheros-italic.otf" },
503 { "Root.TTFont.6", "texgyreheros-bold.otf" },
504 { "Root.TTFont.7", "texgyreheros-bolditalic.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",
544 thisset = ttfont ? 0 : 1;
545 }
546 Int_t italic = fontid == 15 ? 1 : 0;
548
549 // Do not define font set is we're loading the symbol.ttf - it's
550 // the same in both cases.
551 if (ret == 0 && fontid != 12)
553}
554
555////////////////////////////////////////////////////////////////////////////////
556/// Set current text size.
557
559{
560 if (textsize < 0)
561 return kFALSE;
562
563 if (!fFont || !fFont->face) {
564 Error("TTFhandle::SetTextSize", "current font not selected");
565 return kFALSE;
566 }
567
568 Int_t tsize = (Int_t)(textsize*kScale+0.5) << 6;
569 FT_Error err = FT_Set_Char_Size(fFont->face, tsize, tsize, 72, 72);
570
571 if (err)
572 Error("TTFhandle::SetTextSize", "error in FT_Set_Char_Size: 0x%x (input size %f, calc. size 0x%x)", err, textsize, tsize);
573
574 return !err;
575}
576
577////////////////////////////////////////////////////////////////////////////////
578
583
584
585////////////////////////////////////////////////////////////////////////////////
586
588{
589 return InitClose(1) != nullptr;
590}
591
592
593////////////////////////////////////////////////////////////////////////////////
594
596{
597 return fgHinting;
598}
599
600////////////////////////////////////////////////////////////////////////////////
601
606
607////////////////////////////////////////////////////////////////////////////////
608
610{
611 fgHinting = state;
612}
613
614////////////////////////////////////////////////////////////////////////////////
615
617{
618 fgSmoothing = state;
619}
620
621
622/** \class TTF
623\ingroup BasicGraphics
624
625Interface to the freetype 2 library.
626Implements old static API.
627Unitl ROOT7 just redirects to static TTFhandle instance,
628then TTFhandle will be renamed into TTF class
629*/
630
631thread_local TTF gCleanupTTF; // Allows to call "Cleanup" at the end of the session
632thread_local std::unique_ptr<TTFhandle> fgHandle; // static handle, destroyed automatically
633
634////////////////////////////////////////////////////////////////////////////////
635/// Cleanup TTF environment.
636
638{
640}
641
642////////////////////////////////////////////////////////////////////////////////
643/// Init TTF environment.
644
646{
647 if (!fgHandle) {
648 fgHandle = std::make_unique<TTFhandle>();
649 fgHandle->SetTextFont(62);
650 }
651}
652
653////////////////////////////////////////////////////////////////////////////////
654
659
660////////////////////////////////////////////////////////////////////////////////
661
663{
664 return fgHandle ? fgHandle->GetKerning() : kFALSE;
665}
666
667////////////////////////////////////////////////////////////////////////////////
668
673
674////////////////////////////////////////////////////////////////////////////////
675
677{
678 return fgHandle.get() != nullptr;
679}
680
681////////////////////////////////////////////////////////////////////////////////
682
684{
685 return fgHandle ? fgHandle->GetWidth() : 0;
686}
687
688////////////////////////////////////////////////////////////////////////////////
689
691{
692 return fgHandle ? fgHandle->GetAscent() : 0;
693}
694
695////////////////////////////////////////////////////////////////////////////////
696
698{
699 return fgHandle ? fgHandle->GetNumGlyphs() : 0;
700}
701
702////////////////////////////////////////////////////////////////////////////////
703
705{
706 return fgHandle ? fgHandle->GetRotMatrix() : nullptr;
707}
708
709////////////////////////////////////////////////////////////////////////////////
710
712{
713 return fgHandle ? fgHandle->GetTrailingBlanksWidth() : 0;
714}
715
716////////////////////////////////////////////////////////////////////////////////
717
718const FT_BBox &TTF::GetBox()
719{
720 static FT_BBox dummy;
721 return fgHandle ? fgHandle->GetBox() : dummy;
722}
723
724////////////////////////////////////////////////////////////////////////////////
725
727{
728 return fgHandle ? fgHandle->GetGlyphs() : nullptr;
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Map char to unicode. Returns 0 in case no mapping exists.
733
735{
736 Init();
737 return fgHandle->CharToUnicode(code);
738}
739
740////////////////////////////////////////////////////////////////////////////////
741/// Set the rotation matrix used to rotate the font outlines.
742
744{
745 Init();
746 fgHandle->SetRotationMatrix(angle);
747}
748
749////////////////////////////////////////////////////////////////////////////////
750/// Set hinting flag.
751
753{
755}
756
757////////////////////////////////////////////////////////////////////////////////
758/// Set kerning flag.
759
761{
762 Init();
763 fgHandle->SetKerning(state);
764}
765
766////////////////////////////////////////////////////////////////////////////////
767/// Set smoothing (anti-aliasing) flag.
768
770{
772}
773
774////////////////////////////////////////////////////////////////////////////////
775/// Set text font to specified name.
776/// - font : font name
777/// - italic : the fonts should be slanted. Used for symbol font.
778
780{
781 Init();
782 return fgHandle->SetTextFont(fontname, italic);
783}
784
785////////////////////////////////////////////////////////////////////////////////
786/// Set specified font.
787
789{
790 Init();
791 fgHandle->SetTextFont(fontnumber);
792}
793
794////////////////////////////////////////////////////////////////////////////////
795
797{
798 Init();
799 fgHandle->SetTextSize(textsize);
800}
801
802////////////////////////////////////////////////////////////////////////////////
803/// Put the characters in "string" in the "glyphs" array.
804
805void TTF::PrepareString(const char *string)
806{
807 Init();
808 fgHandle->PrepareString(string);
809}
810
811////////////////////////////////////////////////////////////////////////////////
812/// Put the characters in "string" in the "glyphs" array.
813
814void TTF::PrepareString(const wchar_t *string)
815{
816 Init();
817 fgHandle->PrepareString(string);
818}
819
820////////////////////////////////////////////////////////////////////////////////
821/// Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
822
824{
825 if (fgHandle)
826 fgHandle->LayoutGlyphs();
827}
828
829////////////////////////////////////////////////////////////////////////////////
830/// Compute the trailing blanks width. It is use to compute the text width in GetTextExtent
831/// `n` is the number of trailing blanks in a string.
832
834{
835 if (fgHandle)
836 fgHandle->ComputeTrailingBlanksWidth(n);
837}
838
839////////////////////////////////////////////////////////////////////////////////
840/// Remove temporary data created by LayoutGlyphs
841
843{
844 if (fgHandle)
845 fgHandle->CleanupGlyphs();
846}
847
848////////////////////////////////////////////////////////////////////////////////
849/// Get width (w) and height (h) when text is horizontal.
850
851void TTF::GetTextExtent(UInt_t &w, UInt_t &h, const char *text)
852{
853 Init();
854 fgHandle->GetTextExtent(w, h, text);
855}
856
857////////////////////////////////////////////////////////////////////////////////
858/// Get advance (a) when text is horizontal.
859
860void TTF::GetTextAdvance(UInt_t &a, const char *text)
861{
862 Init();
863 fgHandle->GetTextAdvance(a, text);
864}
865
866////////////////////////////////////////////////////////////////////////////////
867/// Get width (w) and height (h) when text is horizontal.
868
869void TTF::GetTextExtent(UInt_t &w, UInt_t &h, const wchar_t *text)
870{
871 Init();
872 fgHandle->GetTextExtent(w, h, text);
873}
874
875////////////////////////////////////////////////////////////////////////////////
876
878{
879 Init();
880 fgHandle->Version(major, minor, patch);
881}
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
short Font_t
Font number (short)
Definition RtypesCore.h:95
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const Float_t kScale
Definition TASImage.cxx:135
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:208
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
Definition TError.cxx:267
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 name[80]
Definition TGX11.cxx:148
@ kReadPermission
Definition TSystem.h:55
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
const Float_t kScale
Definition TTF.cxx:33
thread_local TTF gCleanupTTF
Definition TTF.cxx:631
thread_local std::unique_ptr< TTFhandle > fgHandle
Definition TTF.cxx:632
const_iterator begin() const
const_iterator end() const
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:503
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
Definition TROOT.cxx:3507
Basic string class.
Definition TString.h:138
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2385
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1553
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:948
TTF helper class containing glyphs description.
Definition TTF.h:65
Interface to the freetype 2 library.
Definition TTF.h:55
static void SetKerning(Bool_t state)
Set kerning flag.
Definition TTF.cxx:760
static Bool_t IsInitialized()
Definition TTF.cxx:676
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition TTF.cxx:805
static void GetTextExtent(UInt_t &w, UInt_t &h, const char *text)
Get width (w) and height (h) when text is horizontal.
Definition TTF.cxx:851
static Bool_t GetKerning()
Definition TTF.cxx:662
static void Version(Int_t &major, Int_t &minor, Int_t &patch)
Definition TTF.cxx:877
static Int_t GetTrailingBlanksWidth()
Definition TTF.cxx:711
static void SetHinting(Bool_t state)
Set hinting flag.
Definition TTF.cxx:752
static void Init()
Init TTF environment.
Definition TTF.cxx:645
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition TTF.cxx:823
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition TTF.cxx:769
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:743
static void CleanupGlyphs()
Remove temporary data created by LayoutGlyphs.
Definition TTF.cxx:842
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:788
static Short_t CharToUnicode(UInt_t code)
Map char to unicode. Returns 0 in case no mapping exists.
Definition TTF.cxx:734
static Int_t GetAscent()
Definition TTF.cxx:690
static TTGlyph * GetGlyphs()
Definition TTF.cxx:726
static Int_t GetNumGlyphs()
Definition TTF.cxx:697
static void ComputeTrailingBlanksWidth(Int_t n)
Compute the trailing blanks width.
Definition TTF.cxx:833
virtual ~TTF()
Cleanup TTF environment.
Definition TTF.cxx:637
static Int_t GetWidth()
Definition TTF.cxx:683
static const FT_BBox & GetBox()
Definition TTF.cxx:718
static void GetTextAdvance(UInt_t &a, const char *text)
Get advance (a) when text is horizontal.
Definition TTF.cxx:860
static Bool_t GetHinting()
Definition TTF.cxx:655
static Bool_t GetSmoothing()
Definition TTF.cxx:669
static void SetTextSize(Float_t textsize)
Definition TTF.cxx:796
static FT_Matrix * GetRotMatrix()
Definition TTF.cxx:704
void GetTextExtent(UInt_t &w, UInt_t &h, const char *text)
Get width (w) and height (h) when text is horizontal.
Definition TTF.cxx:140
Bool_t fKerning
use kerning (true by default)
Definition TTF.h:127
virtual ~TTFhandle()
Definition TTF.cxx:59
std::unique_ptr< FT_Matrix > fRotMatrix
rotation matrix
Definition TTF.h:128
std::vector< TTF::TTGlyph > fGlyphs
glyphs
Definition TTF.h:126
Int_t GetWidth() const
Definition TTF.h:154
Int_t fAscent
string ascent, used to compute Y alignment
Definition TTF.h:124
Int_t SelectFontHandle(Int_t arg, const char *name=nullptr)
Return thread_local instance of TTFontHandle for speified font.
Definition TTF.cxx:376
Bool_t SetTextSize(Float_t textsize)
Set current text size.
Definition TTF.cxx:558
void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:352
void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition TTF.cxx:290
UInt_t CharToUnicode(UInt_t code)
Map char to unicode. Returns 0 in case no mapping exists.
Definition TTF.cxx:89
FT_BitmapGlyph GetGlyphBitmap(UInt_t n, Bool_t smooth=kFALSE)
Return bitmap for specified glyph.
Definition TTF.cxx:259
static Bool_t Init()
Definition TTF.cxx:587
static void SetHinting(Bool_t state)
Definition TTF.cxx:609
FT_BBox fCBox
string control box
Definition TTF.h:125
void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:491
Int_t fTBlankW
trailing blanks width
Definition TTF.h:129
Int_t GetTrailingBlanksWidth() const
Definition TTF.h:153
TTFontHandle * fFont
selected font
Definition TTF.h:123
static Bool_t fgHinting
use hinting (false by default)
Definition TTF.h:132
void Version(Int_t &major, Int_t &minor, Int_t &patch)
Definition TTF.cxx:579
FT_Face GetFontFace() const
Return current font index.
Definition TTF.cxx:344
void CleanupGlyphs()
Remove temporary data created by LayoutGlyphs.
Definition TTF.cxx:273
void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition TTF.cxx:186
TTFhandle()
Definition TTF.cxx:51
static Bool_t GetSmoothing()
Definition TTF.cxx:602
void ComputeTrailingBlanksWidth(Int_t n)
Compute the trailing blanks width.
Definition TTF.cxx:119
void GetTextAdvance(UInt_t &a, const char *text)
Get advance (a) when text is horizontal.
Definition TTF.cxx:155
static Bool_t fgSmoothing
use anti-aliasing (true when >8 planes, false otherwise)
Definition TTF.h:133
static FT_Library InitClose(Int_t direction=0)
Initialize or close FreeType library If argument is 0 - just return current handle Library initialize...
Definition TTF.cxx:69
Int_t fWidth
string width, used to compute X alignment
Definition TTF.h:130
static Bool_t GetHinting()
Definition TTF.cxx:595
static void SetSmoothing(Bool_t state)
Definition TTF.cxx:616
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:249
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:605
constexpr Double_t Pi()
Definition TMath.h:40
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:599
FT_Face face
Definition TTF.cxx:41
FT_CharMap charmap
Definition TTF.cxx:42
std::string name
Definition TTF.cxx:40
bool is_symbol() const
Definition TTF.cxx:43