Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLFontManager.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Alja Mrak-Tadel 2008
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, 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#include "RConfigure.h"
13#include "TGLFontManager.h"
14
15
16#include "TROOT.h"
17#include "TVirtualX.h"
18#include "TMath.h"
19#include "TSystem.h"
20#include "TEnv.h"
21#include "TObjString.h"
22#include "TGLUtil.h"
23#include "TGLIncludes.h"
24
25// Direct inclusion of FTGL headers is deprecated in ftgl-2.1.3 while
26// ftgl-2.1.2 shipped with ROOT requires manual inclusion.
27#ifndef BUILTIN_FTGL
28# include <FTGL/ftgl.h>
29#else
30# include "FTFont.h"
31# include "FTGLExtrdFont.h"
32# include "FTGLOutlineFont.h"
33# include "FTGLPolygonFont.h"
34# include "FTGLTextureFont.h"
35# include "FTGLPixmapFont.h"
36# include "FTGLBitmapFont.h"
37#endif
38
39namespace {
40#ifdef HAVE_UTF8
41// https://github.com/root-project/root/issues/22076#issuecomment-4342764706
42TString AsUTF8(const char *txt)
43{
45 const auto len = strlen(txt);
46 for (auto i = 0UL; i < len; ++i) {
47 if (static_cast<unsigned char>(txt[i]) >= static_cast<unsigned char>(192)) {
48 utxt.Append(static_cast<unsigned char>(0xc3));
49 utxt.Append(static_cast<unsigned char>(0x80) +
50 (static_cast<unsigned char>(txt[i]) - static_cast<unsigned char>(192)));
51 } else {
52 utxt.Append(txt[i]);
53 }
54 }
55 return utxt;
56}
57#endif
58} // namespace
59
60/** \class TGLFont
61\ingroup opengl
62A wrapper class for FTFont.
63Holds pointer to FTFont object and its description: face size, font file
64and class ID. It wraps Render and BBox functions.
65*/
66
67
68////////////////////////////////////////////////////////////////////////////////
69/// Constructor.
70
72 fFont(0), fManager(0), fDepth(0),
73 fSize(0), fFile(0), fMode(kUndef),
74 fTrashCount(0)
75{
76}
77
78////////////////////////////////////////////////////////////////////////////////
79/// Constructor.
80
82 fFont(f), fManager(mng), fDepth(0),
83 fSize(size), fFile(font), fMode(mode),
84 fTrashCount(0)
85{
86}
87
88////////////////////////////////////////////////////////////////////////////////
89/// Assignment operator.
90
92 fFont(0), fManager(0), fDepth(0), fTrashCount(0)
93{
94 fFont = (FTFont*)o.GetFont();
95
96 fSize = o.fSize;
97 fFile = o.fFile;
98 fMode = o.fMode;
99
101}
102
103////////////////////////////////////////////////////////////////////////////////
104///Destructor
105
107{
108 if (fManager) fManager->ReleaseFont(*this);
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// Assignment operator.
113
115{
116 SetFont(o.fFont);
118
119 SetDepth(o.fDepth);
120
121 fSize = o.fSize;
122 fFile = o.fFile;
123 fMode = o.fMode;
124
126}
127
128
129/******************************************************************************/
130
131////////////////////////////////////////////////////////////////////////////////
132/// Get font's ascent.
133
135{
136 return fFont->Ascender();
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Get font's descent. The returned value is positive.
141
143{
144 return -fFont->Descender();
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Get font's line-height.
149
151{
152 return fFont->LineHeight();
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Measure font's base-line parameters from the passed text.
157/// Note that the measured parameters are not the same as the ones
158/// returned by get-functions - those were set by the font designer.
159
161 const char* txt) const
162{
163#ifdef HAVE_UTF8
165 txt = utxt.Data();
166#endif
167 Float_t dum, lly, ury;
168 const_cast<FTFont*>(fFont)->BBox(txt, dum, lly, dum, dum, ury, dum);
169 ascent = ury;
170 descent = -lly;
171 line_height = ury - lly;
172}
173
174////////////////////////////////////////////////////////////////////////////////
175/// Get bounding box.
176
177void TGLFont::BBox(const char* txt,
179 Float_t& urx, Float_t& ury, Float_t& urz) const
180{
181 // HAVE_UTF8 was already called by functions above BBox so no need to transform here
182 // FTGL is not const correct.
183 const_cast<FTFont*>(fFont)->BBox(txt, llx, lly, llz, urx, ury, urz);
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Get bounding box.
188
189void TGLFont::BBox(const wchar_t* txt,
191 Float_t& urx, Float_t& ury, Float_t& urz) const
192{
193 // HAVE_UTF8 was already called by functions above BBox so no need to transform here
194 // FTGL is not const correct.
195 const_cast<FTFont*>(fFont)->BBox(txt, llx, lly, llz, urx, ury, urz);
196}
197
198////////////////////////////////////////////////////////////////////////////////
199/// Get advance
200
201Float_t TGLFont::Advance(const char* txt) const
202{
203#ifdef HAVE_UTF8
205 txt = utxt.Data();
206#endif
207 // FTGL is not const correct.
208 return const_cast<FTFont*>(fFont)->Advance(txt);
209}
210
211////////////////////////////////////////////////////////////////////////////////
212///mgn is simply ignored, because ROOT's TVirtualX TGX11 are complete mess with
213///painting attributes.
214
215template<class Char>
217{
218 // no need to check HAVE_UTF8 here, since it was called by functions above it
219
220 glPushMatrix();
221 //glLoadIdentity();
222
223 // FTGL is not const correct.
224 Float_t llx = 0.f, lly = 0.f, llz = 0.f, urx = 0.f, ury = 0.f, urz = 0.f;
225 BBox(txt, llx, lly, llz, urx, ury, urz);
226
227 /*
228 V\H | left | center | right
229 _______________________________
230 bottom | 7 | 8 | 9
231 _______________________________
232 center | 4 | 5 | 6
233 _______________________________
234 top | 1 | 2 | 3
235 */
236 const Double_t dx = urx - llx, dy = ury - lly;
237 Double_t xc = 0., yc = 0.;
238
239 // if align was not set before - use value from gVirtualX
240 const UInt_t align = fTextAlign ? fTextAlign : gVirtualX->GetTextAlign();
241
242 //Timur: Here's the nice X11 bullshido: you call gVirtualX->SetTextAlign(11),
243 //later gVirtualX->GetTextAling() will give you 7. Brilliant!
244 //But with Cocoa you'll have 11. As it should be, of course.
245 //Sergey: problem with gVirtualX solved, now all platforms works same way
246
247 const UInt_t hAlign = UInt_t(align / 10);
248 const UInt_t vAlign = UInt_t(align % 10);
249 switch (hAlign) {
250 case 1:
251 xc = 0.5 * dx;
252 break;
253 case 2:
254 break;
255 case 3:
256 xc = -0.5 * dy;
257 break;
258 }
259
260 switch (vAlign) {
261 case 1:
262 yc = 0.5 * dy;
263 break;
264 case 2:
265 break;
266 case 3:
267 yc = -0.5 * dy;
268 break;
269 }
270
271 glTranslated(x, y, 0.);
272 glRotated(angle, 0., 0., 1.);
273 glTranslated(xc, yc, 0.);
274 glTranslated(-0.5 * dx, -0.5 * dy, 0.);
275 //glScaled(mgn, mgn, 1.);
276
277 const_cast<FTFont*>(fFont)->Render(txt);
278
279 glPopMatrix();
280}
281
282////////////////////////////////////////////////////////////////////////////////
283
285{
286 // TODO handle UTF8
288}
289
290////////////////////////////////////////////////////////////////////////////////
291
293{
294#ifdef HAVE_UTF8
296 txt = utxt.Data();
297#endif
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// Render text.
303
304void TGLFont::Render(const TString &txt) const
305{
306 Bool_t scaleDepth = (fMode == kExtrude && fDepth != 1.0f);
307
308 if (scaleDepth) {
309 glPushMatrix();
310 // !!! 0.2*fSize is hard-coded in TGLFontManager::GetFont(), too.
311 glTranslatef(0.0f, 0.0f, 0.5f*fDepth * 0.2f*fSize);
312 glScalef(1.0f, 1.0f, fDepth);
313 }
314
315#ifdef HAVE_UTF8
317 // FTGL is not const correct.
318 const_cast<FTFont *>(fFont)->Render(utxt.Data());
319#else
320 // FTGL is not const correct.
321 const_cast<FTFont *>(fFont)->Render(txt.Data());
322#endif
323
324 if (scaleDepth) {
325 glPopMatrix();
326 }
327}
328
329////////////////////////////////////////////////////////////////////////////////
330/// Render text with given alignmentrepl and at given position.
331
333 ETextAlignV_e alignV) const
334{
335 glPushMatrix();
336
337 glTranslatef(x, y, z);
338
339 x=0, y=0;
340 Float_t llx, lly, llz, urx, ury, urz;
341
342#ifdef HAVE_UTF8
344 BBox(utxt.Data(), llx, lly, llz, urx, ury, urz);
345#else
346 BBox(txt.Data(), llx, lly, llz, urx, ury, urz);
347#endif
348
349 switch (alignH)
350 {
351 case TGLFont::kRight:
352 x = -urx;
353 break;
354
356 x = -urx*0.5;
357 break;
358 default:
359 break;
360 };
361
362 switch (alignV)
363 {
364 case TGLFont::kBottom:
365 y = -ury;
366 break;
368 y = -ury*0.5;
369 break;
370 default:
371 break;
372 };
373
375 {
376 glRasterPos2i(0, 0);
377 glBitmap(0, 0, 0, 0, x, y, 0);
378 }
379 else
380 {
381 glTranslatef(x, y, 0);
382 }
383
384 Bool_t scaleDepth = (fMode == kExtrude && fDepth != 1.0f);
385
386 if (scaleDepth) {
387 glPushMatrix();
388 // !!! 0.2*fSize is hard-coded in TGLFontManager::GetFont(), too.
389 glTranslatef(0.0f, 0.0f, 0.5f * fDepth * 0.2f * fSize);
390 glScalef(1.0f, 1.0f, fDepth);
391 }
392
393#ifdef HAVE_UTF8
394 // FTGL is not const correct.
395 const_cast<FTFont *>(fFont)->Render(utxt.Data());
396#else
397 // FTGL is not const correct.
398 const_cast<FTFont *>(fFont)->Render(txt.Data());
399#endif
400
401 if (scaleDepth) {
402 glPopMatrix();
403 }
404 glPopMatrix();
405}
406
407////////////////////////////////////////////////////////////////////////////////
408/// Set-up GL state before FTFont rendering.
409
411{
412 switch (fMode)
413 {
414 case kBitmap:
415 case kPixmap:
419 glAlphaFunc(GL_GEQUAL, 0.0625);
420 break;
421 case kTexture:
427 glAlphaFunc(GL_GEQUAL, 0.0625);
428 break;
429 case kOutline:
430 case kPolygon:
431 case kExtrude:
435 break;
436 default:
437 Warning("TGLFont::PreRender", "Font mode undefined.");
439 break;
440 }
441
444 else
446}
447
448////////////////////////////////////////////////////////////////////////////////
449/// Reset GL state after FTFont rendering.
450
452{
453 glPopAttrib();
454}
455
456/** \class TGLFontManager
457\ingroup opengl
458A FreeType GL font manager.
459
460Each GL rendering context has an instance of FTGLManager.
461This enables FTGL fonts to be shared same way as textures and display lists.
462*/
463
464
469
470////////////////////////////////////////////////////////////////////////////////
471/// Destructor.
472
474{
475 FontMap_i it = fFontMap.begin();
476 while (it != fFontMap.end()) {
477 delete it->first.GetFont();
478 it++;
479 }
480 fFontMap.clear();
481}
482
483////////////////////////////////////////////////////////////////////////////////
484/// Provide font with given size, file and FTGL class.
485
487{
489 InitStatics();
490
492 if (mode == out.GetMode() && fileID == out.GetFile() && size == out.GetSize())
493 return;
494
496 if (it == fFontMap.end())
497 {
498 TString ttpath = gEnv->GetValue("Root.TTGLFontPath", TROOT::GetTTFFontDir());
499 TString file = fgFontFileArray[fileID]->GetName();
501 file += ".ttf";
502 gSystem->FindFile(ttpath, file);
503 if (file.IsNull()) {
504 Error("RegisterFont", "File for font id %d not found", fileID);
505 return;
506 }
507
508 FTFont* ftfont = nullptr;
509 switch (mode)
510 {
511 case TGLFont::kBitmap:
512 ftfont = new FTGLBitmapFont(file);
513 break;
514 case TGLFont::kPixmap:
515 ftfont = new FTGLPixmapFont(file);
516 break;
518 ftfont = new FTGLOutlineFont(file);
519 break;
521 ftfont = new FTGLPolygonFont(file);
522 break;
524 ftfont = new FTGLExtrdFont(file);
525 ftfont->Depth(0.2*size);
526 break;
528 ftfont = new FTGLTextureFont(file);
529 break;
530 default:
531 Error("RegisterFont", "invalid FTGL type");
532 return;
533 }
534 ftfont->FaceSize(size);
535 const TGLFont &mf = fFontMap.insert(std::make_pair(TGLFont(size, fileID, mode, ftfont, 0), 1)).first->first;
536 out.CopyAttributes(mf);
537 }
538 else
539 {
540 if (it->first.GetTrashCount() > 0) {
541 fFontTrash.remove(&(it->first));
542 it->first.SetTrashCount(0);
543 }
544 ++(it->second);
545 out.CopyAttributes(it->first);
546 }
547 out.SetManager(this);
548}
549
550////////////////////////////////////////////////////////////////////////////////
551/// Get mapping from ttf id to font names. Table taken from TTF.cxx.
552
554{
556 TIter next(farr);
557 TObjString* os;
558 Int_t cnt = 0;
559 while ((os = (TObjString*) next()) != 0)
560 {
561 if (os->String() == name)
562 break;
563 cnt++;
564 }
565
566 if (cnt < farr->GetEntries())
567 RegisterFont(size, cnt, mode, out);
568 else
569 Error("TGLFontManager::RegisterFont", "unknown font name %s", name);
570}
571
572////////////////////////////////////////////////////////////////////////////////
573/// Release font with given attributes. Returns false if font has
574/// not been found in the managers font set.
575
577{
578 FontMap_i it = fFontMap.find(font);
579
580 if (it != fFontMap.end())
581 {
582 --(it->second);
583 if (it->second == 0)
584 {
585 assert(it->first.GetTrashCount() == 0);
586 it->first.IncTrashCount();
587 fFontTrash.push_back(&it->first);
588 }
589 }
590}
591
592////////////////////////////////////////////////////////////////////////////////
593/// Get id to file name map.
594
600
601////////////////////////////////////////////////////////////////////////////////
602/// Get valid font size vector.
603
609
610////////////////////////////////////////////////////////////////////////////////
611
613{
615
616 assert(fgExtendedFontStart > 0 && "GetExtendedFontStartIndex, invalid index");
617
618 return fgExtendedFontStart;
619}
620
621////////////////////////////////////////////////////////////////////////////////
622/// Get availabe font size.
623
625{
627
630
631 if (idx < 0) idx = 0;
632 return fgFontSizeArray[idx];
633}
634
635////////////////////////////////////////////////////////////////////////////////
636/// Get availabe font size.
637
639{
640 if (ds < min) ds = min;
641 if (ds > max) ds = max;
642 return GetFontSize(ds);
643}
644
645////////////////////////////////////////////////////////////////////////////////
646/// Get font name from TAttAxis font id.
647
649{
651
652 Int_t fontIndex = id / 10;
653
654 if (fontIndex > fgFontFileArray.GetEntries() || !fontIndex)
655 fontIndex = 5;//arialbd
656 else
657 fontIndex -= 1;
658
660 return os->String().Data();
661}
662
663////////////////////////////////////////////////////////////////////////////////
664/// Create a list of available font files and allowed font sizes.
665
667{
668 fgFontFileArray.Add(new TObjString("timesi")); // 10
669 fgFontFileArray.Add(new TObjString("timesbd")); // 20
670 fgFontFileArray.Add(new TObjString("timesbi")); // 30
671
672 fgFontFileArray.Add(new TObjString("arial")); // 40
673 fgFontFileArray.Add(new TObjString("ariali")); // 50
674 fgFontFileArray.Add(new TObjString("arialbd")); // 60
675 fgFontFileArray.Add(new TObjString("arialbi")); // 70
676
677 fgFontFileArray.Add(new TObjString("cour")); // 80
678 fgFontFileArray.Add(new TObjString("couri")); // 90
679 fgFontFileArray.Add(new TObjString("courbd")); // 100
680 fgFontFileArray.Add(new TObjString("courbi")); // 110
681
682 fgFontFileArray.Add(new TObjString("symbol")); // 120
683 fgFontFileArray.Add(new TObjString("times")); // 130
684 fgFontFileArray.Add(new TObjString("wingding")); // 140
685 fgFontFileArray.Add(new TObjString("symbol")); // 150
686
688 //"Extended" fonts for gl-pad.
689 //fgPadFontStart + ...
690 fgFontFileArray.Add(new TObjString("FreeSerifItalic.otf")); // 10 (160)
691 fgFontFileArray.Add(new TObjString("FreeSerifBold.otf")); // 20 (170)
692 fgFontFileArray.Add(new TObjString("FreeSerifBoldItalic.otf")); // 30
693
694 fgFontFileArray.Add(new TObjString("FreeSans.otf")); // 40
695 fgFontFileArray.Add(new TObjString("FreeSansOblique.otf")); // 50
696 fgFontFileArray.Add(new TObjString("FreeSansBold.otf")); // 60
697 fgFontFileArray.Add(new TObjString("FreeSansBoldOblique.otf")); // 70
698
699 fgFontFileArray.Add(new TObjString("FreeMono.otf")); // 80
700 fgFontFileArray.Add(new TObjString("FreeMonoOblique.otf")); // 90
701 fgFontFileArray.Add(new TObjString("FreeMonoBold.otf")); // 100
702 fgFontFileArray.Add(new TObjString("FreeMonoBoldOblique.otf")); // 110
703
704 fgFontFileArray.Add(new TObjString("symbol.ttf")); // 120
705 fgFontFileArray.Add(new TObjString("FreeSerif.otf")); // 130
706 fgFontFileArray.Add(new TObjString("wingding.ttf")); // 140
707 fgFontFileArray.Add(new TObjString("symbol.ttf")); // 150
708
709 fgFontFileArray.Add(new TObjString("STIXGeneral.otf")); // 200
710 fgFontFileArray.Add(new TObjString("STIXGeneralItalic.otf")); // 210
711 fgFontFileArray.Add(new TObjString("STIXGeneralBol.otf")); // 220
712 fgFontFileArray.Add(new TObjString("STIXGeneralBolIta.otf")); // 230
713
714 fgFontFileArray.Add(new TObjString("STIXSiz1Sym.otf")); // 240
715 fgFontFileArray.Add(new TObjString("STIXSiz1SymBol.otf")); // 250
716 fgFontFileArray.Add(new TObjString("STIXSiz2Sym.otf")); // 260
717 fgFontFileArray.Add(new TObjString("STIXSiz2SymBol.otf")); // 270
718
719 fgFontFileArray.Add(new TObjString("STIXSiz3Sym.otf")); // 280
720 fgFontFileArray.Add(new TObjString("STIXSiz3SymBol.otf")); // 290
721 fgFontFileArray.Add(new TObjString("STIXSiz4Sym.otf")); // 300
722 fgFontFileArray.Add(new TObjString("STIXSiz4SymBol.otf")); // 310
723
724 fgFontFileArray.Add(new TObjString("STIXSiz5Sym.otf")); // 320
725 fgFontFileArray.Add(new TObjString("DroidSansFallback.ttf")); // 330
726 fgFontFileArray.Add(new TObjString("DroidSansFallback.ttf")); // 340
727 fgFontFileArray.Add(new TObjString("DroidSansFallback.ttf")); // 350
728
729 for (Int_t i = 10; i <= 20; i+=2)
730 fgFontSizeArray.push_back(i);
731 for (Int_t i = 24; i <= 64; i+=4)
732 fgFontSizeArray.push_back(i);
733 for (Int_t i = 72; i <= 128; i+=8)
734 fgFontSizeArray.push_back(i);
735
737}
738
739////////////////////////////////////////////////////////////////////////////////
740/// Delete FTFFont objects registered for destruction.
741
743{
744 FontList_i it = fFontTrash.begin();
745 while (it != fFontTrash.end())
746 {
747 if ((*it)->IncTrashCount() > 10000)
748 {
749 FontMap_i mi = fFontMap.find(**it);
750 assert(mi != fFontMap.end());
751 fFontMap.erase(mi);
752 delete (*it)->GetFont();
753
754 FontList_i li = it++;
755 fFontTrash.erase(li);
756 }
757 else
758 {
759 ++it;
760 }
761 }
762}
dim_t fSize
#define f(i)
Definition RSha256.hxx:104
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
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
Option_t Option_t mgn
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 Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:148
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define gVirtualX
Definition TVirtualX.h:375
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:503
A FreeType GL font manager.
virtual ~TGLFontManager()
Destructor.
static TObjArray fgFontFileArray
void RegisterFont(Int_t size, Int_t file, TGLFont::EMode mode, TGLFont &out)
Provide font with given size, file and FTGL class.
static Int_t GetFontSize(Int_t ds)
Get availabe font size.
static void InitStatics()
Create a list of available font files and allowed font sizes.
static Int_t GetExtendedFontStartIndex()
static Bool_t fgStaticInitDone
static FontSizeVec_t fgFontSizeArray
static Int_t fgExtendedFontStart
static FontSizeVec_t * GetFontSizeArray()
Get valid font size vector.
std::list< constTGLFont * >::iterator FontList_i
void ClearFontTrash()
Delete FTFFont objects registered for destruction.
std::map< TGLFont, Int_t >::iterator FontMap_i
std::vector< Int_t > FontSizeVec_t
static const char * GetFontNameFromId(Int_t)
Get font name from TAttAxis font id.
static TObjArray * GetFontFileArray()
Get id to file name map.
void ReleaseFont(TGLFont &font)
Release font with given attributes.
FontList_t fFontTrash
A wrapper class for FTFont.
void MeasureBaseLineParams(Float_t &ascent, Float_t &descent, Float_t &line_height, const char *txt="Xj") const
Measure font's base-line parameters from the passed text.
Float_t GetDescent() const
Get font's descent. The returned value is positive.
virtual ~TGLFont()
Destructor.
Float_t GetAscent() const
Get font's ascent.
EMode GetMode() const
void SetManager(TGLFontManager *mng)
void SetFont(FTFont *f)
Float_t GetLineHeight() const
Get font's line-height.
EMode fMode
Float_t Advance(const char *txt) const
Get advance.
Int_t GetSize() const
const FTFont * GetFont() const
void RenderHelper(const Char *txt, Double_t x, Double_t y, Double_t angle, Double_t) const
mgn is simply ignored, because ROOT's TVirtualX TGX11 are complete mess with painting attributes.
FTFont * fFont
TGLFontManager * fManager
Int_t GetFile() const
UInt_t fTextAlign
void BBox(const char *txt, Float_t &llx, Float_t &lly, Float_t &llz, Float_t &urx, Float_t &ury, Float_t &urz) const
Get bounding box.
Int_t fTrashCount
Float_t fDepth
void Render(const char *txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const
virtual void PostRender() const
Reset GL state after FTFont rendering.
void SetDepth(Float_t d)
virtual void PreRender(Bool_t autoLight=kTRUE, Bool_t lightOn=kFALSE) const
Set-up GL state before FTFont rendering.
Int_t fSize
TGLFont()
Constructor.
void CopyAttributes(const TGLFont &o)
Assignment operator.
Int_t fFile
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
TString & String()
Definition TObjString.h:48
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
const char * Data() const
Definition TString.h:384
Bool_t IsNull() const
Definition TString.h:422
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1553
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Int_t CeilNint(Double_t x)
Returns the nearest integer of TMath::Ceil(x).
Definition TMath.h:685
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Definition TMathBase.h:329