Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TTFhandle.cxx
Go to the documentation of this file.
1// @(#)root/graf:$Id$
2// Author: Sergey Linev 25/08/2026
3
4/*************************************************************************
5 * Copyright (C) 1995-2026, 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
13/** \class TTFhandle
14\ingroup BasicGraphics
15
16Dynamic handle to work with freetype 2 library.
17in ROOT7 TTFhandle will completely replace TTF class
18*/
19
20
21#include <ft2build.h>
22#include FT_FREETYPE_H
23#include FT_GLYPH_H
24
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
36public:
37 UInt_t fIndex{0}; ///< glyph index in face
38 FT_Vector fPos; ///< position of glyph origin
39 FT_Glyph fImage{nullptr}; ///< glyph image
42};
43
44
46 std::string name;
47 FT_Face face = nullptr;
48 FT_CharMap charmap = nullptr;
49 bool is_symbol() const
50 {
51 return (name == "wingding.ttf") || (name.find("symbol.ttf") == 0);
52 }
53};
54
55////////////////////////////////////////////////////////////////////////////////
56/// Thread-local wrapper to the freetype library.
57/// The library gets initialised on demand when Get() is called.
58/// It auto-destructs when the thread exits.
60 FT_Library _library = nullptr;
61 FT_Library_Wrapper() = default;
66
67 FT_Library Get()
68 {
69 if (!_library && FT_Init_FreeType(&_library) != 0) {
70 Error("TTF.cxx", "error initializing FreeType");
71 _library = nullptr;
72 }
73 return _library;
74 }
75
81};
82
84
85////////////////////////////////////////////////////////////////////////////////
86
88{
89 // Ensure that there's a freetype library in our thread
90 fFT_Library.Get();
91}
92
93////////////////////////////////////////////////////////////////////////////////
94
99
100////////////////////////////////////////////////////////////////////////////////
101/// Map char to unicode. Returns 0 in case no mapping exists.
102
104{
105 FT_Face face = fFont ? fFont->face : nullptr;
106 if (!face)
107 return 0;
108
109 if (!fFont->charmap) {
110 Int_t n = face->num_charmaps;
111 for (Int_t i = 0; i < n; i++) {
112 FT_CharMap charmap = face->charmaps[i];
113 auto platform = charmap->platform_id;
114 auto encoding = charmap->encoding_id;
115 if ((platform == 3 && encoding == 1) ||
116 (platform == 0 && encoding == 0) ||
117 (platform == 1 && encoding == 0 && fFont->is_symbol()))
118 {
119 fFont->charmap = charmap;
120 if (FT_Set_Charmap(face, charmap))
121 Error("TTF::CharToUnicode", "error in FT_Set_CharMap");
122 break;
123 }
124 }
125 }
126 return FT_Get_Char_Index(face, (FT_ULong)code);
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// Compute the trailing blanks width. It is use to compute the text width in GetTextExtent
131/// `n` is the number of trailing blanks in a string.
132
134{
135 fTBlankW = 0;
136 if (n && fFont) {
137 FT_Face face = fFont->face;
138 char space = ' ';
141 FT_Load_Char(face, space, load_flags);
142
143 FT_GlyphSlot slot = face->glyph;
144 FT_Pos advance_x = slot->advance.x;
146
148 }
149}
150
151////////////////////////////////////////////////////////////////////////////////
152/// Get width (w) and height (h) when text is horizontal.
153
163
164////////////////////////////////////////////////////////////////////////////////
165/// Get advance (a) when text is horizontal.
166
168{
171 LayoutGlyphs();
172 a = GetWidth() >> 6;
174}
175
176////////////////////////////////////////////////////////////////////////////////
177/// Get width (w) and height (h) when text is horizontal.
178
188
189////////////////////////////////////////////////////////////////////////////////
190/// Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
191/// Perform the Glyphs transformation.
192/// Compute the string control box.
193/// If required take the "kerning" into account.
194/// SetRotation and PrepareString should have been called before.
195
197{
198 FT_Vector origin;
201
202 fAscent = 0;
203 fWidth = 0;
204
206 if (!fHinting)
208
209 xMin = yMin = 32000;
210 xMax = yMax = -32000;
211
212 FT_Face face = fFont ? fFont->face : nullptr;
213 if (!face)
214 return;
215
216 for (auto &glyph : fGlyphs) {
217
218 // compute glyph origin
219 if (fKerning) {
220 if (prev_index) {
221 FT_Vector kern;
222 FT_Get_Kerning(face, prev_index, glyph.fIndex,
224 &kern);
225 fWidth += kern.x;
226 }
227 prev_index = glyph.fIndex;
228 }
229
230 origin.x = fWidth;
231 origin.y = 0;
232
233 // clear existing image if there is one
234 if (glyph.fImage) {
235 FT_Done_Glyph(glyph.fImage);
236 glyph.fImage = nullptr;
237 }
238
239 // load the glyph image (in its native format)
240 if (FT_Load_Glyph(face, glyph.fIndex, load_flags))
241 continue;
242
243 // extract the glyph image
244 if (FT_Get_Glyph(face->glyph, &glyph.fImage))
245 continue;
246
247 glyph.fPos = origin;
248 fWidth += face->glyph->advance.x;
249 fAscent = TMath::Max((Int_t)(face->glyph->metrics.horiBearingY), fAscent);
250
251 // transform the glyphs
252 FT_Matrix m, *matrix_arg = nullptr;
253
254 if (fRotationXX || fRotationXY) {
255 m.xx = m.yy = fRotationXX;
256 m.xy = fRotationXY;
257 m.yx = -fRotationXY;
258 matrix_arg = &m;
259 }
260
262 if (FT_Glyph_Transform(glyph.fImage, matrix_arg, &glyph.fPos))
263 continue;
264
265 // compute the string control box
266 FT_BBox bbox;
268 if (bbox.xMin < xMin) xMin = bbox.xMin;
269 if (bbox.yMin < yMin) yMin = bbox.yMin;
270 if (bbox.xMax > xMax) xMax = bbox.xMax;
271 if (bbox.yMax > yMax) yMax = bbox.yMax;
272 }
273}
274
275////////////////////////////////////////////////////////////////////////////////
276/// return number of glyphs
277
279{
280 return fGlyphs.size();
281}
282
283
284////////////////////////////////////////////////////////////////////////////////
285/// Fill vector from TTF class
286/// Only for backward compatibility of old API
287
289{
290 auto &vect = *((std::vector<TTF::TTGlyph> *) data);
291 vect.resize(fGlyphs.size());
292 for (std::size_t i = 0; i < fGlyphs.size(); ++i) {
293 auto &tgt = vect[i];
294 auto &src = fGlyphs[i];
295
296 tgt.fIndex = src.fIndex;
297 tgt.fPos = src.fPos;
298 tgt.fImage = src.fImage;
299 }
300}
301
302////////////////////////////////////////////////////////////////////////////////
303/// Apply align and configured rotation matrix to text position
304/// px and py will be shifted to the place where glyph drawing can be started
305/// Method returns false when glyphs not need to be drawn
306/// while position is outside of specified pad dimentsions
307
309{
310 Int_t txalh = align / 10;
311 Int_t txalv = align % 10;
312
313 FT_Vector alignVector;
314
315 switch (txalh) {
316 case 2: alignVector.x = GetWidth() / 2; break; //center
317 case 3: alignVector.x = GetWidth(); break; //right
318 default: alignVector.x = 0; break; // left
319 }
320
321 switch (txalv) {
322 case 2: alignVector.y = GetAscent() / 2; break; // middle
323 case 3: alignVector.y = GetAscent(); break; //top
324 default: alignVector.y = 0; break; //bottom
325 }
326
327 FT_Matrix m, *matrix_arg = nullptr;
328
329 if (fRotationXX || fRotationXY) {
330 m.xx = m.yy = fRotationXX;
331 m.xy = fRotationXY;
332 m.yx = -fRotationXY;
333 matrix_arg = &m;
334 }
335
337
338 Int_t Xoff = TMath::Max(0, (Int_t) -xMin);
339 Int_t Yoff = TMath::Max(0, (Int_t) -yMin);
342
343 // If w or h is 0, very likely the string is only blank characters
344 if (w <= 0 || h <= 0)
345 return kFALSE;
346
347 Int_t x1 = px - Xoff - (alignVector.x >> 6);
348 Int_t y1 = py + Yoff + (alignVector.y >> 6) - h;
349
350 // If string falls outside window, there is probably no need to draw it.
352 return kFALSE;
353
354 // do not draw text, which size is significantly larger than available pad
355 if ((w > 10 * pad_width) || (h > 10 * pad_height))
356 return kFALSE;
357
358 px = x1;
359 py = y1;
360 return kTRUE;
361}
362
363////////////////////////////////////////////////////////////////////////////////
364/// Returns width of all glyphs
365
367{
368 return xMax + TMath::Max(0, (Int_t) -xMin);
369}
370
371////////////////////////////////////////////////////////////////////////////////
372/// Returns height of all glyphs
373
375{
376 return yMax + TMath::Max(0, (Int_t) -yMin);
377}
378
379////////////////////////////////////////////////////////////////////////////////
380/// Returns data for glyph bitmap
381/// Instead direct access to FT_BitmapGlyph one can obtain all relevant fields
382/// Thus one do not requires work with TrueType classes directly
383/// Return kFALSE when glyph not exists or if it width is zero
384
386{
387 if (n >= fGlyphs.size())
388 return kFALSE;
389
391 return kFALSE;
392
393 auto glyph = fGlyphs[n].fImage;
394 if (!glyph || (glyph->format != FT_GLYPH_FORMAT_BITMAP))
395 return kFALSE;
396
397 // 2. Safe to typecast to FT_BitmapGlyph
399
400 auto &bmp = bitmap_glyph->bitmap;
401 if (!bmp.width)
402 return kFALSE;
403
404 offx = TMath::Max(0, (Int_t) -xMin) + bitmap_glyph->left;
405 offy = yMax - bitmap_glyph->top;
406
407 buffer = bmp.buffer;
408 width = bmp.width;
409 rows = bmp.rows;
410 pitch = bmp.pitch;
411 return kTRUE;
412}
413
414////////////////////////////////////////////////////////////////////////////////
415/// Remove temporary data created by LayoutGlyphs
416
418{
419 fGlyphs.clear();
420}
421
422////////////////////////////////////////////////////////////////////////////////
423/// Put the characters in "string" in the "glyphs" array.
424
425void TTFhandle::PrepareString(const char *string)
426{
428
429 const unsigned char *p = (const unsigned char*) string;
430
431 Int_t NbTBlank = 0; // number of trailing blanks
432
433 while (*p) {
435 if (index != 0)
436 fGlyphs.emplace_back(index);
437 if (*p == ' ')
438 NbTBlank++;
439 else
440 NbTBlank = 0;
441 p++;
442 }
443
445}
446
447////////////////////////////////////////////////////////////////////////////////
448/// Put the characters in "string" in the "glyphs" array.
449
450void TTFhandle::PrepareString(const wchar_t *string)
451{
453
454 FT_Face face = fFont ? fFont->face : nullptr;
455 if (!face)
456 return;
457
458 const wchar_t *p = string;
459
460 Int_t NbTBlank = 0; // number of trailing blanks
461
462 while (*p) {
464 if (index != 0)
465 fGlyphs.emplace_back(index);
466 if (*p == ' ')
467 NbTBlank++;
468 else
469 NbTBlank = 0;
470 p++;
471 }
472
474}
475
476////////////////////////////////////////////////////////////////////////////////
477/// Return current font index
478
480{
481 return fFont ? (void *) fFont->face : nullptr;
482}
483
484////////////////////////////////////////////////////////////////////////////////
485/// Set the rotation matrix used to rotate the font outlines.
486
488{
490 if (!angle)
491 return;
492
493 Float_t rangle = angle * TMath::Pi() / 180.; // Angle in radian
494#if defined(FREETYPE_PATCH) && \
495 (FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 1) && (FREETYPE_PATCH == 2)
498#else
499 Float_t sin = TMath::Sin(-rangle);
500 Float_t cos = TMath::Cos(-rangle);
501#endif
502
503 fRotationXX = (FT_Fixed) (cos * (1<<16));
504 fRotationXY = (FT_Fixed) (sin * (1<<16));
505
506// fRotMatrix->xx = (FT_Fixed) (cos * (1<<16));
507// fRotMatrix->xy = (FT_Fixed) (sin * (1<<16));
508// fRotMatrix->yx = -fRotMatrix->xy;
509// fRotMatrix->yy = fRotMatrix->xx;
510}
511
512////////////////////////////////////////////////////////////////////////////////
513/// Return thread_local instance of FontStruct for speified font
514
516{
517 thread_local std::map<std::string, FontStruct> _fonts;
518
519 fFont = nullptr;
520
521 if (arg == 111) {
522 // select any existing font, fallback solution for some errors in SetTextFont
523 if (!_fonts.empty())
524 fFont = &(_fonts.begin()->second);
525 Warning("TTFhandle::SetTextFont", "%s, using %s", name, fFont ? fFont->name.c_str() : "<nothing>");
526 return fFont ? 0 : 1;
527 }
528
529 if (arg >= 0) {
530 auto iter = _fonts.find(name);
531 if (iter != _fonts.end()) {
532 fFont = &iter->second;
533 return 0;
534 }
535 if (arg == 0)
536 return 1;
537 _fonts[name] = { name, nullptr, nullptr };
538 fFont = &_fonts[name];
539 return 0;
540 }
541
542 for (auto &font : _fonts) {
543 if (font.second.face) {
544 FT_Done_Face(font.second.face);
545 font.second.face = nullptr;
546 }
547 }
548 _fonts.clear();
549 return 0;
550}
551
552
553////////////////////////////////////////////////////////////////////////////////
554/// Set text font to specified name.
555/// - font : font name
556/// - italic : the fonts should be slanted. Used for symbol font.
557///
558/// Set text font to specified name. This function returns 0 if
559/// the specified font is found, 1 if not.
560
562{
563 fFont = nullptr;
564
565 if (!fontname || !*fontname)
566 return SelectFontHandle(111, "no font name specified");
567
568 const char *basename = gSystem->BaseName(fontname);
569
570 if (SelectFontHandle(1, TString::Format("%s%s", basename, italic ? ".italic" : ""))) {
571 Fatal("SetTextFont", "Fail to create font handle for font %s", basename);
572 return 1;
573 }
574
575 // font face exists and initialized
576 if (fFont->face)
577 return 0;
578
579 auto lib = fFT_Library.Get();
580 if (!lib) {
581 Error("SetTextFont", "no free type library initialized");
582 return 1;
583 }
584
585 // try to load font (font must be in Root.TTFontPath resource)
586 const char *ttpath = gEnv->GetValue("Root.TTFontPath", TROOT::GetTTFFontDir());
587
590
591 if (!ttfont)
592 return SelectFontHandle(111, TString::Format("font file %s not found in path %s", fontname, ttpath));
593
594 if (FT_New_Face(lib, ttfont, 0, &fFont->face))
595 return SelectFontHandle(111, TString::Format("error loading font %s", ttfont));
596
597 if (italic) {
599 slantMat.xx = (1 << 16);
600 slantMat.xy = ((1 << 16) >> 2);
601 slantMat.yx = 0;
602 slantMat.yy = (1 << 16);
603 FT_Set_Transform(fFont->face, &slantMat, nullptr);
604 }
605
606 return 0;
607}
608
609////////////////////////////////////////////////////////////////////////////////
610/// Set specified font.
611/// List of the currently supported fonts (screen and PostScript)
612///
613/// | Font number | TTF Names | PostScript/PDF Names |
614/// |-------------|---------------------------|-------------------------------|
615/// | 1 | Free Serif Italic | Times-Italic |
616/// | 2 | Free Serif Bold | Times-Bold |
617/// | 3 | Free Serif Bold Italic | Times-BoldItalic |
618/// | 4 | Tex Gyre Regular | Helvetica |
619/// | 5 | Tex Gyre Italic | Helvetica-Oblique |
620/// | 6 | Tex Gyre Bold | Helvetica-Bold |
621/// | 7 | Tex Gyre Bold Italic | Helvetica-BoldOblique |
622/// | 8 | Free Mono | Courier |
623/// | 9 | Free Mono Oblique | Courier-Oblique |
624/// | 10 | Free Mono Bold | Courier-Bold |
625/// | 11 | Free Mono Bold Oblique | Courier-BoldOblique |
626/// | 12 | Symbol | Symbol |
627/// | 13 | Free Serif | Times-Roman |
628/// | 14 | Wingdings | ZapfDingbats |
629
631{
632 // Added by cholm for use of DFSG - fonts - based on Kevins fix.
633 // Table of Microsoft and (for non-MSFT operating systems) backup
634 // FreeFont TTF fonts.
635 static const char *fonttable[][2] = {
636 { "Root.TTFont.0", "FreeSansBold.otf" },
637 { "Root.TTFont.1", "FreeSerifItalic.otf" },
638 { "Root.TTFont.2", "FreeSerifBold.otf" },
639 { "Root.TTFont.3", "FreeSerifBoldItalic.otf" },
640 { "Root.TTFont.4", "texgyreheros-regular.otf" },
641 { "Root.TTFont.5", "texgyreheros-italic.otf" },
642 { "Root.TTFont.6", "texgyreheros-bold.otf" },
643 { "Root.TTFont.7", "texgyreheros-bolditalic.otf" },
644 { "Root.TTFont.8", "FreeMono.otf" },
645 { "Root.TTFont.9", "FreeMonoOblique.otf" },
646 { "Root.TTFont.10", "FreeMonoBold.otf" },
647 { "Root.TTFont.11", "FreeMonoBoldOblique.otf" },
648 { "Root.TTFont.12", "symbol.ttf" },
649 { "Root.TTFont.13", "FreeSerif.otf" },
650 { "Root.TTFont.14", "wingding.ttf" },
651 { "Root.TTFont.15", "symbol.ttf" },
652 { "Root.TTFont.STIXGen", "STIXGeneral.otf" },
653 { "Root.TTFont.STIXGenIt", "STIXGeneralItalic.otf" },
654 { "Root.TTFont.STIXGenBd", "STIXGeneralBol.otf" },
655 { "Root.TTFont.STIXGenBdIt", "STIXGeneralBolIta.otf" },
656 { "Root.TTFont.STIXSiz1Sym", "STIXSiz1Sym.otf" },
657 { "Root.TTFont.STIXSiz1SymBd", "STIXSiz1SymBol.otf" },
658 { "Root.TTFont.STIXSiz2Sym", "STIXSiz2Sym.otf" },
659 { "Root.TTFont.STIXSiz2SymBd", "STIXSiz2SymBol.otf" },
660 { "Root.TTFont.STIXSiz3Sym", "STIXSiz3Sym.otf" },
661 { "Root.TTFont.STIXSiz3SymBd", "STIXSiz3SymBol.otf" },
662 { "Root.TTFont.STIXSiz4Sym", "STIXSiz4Sym.otf" },
663 { "Root.TTFont.STIXSiz4SymBd", "STIXSiz4SymBol.otf" },
664 { "Root.TTFont.STIXSiz5Sym", "STIXSiz5Sym.otf" },
665 { "Root.TTFont.ME", "DroidSansFallback.ttf" },
666 { "Root.TTFont.CJKMing", "DroidSansFallback.ttf" },
667 { "Root.TTFont.CJKGothic", "DroidSansFallback.ttf" }
668 };
669
670 static int fontset = -1;
671 int thisset = fontset;
672
673 int fontid = fontnumber / 10;
674 if (fontid < 0 || fontid > 31) fontid = 0;
675
676 if (thisset == -1) {
677 // try to load font (font must be in Root.TTFontPath resource)
678 // to see which fontset we have available
679 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
683 thisset = ttfont ? 0 : 1;
684 }
685 Int_t italic = fontid == 15 ? 1 : 0;
687
688 // Do not define font set is we're loading the symbol.ttf - it's
689 // the same in both cases.
690 if (ret == 0 && fontid != 12)
692}
693
694////////////////////////////////////////////////////////////////////////////////
695/// Set current text size.
696
698{
699 if (textsize < 0)
700 return kFALSE;
701
702 if (!fFont || !fFont->face) {
703 Error("TTFhandle::SetTextSize", "current font not selected");
704 return kFALSE;
705 }
706
707 Int_t tsize = (Int_t)(textsize*kScale+0.5) << 6;
709
710 if (err)
711 Error("TTFhandle::SetTextSize", "error in FT_Set_Char_Size: 0x%x (input size %f, calc. size 0x%x)", err, textsize, tsize);
712
713 return !err;
714}
715
716////////////////////////////////////////////////////////////////////////////////
717
722
723
724////////////////////////////////////////////////////////////////////////////////
725
727{
728 return fFT_Library.Get() != nullptr;
729}
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:53
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
short Font_t
Font number (short)
Definition RtypesCore.h:96
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const Float_t kScale
Definition TASImage.cxx:131
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 data
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 TPoint TPoint const char x1
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 width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:142
@ kReadPermission
Definition TSystem.h:55
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
const Float_t kScale
Definition TTFhandle.cxx:33
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:3522
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
void GetTextExtent(UInt_t &w, UInt_t &h, const char *text)
Get width (w) and height (h) when text is horizontal.
long fRotationXX
Definition TTFhandle.h:34
Bool_t fKerning
use kerning (true by default)
Definition TTFhandle.h:29
void * GetFontFace() const
Return current font index.
virtual ~TTFhandle()
Definition TTFhandle.cxx:95
long xMax
Definition TTFhandle.h:37
Int_t GetWidth() const
Definition TTFhandle.h:78
Int_t fAscent
string ascent, used to compute Y alignment
Definition TTFhandle.h:36
Int_t SelectFontHandle(Int_t arg, const char *name=nullptr)
Return thread_local instance of FontStruct for speified font.
FontStruct * fFont
selected font
Definition TTFhandle.h:33
Bool_t SetTextSize(Float_t textsize)
Set current text size.
void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
UInt_t CharToUnicode(UInt_t code)
Map char to unicode. Returns 0 in case no mapping exists.
static Bool_t Init()
UInt_t GetNumGlyphs() const
return number of glyphs
long xMin
Definition TTFhandle.h:37
Int_t GetAscent() const
Definition TTFhandle.h:76
Int_t GetGlyphsHeight() const
Returns height of all glyphs.
std::vector< GlyphStruct > fGlyphs
glyphs
Definition TTFhandle.h:35
long fRotationXY
rotation matrix members
Definition TTFhandle.h:34
long yMin
Definition TTFhandle.h:37
void SetTextFont(Font_t fontnumber)
Set specified font.
Int_t fTBlankW
trailing blanks width
Definition TTFhandle.h:38
Int_t GetTrailingBlanksWidth() const
Definition TTFhandle.h:77
void Version(Int_t &major, Int_t &minor, Int_t &patch)
Int_t GetGlyphsWidth() const
Returns width of all glyphs.
static thread_local FT_Library_Wrapper fFT_Library
Definition TTFhandle.h:48
Bool_t fHinting
use hinting (false by default)
Definition TTFhandle.h:31
void CleanupGlyphs()
Remove temporary data created by LayoutGlyphs.
void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
void ComputeTrailingBlanksWidth(Int_t n)
Compute the trailing blanks width.
void GetTextAdvance(UInt_t &a, const char *text)
Get advance (a) when text is horizontal.
Int_t fWidth
string width, used to compute X alignment
Definition TTFhandle.h:39
void FillTTFGlypths(void *vect)
Fill vector from TTF class Only for backward compatibility of old API.
Bool_t GetSmoothing() const
Definition TTFhandle.h:64
long yMax
boundaries
Definition TTFhandle.h:37
Bool_t GetGlyphData(UInt_t n, Int_t &offx, Int_t &offy, UChar_t *&buffer, UInt_t &width, UInt_t &rows, UInt_t &pitch)
Returns data for glyph bitmap Instead direct access to FT_BitmapGlyph one can obtain all relevant fie...
Bool_t ApplyAlignRotate(Int_t &px, Int_t &py, Int_t align, Int_t pad_width, Int_t pad_height)
Apply align and configured rotation matrix to text position px and py will be shifted to the place wh...
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:607
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:601
Thread-local wrapper to the freetype library.
Definition TTFhandle.cxx:59
FT_Library_Wrapper & operator=(FT_Library_Wrapper const &)=delete
FT_Library_Wrapper & operator=(FT_Library_Wrapper &&)=delete
FT_Library_Wrapper(FT_Library_Wrapper &&)=delete
FT_Library_Wrapper(FT_Library_Wrapper const &)=delete
bool is_symbol() const
Definition TTFhandle.cxx:49
UInt_t fIndex
glyph index in face
Definition TTFhandle.cxx:37
FT_Glyph fImage
glyph image
Definition TTFhandle.cxx:39
FT_Vector fPos
position of glyph origin
Definition TTFhandle.cxx:38
GlyphStruct(UInt_t indx=0)
Definition TTFhandle.cxx:40
TMarker m
Definition textangle.C:8