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