13 #include "RConfigure.h"
28 # include <FTGL/ftgl.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"
53 fFont(0), fManager(0), fDepth(0),
54 fSize(0), fFile(0), fMode(
kUndef),
63 fFont(f), fManager(mng), fDepth(0),
64 fSize(size), fFile(font), fMode(mode),
73 fFont(0), fManager(0), fDepth(0), fTrashCount(0)
117 return fFont->Ascender();
125 return -
fFont->Descender();
133 return fFont->LineHeight();
142 const char* txt)
const
145 const_cast<FTFont*
>(
fFont)->
BBox(txt, dum, lly, dum, dum, ury, dum);
148 line_height = ury - lly;
159 const_cast<FTFont*
>(
fFont)->
BBox(txt, llx, lly, llz, urx, ury, urz);
170 const_cast<FTFont*
>(
fFont)->
BBox(txt, llx, lly, llz, urx, ury, urz);
184 Float_t llx = 0.f, lly = 0.f, llz = 0.f, urx = 0.f, ury = 0.f, urz = 0.f;
185 BBox(txt, llx, lly, llz, urx, ury, urz);
196 const Double_t dx = urx - llx, dy = ury - lly;
204 if (
gVirtualX->InheritsFrom(
"TGCocoa")) {
263 glTranslated(x, y, 0.);
264 glRotated(angle, 0., 0., 1.);
265 glTranslated(xc, yc, 0.);
266 glTranslated(-0.5 * dx, -0.5 * dy, 0.);
318 glTranslatef(x, y, z);
321 Float_t llx, lly, llz, urx, ury, urz;
322 BBox(txt, llx, lly, llz, urx, ury, urz);
352 glBitmap(0, 0, 0, 0, x, y, 0);
356 glTranslatef(x, y, 0);
371 glPushAttrib(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT);
372 glEnable(GL_ALPHA_TEST);
373 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
374 glAlphaFunc(GL_GEQUAL, 0.0625);
377 glPushAttrib(GL_POLYGON_BIT | GL_ENABLE_BIT);
378 glEnable(GL_TEXTURE_2D);
379 glDisable(GL_CULL_FACE);
380 glEnable(GL_ALPHA_TEST);
381 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
382 glAlphaFunc(GL_GEQUAL, 0.0625);
387 glPushAttrib(GL_POLYGON_BIT | GL_ENABLE_BIT);
388 glEnable(GL_NORMALIZE);
389 glDisable(GL_CULL_FACE);
392 Warning(
"TGLFont::PreRender",
"Font mode undefined.");
393 glPushAttrib(GL_LIGHTING_BIT);
398 glEnable(GL_LIGHTING);
400 glDisable(GL_LIGHTING);
433 delete it->first.GetFont();
455 ttpath =
gEnv->
GetValue(
"Root.TTGLFontPath", TTFFONTDIR );
457 ttpath =
gEnv->
GetValue(
"Root.TTGLFontPath",
"$(ROOTSYS)/fonts");
472 ftfont =
new FTGLBitmapFont(file);
475 ftfont =
new FTGLPixmapFont(file);
478 ftfont =
new FTGLOutlineFont(file);
481 ftfont =
new FTGLPolygonFont(file);
484 ftfont =
new FTGLExtrdFont(file);
485 ftfont->Depth(0.2*size);
488 ftfont =
new FTGLTextureFont(file);
491 Error(
"TGLFontManager::RegisterFont",
"invalid FTGL type");
495 ftfont->FaceSize(size);
496 const TGLFont &mf =
fFontMap.insert(std::make_pair(
TGLFont(size, fileID, mode, ftfont, 0), 1)).first->first;
501 if (it->first.GetTrashCount() > 0) {
503 it->first.SetTrashCount(0);
527 if (cnt < farr->GetEntries())
530 Error(
"TGLFontManager::RegisterFont",
"unknown font name %s", name);
546 assert(it->first.GetTrashCount() == 0);
547 it->first.IncTrashCount();
592 if (idx < 0) idx = 0;
601 if (ds < min) ds =
min;
602 if (ds > max) ds =
max;
613 Int_t fontIndex =
id / 10;
690 for (
Int_t i = 10; i <= 20; i+=2)
692 for (
Int_t i = 24; i <= 64; i+=4)
694 for (
Int_t i = 72; i <= 128; i+=8)
708 if ((*it)->IncTrashCount() > 10000)
713 delete (*it)->GetFont();
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
static const char * GetFontNameFromId(Int_t)
Get font name from TAttAxis font id.
Collectable string class.
void ReleaseFont(TGLFont &font)
Release font with given attributes.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
void CopyAttributes(const TGLFont &o)
Assignment operator.
static void InitStatics()
Create a list of available font files and allowed font sizes.
const char * Data() const
void RegisterFont(Int_t size, Int_t file, TGLFont::EMode mode, TGLFont &out)
Provide font with given size, file and FTGL class.
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.
void Render(const char *txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const
static TObjArray fgFontFileArray
std::vector< Int_t > FontSizeVec_t
static Int_t GetFontSize(Int_t ds)
Get availabe font size.
Float_t GetLineHeight() const
Get font's line-height.
std::list< const TGLFont * >::iterator FontList_i
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TSystem * gSystem
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Float_t GetAscent() const
Get font's ascent.
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.
virtual void PostRender() const
Reset GL state after FTFont rendering.
static Int_t fgExtendedFontStart
Float_t GetDescent() const
Get font's descent. The returned value is positive.
const FTFont * GetFont() const
void Warning(const char *location, const char *msgfmt,...)
std::map< TGLFont, Int_t >::iterator FontMap_i
void SetManager(TGLFontManager *mng)
Int_t GetEntries() const
Return the number of objects in array (i.e.
TGLFontManager * fManager
static Bool_t fgStaticInitDone
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
virtual ~TGLFontManager()
Destructor.
A FreeType GL font manager.
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...
virtual void PreRender(Bool_t autoLight=kTRUE, Bool_t lightOn=kFALSE) const
Set-up GL state before FTFont rendering.
static FontSizeVec_t * GetFontSizeArray()
Get valid font size vector.
static FontSizeVec_t fgFontSizeArray
static TObjArray * GetFontFileArray()
Get id to file name map.
A wrapper class for FTFont.
static Int_t GetExtendedFontStartIndex()
void ClearFontTrash()
Delete FTFFont objects registered for destruction.
virtual ~TGLFont()
Destructor.
Int_t CeilNint(Double_t x)
Long64_t BinarySearch(Long64_t n, const T *array, T value)