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/// Thread-local wrapper to the freetype library.
51/// The library gets initialised on demand when Get() is called.
52/// It auto-destructs when the thread exits.
54 FT_Library _library = nullptr;
55 FT_Library_Wrapper() = default;
60
61 FT_Library Get()
62 {
63 if (!_library && FT_Init_FreeType(&_library) != 0) {
64 Error("TTF.cxx", "error initializing FreeType");
65 _library = nullptr;
66 }
67 return _library;
68 }
69
70 bool InitCompleted() const { return _library != nullptr; }
71
77};
78
80
81////////////////////////////////////////////////////////////////////////////////
82
83TTFhandle::TTFhandle() = default;
84
85////////////////////////////////////////////////////////////////////////////////
86
91
92////////////////////////////////////////////////////////////////////////////////
93/// Map char to unicode. Returns 0 in case no mapping exists.
94
96{
97 FT_Face face = fFont ? fFont->face : nullptr;
98 if (!face)
99 return 0;
100
101 if (!fFont->charmap) {
102 Int_t n = face->num_charmaps;
103 for (Int_t i = 0; i < n; i++) {
104 FT_CharMap charmap = face->charmaps[i];
105 auto platform = charmap->platform_id;
106 auto encoding = charmap->encoding_id;
107 if ((platform == 3 && encoding == 1) ||
108 (platform == 0 && encoding == 0) ||
109 (platform == 1 && encoding == 0 && fFont->is_symbol()))
110 {
111 fFont->charmap = charmap;
112 if (FT_Set_Charmap(face, charmap))
113 Error("TTF::CharToUnicode", "error in FT_Set_CharMap");
114 break;
115 }
116 }
117 }
118 return FT_Get_Char_Index(face, (FT_ULong)code);
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// Compute the trailing blanks width. It is use to compute the text width in GetTextExtent
123/// `n` is the number of trailing blanks in a string.
124
126{
127 fTBlankW = 0;
128 if (n && fFont) {
129 FT_Face face = fFont->face;
130 char space = ' ';
133 FT_Load_Char(face, space, load_flags);
134
135 FT_GlyphSlot slot = face->glyph;
136 FT_Pos advance_x = slot->advance.x;
138
140 }
141}
142
143////////////////////////////////////////////////////////////////////////////////
144/// Get width (w) and height (h) when text is horizontal.
145
147{
150 LayoutGlyphs();
151 Int_t Xoff = 0; if (fCBox.xMin < 0) Xoff = -fCBox.xMin;
152 Int_t Yoff = 0; if (fCBox.yMin < 0) Yoff = -fCBox.yMin;
153 w = fCBox.xMax + Xoff + GetTrailingBlanksWidth();
154 h = fCBox.yMax + Yoff;
156}
157
158////////////////////////////////////////////////////////////////////////////////
159/// Get advance (a) when text is horizontal.
160
162{
165 LayoutGlyphs();
166 a = GetWidth() >> 6;
168}
169
170////////////////////////////////////////////////////////////////////////////////
171/// Get width (w) and height (h) when text is horizontal.
172
174{
177 LayoutGlyphs();
178 Int_t Xoff = 0; if (fCBox.xMin < 0) Xoff = -fCBox.xMin;
179 Int_t Yoff = 0; if (fCBox.yMin < 0) Yoff = -fCBox.yMin;
180 w = fCBox.xMax + Xoff + GetTrailingBlanksWidth();
181 h = fCBox.yMax + Yoff;
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
187/// Perform the Glyphs transformation.
188/// Compute the string control box.
189/// If required take the "kerning" into account.
190/// SetRotation and PrepareString should have been called before.
191
193{
194 FT_Vector origin;
197
198 fAscent = 0;
199 fWidth = 0;
200
202 if (!fgHinting)
204
205 fCBox.xMin = fCBox.yMin = 32000;
206 fCBox.xMax = fCBox.yMax = -32000;
207
208 FT_Face face = fFont ? fFont->face : nullptr;
209 if (!face)
210 return;
211
212 for (auto &glyph : fGlyphs) {
213
214 // compute glyph origin
215 if (fKerning) {
216 if (prev_index) {
217 FT_Vector kern;
218 FT_Get_Kerning(face, prev_index, glyph.fIndex,
220 &kern);
221 fWidth += kern.x;
222 }
223 prev_index = glyph.fIndex;
224 }
225
226 origin.x = fWidth;
227 origin.y = 0;
228
229 // clear existing image if there is one
230 if (glyph.fImage) {
231 FT_Done_Glyph(glyph.fImage);
232 glyph.fImage = nullptr;
233 }
234
235 // load the glyph image (in its native format)
236 if (FT_Load_Glyph(face, glyph.fIndex, load_flags))
237 continue;
238
239 // extract the glyph image
240 if (FT_Get_Glyph(face->glyph, &glyph.fImage))
241 continue;
242
243 glyph.fPos = origin;
244 fWidth += face->glyph->advance.x;
245 fAscent = TMath::Max((Int_t)(face->glyph->metrics.horiBearingY), fAscent);
246
247 // transform the glyphs
249 if (FT_Glyph_Transform(glyph.fImage, fRotMatrix.get(), &glyph.fPos))
250 continue;
251
252 // compute the string control box
253 FT_BBox bbox;
255 if (bbox.xMin < fCBox.xMin) fCBox.xMin = bbox.xMin;
256 if (bbox.yMin < fCBox.yMin) fCBox.yMin = bbox.yMin;
257 if (bbox.xMax > fCBox.xMax) fCBox.xMax = bbox.xMax;
258 if (bbox.yMax > fCBox.yMax) fCBox.yMax = bbox.yMax;
259 }
260}
261
262////////////////////////////////////////////////////////////////////////////////
263/// Return bitmap for specified glyph
264
266{
267 if (n >= fGlyphs.size())
268 return nullptr;
269
271 return nullptr;
272
273 return (FT_BitmapGlyph) fGlyphs[n].fImage;
274}
275
276////////////////////////////////////////////////////////////////////////////////
277/// Remove temporary data created by LayoutGlyphs
278
280{
281 bool is_lib = fFT_Library.InitCompleted();
282
283 for(auto &glyph : fGlyphs) {
284 // clear existing image if there is one
285 if (glyph.fImage && is_lib) {
286 FT_Done_Glyph(glyph.fImage);
287 glyph.fImage = nullptr;
288 }
289 }
290 fGlyphs.clear();
291}
292
293////////////////////////////////////////////////////////////////////////////////
294/// Put the characters in "string" in the "glyphs" array.
295
296void TTFhandle::PrepareString(const char *string)
297{
299
300 const unsigned char *p = (const unsigned char*) string;
301
302 Int_t NbTBlank = 0; // number of trailing blanks
303
304 while (*p) {
306 if (index != 0)
307 fGlyphs.emplace_back(index);
308 if (*p == ' ')
309 NbTBlank++;
310 else
311 NbTBlank = 0;
312 p++;
313 }
314
316}
317
318////////////////////////////////////////////////////////////////////////////////
319/// Put the characters in "string" in the "glyphs" array.
320
321void TTFhandle::PrepareString(const wchar_t *string)
322{
324
325 FT_Face face = fFont ? fFont->face : nullptr;
326 if (!face)
327 return;
328
329 const wchar_t *p = string;
330
331 Int_t NbTBlank = 0; // number of trailing blanks
332
333 while (*p) {
335 if (index != 0)
336 fGlyphs.emplace_back(index);
337 if (*p == ' ')
338 NbTBlank++;
339 else
340 NbTBlank = 0;
341 p++;
342 }
343
345}
346
347////////////////////////////////////////////////////////////////////////////////
348/// Return current font index
349
351{
352 return fFont ? fFont->face : nullptr;
353}
354
355////////////////////////////////////////////////////////////////////////////////
356/// Set the rotation matrix used to rotate the font outlines.
357
359{
360 Float_t rangle = angle * TMath::Pi() / 180.; // Angle in radian
361#if defined(FREETYPE_PATCH) && \
362 (FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 1) && (FREETYPE_PATCH == 2)
365#else
366 Float_t sin = TMath::Sin(-rangle);
367 Float_t cos = TMath::Cos(-rangle);
368#endif
369
370 if (!fRotMatrix)
371 fRotMatrix = std::make_unique<FT_Matrix>();
372
373 fRotMatrix->xx = (FT_Fixed) (cos * (1<<16));
374 fRotMatrix->xy = (FT_Fixed) (sin * (1<<16));
375 fRotMatrix->yx = -fRotMatrix->xy;
376 fRotMatrix->yy = fRotMatrix->xx;
377}
378
379////////////////////////////////////////////////////////////////////////////////
380/// Return thread_local instance of TTFontHandle for speified font
381
383{
384 thread_local std::map<std::string, TTFontHandle> _fonts;
385
386 fFont = nullptr;
387
388 if (arg == 111) {
389 // select any existing font, fallback solution for some errors in SetTextFont
390 if (!_fonts.empty())
391 fFont = &(_fonts.begin()->second);
392 Warning("TTFhandle::SetTextFont", "%s, using %s", name, fFont ? fFont->name.c_str() : "<nothing>");
393 return fFont ? 0 : 1;
394 }
395
396 if (arg >= 0) {
397 auto iter = _fonts.find(name);
398 if (iter != _fonts.end()) {
399 fFont = &iter->second;
400 return 0;
401 }
402 if (arg == 0)
403 return 1;
404 _fonts[name] = { name, nullptr, nullptr };
405 fFont = &_fonts[name];
406 return 0;
407 }
408
409 for (auto &font : _fonts) {
410 if (font.second.face) {
411 FT_Done_Face(font.second.face);
412 font.second.face = nullptr;
413 }
414 }
415 _fonts.clear();
416 return 0;
417}
418
419
420////////////////////////////////////////////////////////////////////////////////
421/// Set text font to specified name.
422/// - font : font name
423/// - italic : the fonts should be slanted. Used for symbol font.
424///
425/// Set text font to specified name. This function returns 0 if
426/// the specified font is found, 1 if not.
427
429{
430 fFont = nullptr;
431
432 if (!fontname || !*fontname)
433 return SelectFontHandle(111, "no font name specified");
434
435 const char *basename = gSystem->BaseName(fontname);
436
437 if (SelectFontHandle(1, TString::Format("%s%s", basename, italic ? ".italic" : ""))) {
438 Fatal("SetTextFont", "Fail to create font handle for font %s", basename);
439 return 1;
440 }
441
442 // font face exists and initialized
443 if (fFont->face)
444 return 0;
445
446 auto lib = fFT_Library.Get();
447 if (!lib) {
448 Error("SetTextFont", "no free type library initialized");
449 return 1;
450 }
451
452 // try to load font (font must be in Root.TTFontPath resource)
453 const char *ttpath = gEnv->GetValue("Root.TTFontPath", TROOT::GetTTFFontDir());
454
457
458 if (!ttfont)
459 return SelectFontHandle(111, TString::Format("font file %s not found in path %s", fontname, ttpath));
460
461 if (FT_New_Face(lib, ttfont, 0, &fFont->face))
462 return SelectFontHandle(111, TString::Format("error loading font %s", ttfont));
463
464 if (italic) {
466 slantMat.xx = (1 << 16);
467 slantMat.xy = ((1 << 16) >> 2);
468 slantMat.yx = 0;
469 slantMat.yy = (1 << 16);
470 FT_Set_Transform(fFont->face, &slantMat, nullptr);
471 }
472
473 return 0;
474}
475
476////////////////////////////////////////////////////////////////////////////////
477/// Set specified font.
478/// List of the currently supported fonts (screen and PostScript)
479///
480/// | Font number | TTF Names | PostScript/PDF Names |
481/// |-------------|---------------------------|-------------------------------|
482/// | 1 | Free Serif Italic | Times-Italic |
483/// | 2 | Free Serif Bold | Times-Bold |
484/// | 3 | Free Serif Bold Italic | Times-BoldItalic |
485/// | 4 | Tex Gyre Regular | Helvetica |
486/// | 5 | Tex Gyre Italic | Helvetica-Oblique |
487/// | 6 | Tex Gyre Bold | Helvetica-Bold |
488/// | 7 | Tex Gyre Bold Italic | Helvetica-BoldOblique |
489/// | 8 | Free Mono | Courier |
490/// | 9 | Free Mono Oblique | Courier-Oblique |
491/// | 10 | Free Mono Bold | Courier-Bold |
492/// | 11 | Free Mono Bold Oblique | Courier-BoldOblique |
493/// | 12 | Symbol | Symbol |
494/// | 13 | Free Serif | Times-Roman |
495/// | 14 | Wingdings | ZapfDingbats |
496
498{
499 // Added by cholm for use of DFSG - fonts - based on Kevins fix.
500 // Table of Microsoft and (for non-MSFT operating systems) backup
501 // FreeFont TTF fonts.
502 static const char *fonttable[][2] = {
503 { "Root.TTFont.0", "FreeSansBold.otf" },
504 { "Root.TTFont.1", "FreeSerifItalic.otf" },
505 { "Root.TTFont.2", "FreeSerifBold.otf" },
506 { "Root.TTFont.3", "FreeSerifBoldItalic.otf" },
507 { "Root.TTFont.4", "texgyreheros-regular.otf" },
508 { "Root.TTFont.5", "texgyreheros-italic.otf" },
509 { "Root.TTFont.6", "texgyreheros-bold.otf" },
510 { "Root.TTFont.7", "texgyreheros-bolditalic.otf" },
511 { "Root.TTFont.8", "FreeMono.otf" },
512 { "Root.TTFont.9", "FreeMonoOblique.otf" },
513 { "Root.TTFont.10", "FreeMonoBold.otf" },
514 { "Root.TTFont.11", "FreeMonoBoldOblique.otf" },
515 { "Root.TTFont.12", "symbol.ttf" },
516 { "Root.TTFont.13", "FreeSerif.otf" },
517 { "Root.TTFont.14", "wingding.ttf" },
518 { "Root.TTFont.15", "symbol.ttf" },
519 { "Root.TTFont.STIXGen", "STIXGeneral.otf" },
520 { "Root.TTFont.STIXGenIt", "STIXGeneralItalic.otf" },
521 { "Root.TTFont.STIXGenBd", "STIXGeneralBol.otf" },
522 { "Root.TTFont.STIXGenBdIt", "STIXGeneralBolIta.otf" },
523 { "Root.TTFont.STIXSiz1Sym", "STIXSiz1Sym.otf" },
524 { "Root.TTFont.STIXSiz1SymBd", "STIXSiz1SymBol.otf" },
525 { "Root.TTFont.STIXSiz2Sym", "STIXSiz2Sym.otf" },
526 { "Root.TTFont.STIXSiz2SymBd", "STIXSiz2SymBol.otf" },
527 { "Root.TTFont.STIXSiz3Sym", "STIXSiz3Sym.otf" },
528 { "Root.TTFont.STIXSiz3SymBd", "STIXSiz3SymBol.otf" },
529 { "Root.TTFont.STIXSiz4Sym", "STIXSiz4Sym.otf" },
530 { "Root.TTFont.STIXSiz4SymBd", "STIXSiz4SymBol.otf" },
531 { "Root.TTFont.STIXSiz5Sym", "STIXSiz5Sym.otf" },
532 { "Root.TTFont.ME", "DroidSansFallback.ttf" },
533 { "Root.TTFont.CJKMing", "DroidSansFallback.ttf" },
534 { "Root.TTFont.CJKGothic", "DroidSansFallback.ttf" }
535 };
536
537 static int fontset = -1;
538 int thisset = fontset;
539
540 int fontid = fontnumber / 10;
541 if (fontid < 0 || fontid > 31) fontid = 0;
542
543 if (thisset == -1) {
544 // try to load font (font must be in Root.TTFontPath resource)
545 // to see which fontset we have available
546 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
550 thisset = ttfont ? 0 : 1;
551 }
552 Int_t italic = fontid == 15 ? 1 : 0;
554
555 // Do not define font set is we're loading the symbol.ttf - it's
556 // the same in both cases.
557 if (ret == 0 && fontid != 12)
559}
560
561////////////////////////////////////////////////////////////////////////////////
562/// Set current text size.
563
565{
566 if (textsize < 0)
567 return kFALSE;
568
569 if (!fFont || !fFont->face) {
570 Error("TTFhandle::SetTextSize", "current font not selected");
571 return kFALSE;
572 }
573
574 Int_t tsize = (Int_t)(textsize*kScale+0.5) << 6;
575 FT_Error err = FT_Set_Char_Size(fFont->face, tsize, tsize, 72, 72);
576
577 if (err)
578 Error("TTFhandle::SetTextSize", "error in FT_Set_Char_Size: 0x%x (input size %f, calc. size 0x%x)", err, textsize, tsize);
579
580 return !err;
581}
582
583////////////////////////////////////////////////////////////////////////////////
584
589
590
591////////////////////////////////////////////////////////////////////////////////
592
594{
595 return fFT_Library.Get() != nullptr;
596}
597
598
599////////////////////////////////////////////////////////////////////////////////
600
602{
603 return fgHinting;
604}
605
606////////////////////////////////////////////////////////////////////////////////
607
612
613////////////////////////////////////////////////////////////////////////////////
614
616{
617 fgHinting = state;
618}
619
620////////////////////////////////////////////////////////////////////////////////
621
623{
624 fgSmoothing = state;
625}
626
627
628/** \class TTF
629\ingroup BasicGraphics
630
631Interface to the freetype 2 library.
632Implements old static API.
633Unitl ROOT7 just redirects to static TTFhandle instance,
634then TTFhandle will be renamed into TTF class
635*/
636
637thread_local TTF gCleanupTTF; // Allows to call "Cleanup" at the end of the session
638thread_local std::unique_ptr<TTFhandle> fgHandle; // static handle, destroyed automatically
639
640////////////////////////////////////////////////////////////////////////////////
641/// Cleanup TTF environment.
642
644
645////////////////////////////////////////////////////////////////////////////////
646/// Init TTF environment.
647
649{
650 if (!fgHandle) {
651 fgHandle = std::make_unique<TTFhandle>();
652 fgHandle->SetTextFont(62);
653 }
654}
655
656////////////////////////////////////////////////////////////////////////////////
657
662
663////////////////////////////////////////////////////////////////////////////////
664
666{
667 return fgHandle ? fgHandle->GetKerning() : kFALSE;
668}
669
670////////////////////////////////////////////////////////////////////////////////
671
676
677////////////////////////////////////////////////////////////////////////////////
678
680{
681 return fgHandle.get() != nullptr;
682}
683
684////////////////////////////////////////////////////////////////////////////////
685
687{
688 return fgHandle ? fgHandle->GetWidth() : 0;
689}
690
691////////////////////////////////////////////////////////////////////////////////
692
694{
695 return fgHandle ? fgHandle->GetAscent() : 0;
696}
697
698////////////////////////////////////////////////////////////////////////////////
699
701{
702 return fgHandle ? fgHandle->GetNumGlyphs() : 0;
703}
704
705////////////////////////////////////////////////////////////////////////////////
706
708{
709 return fgHandle ? fgHandle->GetRotMatrix() : nullptr;
710}
711
712////////////////////////////////////////////////////////////////////////////////
713
715{
716 return fgHandle ? fgHandle->GetTrailingBlanksWidth() : 0;
717}
718
719////////////////////////////////////////////////////////////////////////////////
720
721const FT_BBox &TTF::GetBox()
722{
723 static FT_BBox dummy;
724 return fgHandle ? fgHandle->GetBox() : dummy;
725}
726
727////////////////////////////////////////////////////////////////////////////////
728
730{
731 return fgHandle ? fgHandle->GetGlyphs() : nullptr;
732}
733
734////////////////////////////////////////////////////////////////////////////////
735/// Map char to unicode. Returns 0 in case no mapping exists.
736
738{
739 Init();
740 return fgHandle->CharToUnicode(code);
741}
742
743////////////////////////////////////////////////////////////////////////////////
744/// Set the rotation matrix used to rotate the font outlines.
745
747{
748 Init();
749 fgHandle->SetRotationMatrix(angle);
750}
751
752////////////////////////////////////////////////////////////////////////////////
753/// Set hinting flag.
754
756{
758}
759
760////////////////////////////////////////////////////////////////////////////////
761/// Set kerning flag.
762
764{
765 Init();
766 fgHandle->SetKerning(state);
767}
768
769////////////////////////////////////////////////////////////////////////////////
770/// Set smoothing (anti-aliasing) flag.
771
773{
775}
776
777////////////////////////////////////////////////////////////////////////////////
778/// Set text font to specified name.
779/// - font : font name
780/// - italic : the fonts should be slanted. Used for symbol font.
781
783{
784 Init();
785 return fgHandle->SetTextFont(fontname, italic);
786}
787
788////////////////////////////////////////////////////////////////////////////////
789/// Set specified font.
790
792{
793 Init();
794 fgHandle->SetTextFont(fontnumber);
795}
796
797////////////////////////////////////////////////////////////////////////////////
798
800{
801 Init();
802 fgHandle->SetTextSize(textsize);
803}
804
805////////////////////////////////////////////////////////////////////////////////
806/// Put the characters in "string" in the "glyphs" array.
807
808void TTF::PrepareString(const char *string)
809{
810 Init();
811 fgHandle->PrepareString(string);
812}
813
814////////////////////////////////////////////////////////////////////////////////
815/// Put the characters in "string" in the "glyphs" array.
816
817void TTF::PrepareString(const wchar_t *string)
818{
819 Init();
820 fgHandle->PrepareString(string);
821}
822
823////////////////////////////////////////////////////////////////////////////////
824/// Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
825
827{
828 if (fgHandle)
829 fgHandle->LayoutGlyphs();
830}
831
832////////////////////////////////////////////////////////////////////////////////
833/// Compute the trailing blanks width. It is use to compute the text width in GetTextExtent
834/// `n` is the number of trailing blanks in a string.
835
837{
838 if (fgHandle)
839 fgHandle->ComputeTrailingBlanksWidth(n);
840}
841
842////////////////////////////////////////////////////////////////////////////////
843/// Remove temporary data created by LayoutGlyphs
844
846{
847 if (fgHandle)
848 fgHandle->CleanupGlyphs();
849}
850
851////////////////////////////////////////////////////////////////////////////////
852/// Get width (w) and height (h) when text is horizontal.
853
854void TTF::GetTextExtent(UInt_t &w, UInt_t &h, const char *text)
855{
856 Init();
857 fgHandle->GetTextExtent(w, h, text);
858}
859
860////////////////////////////////////////////////////////////////////////////////
861/// Get advance (a) when text is horizontal.
862
863void TTF::GetTextAdvance(UInt_t &a, const char *text)
864{
865 Init();
866 fgHandle->GetTextAdvance(a, text);
867}
868
869////////////////////////////////////////////////////////////////////////////////
870/// Get width (w) and height (h) when text is horizontal.
871
872void TTF::GetTextExtent(UInt_t &w, UInt_t &h, const wchar_t *text)
873{
874 Init();
875 fgHandle->GetTextExtent(w, h, text);
876}
877
878////////////////////////////////////////////////////////////////////////////////
879
881{
882 Init();
883 fgHandle->Version(major, minor, patch);
884}
#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:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
short Font_t
Font number (short)
Definition RtypesCore.h:96
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
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:126
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:637
thread_local std::unique_ptr< TTFhandle > fgHandle
Definition TTF.cxx:638
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:511
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:2459
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:763
static Bool_t IsInitialized()
Definition TTF.cxx:679
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition TTF.cxx:808
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:854
static Bool_t GetKerning()
Definition TTF.cxx:665
static void Version(Int_t &major, Int_t &minor, Int_t &patch)
Definition TTF.cxx:880
static Int_t GetTrailingBlanksWidth()
Definition TTF.cxx:714
static void SetHinting(Bool_t state)
Set hinting flag.
Definition TTF.cxx:755
static void Init()
Init TTF environment.
Definition TTF.cxx:648
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition TTF.cxx:826
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition TTF.cxx:772
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:746
static void CleanupGlyphs()
Remove temporary data created by LayoutGlyphs.
Definition TTF.cxx:845
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:791
static Short_t CharToUnicode(UInt_t code)
Map char to unicode. Returns 0 in case no mapping exists.
Definition TTF.cxx:737
static Int_t GetAscent()
Definition TTF.cxx:693
static TTGlyph * GetGlyphs()
Definition TTF.cxx:729
static Int_t GetNumGlyphs()
Definition TTF.cxx:700
static void ComputeTrailingBlanksWidth(Int_t n)
Compute the trailing blanks width.
Definition TTF.cxx:836
virtual ~TTF()
Cleanup TTF environment.
Definition TTF.cxx:643
static Int_t GetWidth()
Definition TTF.cxx:686
static const FT_BBox & GetBox()
Definition TTF.cxx:721
static void GetTextAdvance(UInt_t &a, const char *text)
Get advance (a) when text is horizontal.
Definition TTF.cxx:863
static Bool_t GetHinting()
Definition TTF.cxx:658
static Bool_t GetSmoothing()
Definition TTF.cxx:672
static void SetTextSize(Float_t textsize)
Definition TTF.cxx:799
static FT_Matrix * GetRotMatrix()
Definition TTF.cxx:707
void GetTextExtent(UInt_t &w, UInt_t &h, const char *text)
Get width (w) and height (h) when text is horizontal.
Definition TTF.cxx:146
Bool_t fKerning
use kerning (true by default)
Definition TTF.h:127
virtual ~TTFhandle()
Definition TTF.cxx:87
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:156
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:382
Bool_t SetTextSize(Float_t textsize)
Set current text size.
Definition TTF.cxx:564
void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:358
void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition TTF.cxx:296
UInt_t CharToUnicode(UInt_t code)
Map char to unicode. Returns 0 in case no mapping exists.
Definition TTF.cxx:95
FT_BitmapGlyph GetGlyphBitmap(UInt_t n, Bool_t smooth=kFALSE)
Return bitmap for specified glyph.
Definition TTF.cxx:265
static Bool_t Init()
Definition TTF.cxx:593
static void SetHinting(Bool_t state)
Definition TTF.cxx:615
FT_BBox fCBox
string control box
Definition TTF.h:125
void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:497
Int_t fTBlankW
trailing blanks width
Definition TTF.h:129
Int_t GetTrailingBlanksWidth() const
Definition TTF.h:155
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:585
FT_Face GetFontFace() const
Return current font index.
Definition TTF.cxx:350
static thread_local FT_Library_Wrapper fFT_Library
Definition TTF.h:142
void CleanupGlyphs()
Remove temporary data created by LayoutGlyphs.
Definition TTF.cxx:279
void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition TTF.cxx:192
static Bool_t GetSmoothing()
Definition TTF.cxx:608
void ComputeTrailingBlanksWidth(Int_t n)
Compute the trailing blanks width.
Definition TTF.cxx:125
void GetTextAdvance(UInt_t &a, const char *text)
Get advance (a) when text is horizontal.
Definition TTF.cxx:161
static Bool_t fgSmoothing
use anti-aliasing (true when >8 planes, false otherwise)
Definition TTF.h:133
Int_t fWidth
string width, used to compute X alignment
Definition TTF.h:130
static Bool_t GetHinting()
Definition TTF.cxx:601
static void SetSmoothing(Bool_t state)
Definition TTF.cxx:622
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
Thread-local wrapper to the freetype library.
Definition TTF.cxx:53
FT_Library_Wrapper & operator=(FT_Library_Wrapper const &)=delete
bool InitCompleted() const
Definition TTF.cxx:70
FT_Library_Wrapper & operator=(FT_Library_Wrapper &&)=delete
FT_Library_Wrapper(FT_Library_Wrapper &&)=delete
FT_Library_Wrapper(FT_Library_Wrapper const &)=delete
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