13 #include "RConfigure.h"    29 # include <FTGL/ftgl.h>    32 # include "FTGLExtrdFont.h"    33 # include "FTGLOutlineFont.h"    34 # include "FTGLPolygonFont.h"    35 # include "FTGLTextureFont.h"    36 # include "FTGLPixmapFont.h"    37 # include "FTGLBitmapFont.h"    54    fFont(0), fManager(0), fDepth(0),
    55    fSize(0), fFile(0), fMode(
kUndef),
   118    return fFont->Ascender();
   126    return -
fFont->Descender();
   134    return fFont->LineHeight();
   143                                     const char* txt)
 const   146    const_cast<FTFont*
>(
fFont)->
BBox(txt, dum, lly, dum, dum, ury, dum);
   149    line_height =  ury - lly;
   160    const_cast<FTFont*
>(
fFont)->
BBox(txt, llx, lly, llz, urx, ury, urz);
   171    const_cast<FTFont*
>(
fFont)->
BBox(txt, llx, lly, llz, urx, ury, urz);
   185    Float_t llx = 0.f, lly = 0.f, llz = 0.f, urx = 0.f, ury = 0.f, urz = 0.f;
   186    BBox(txt, llx, lly, llz, urx, ury, urz);
   197    const Double_t dx = urx - llx, dy = ury - lly;
   205    if (
gVirtualX->InheritsFrom(
"TGCocoa")) {
   264    glTranslated(x, y, 0.);
   265    glRotated(angle, 0., 0., 1.);
   266    glTranslated(xc, yc, 0.);
   267    glTranslated(-0.5 * dx, -0.5 * dy, 0.);
   299       glTranslatef(0.0f, 0.0f, 0.5f*
fDepth * 0.2f*
fSize);
   300       glScalef(1.0f, 1.0f, 
fDepth);
   319    glTranslatef(x, y, z);
   322    Float_t llx, lly, llz, urx, ury, urz;
   323    BBox(txt, llx, lly, llz, urx, ury, urz);
   353       glBitmap(0, 0, 0, 0, x, y, 0);
   357       glTranslatef(x, y, 0);
   372          glPushAttrib(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT);
   373          glEnable(GL_ALPHA_TEST);
   374          glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   375          glAlphaFunc(GL_GEQUAL, 0.0625);
   378          glPushAttrib(GL_POLYGON_BIT | GL_ENABLE_BIT);
   379          glEnable(GL_TEXTURE_2D);
   380          glDisable(GL_CULL_FACE);
   381          glEnable(GL_ALPHA_TEST);
   382          glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   383          glAlphaFunc(GL_GEQUAL, 0.0625);
   388          glPushAttrib(GL_POLYGON_BIT | GL_ENABLE_BIT);
   389          glEnable(GL_NORMALIZE);
   390          glDisable(GL_CULL_FACE);
   393          Warning(
"TGLFont::PreRender", 
"Font mode undefined.");
   394          glPushAttrib(GL_LIGHTING_BIT);
   399       glEnable(GL_LIGHTING);
   401       glDisable(GL_LIGHTING);
   433    while (it != fFontMap.end()) {
   434       delete it->first.GetFont();
   445    if (fgStaticInitDone == 
kFALSE) InitStatics();
   447    Int_t  size = GetFontSize(sizeIn);
   452    if (it == fFontMap.end())
   458          char *fp = 
gSystem->
Which(ttpath, fileID < fgExtendedFontStart ?
   469             ftfont = 
new FTGLBitmapFont(file);
   472             ftfont = 
new FTGLPixmapFont(file);
   475             ftfont = 
new FTGLOutlineFont(file);
   478             ftfont = 
new FTGLPolygonFont(file);
   481             ftfont = 
new FTGLExtrdFont(file);
   482             ftfont->Depth(0.2*size);
   485             ftfont = 
new FTGLTextureFont(file);
   488             Error(
"TGLFontManager::RegisterFont", 
"invalid FTGL type");
   492       ftfont->FaceSize(size);
   493       const TGLFont &mf = fFontMap.insert(std::make_pair(
TGLFont(size, fileID, mode, ftfont, 0), 1)).first->first;
   498       if (it->first.GetTrashCount() > 0) {
   499          fFontTrash.remove(&(it->first));
   500          it->first.SetTrashCount(0);
   524    if (cnt < farr->GetEntries())
   525       RegisterFont(size, cnt, mode, out);
   527       Error(
"TGLFontManager::RegisterFont", 
"unknown font name %s", name);
   538    if (it != fFontMap.end())
   543          assert(it->first.GetTrashCount() == 0);
   544          it->first.IncTrashCount();
   545          fFontTrash.push_back(&it->first);
   555    if (fgStaticInitDone == 
kFALSE) InitStatics();
   556    return &fgFontFileArray;
   564    if (fgStaticInitDone == 
kFALSE) InitStatics();
   565    return &fgFontSizeArray;
   572    if (fgStaticInitDone == 
kFALSE) InitStatics();
   574    assert(fgExtendedFontStart > 0 && 
"GetExtendedFontStartIndex, invalid index");
   576    return fgExtendedFontStart;
   584    if (fgStaticInitDone == 
kFALSE) InitStatics();
   589    if (idx < 0) idx = 0;
   590    return fgFontSizeArray[idx];
   598    if (ds < min) ds = min;
   599    if (ds > max) ds = max;
   600    return GetFontSize(ds);
   608    if (fgStaticInitDone == 
kFALSE) InitStatics();
   610    Int_t fontIndex = 
id / 10;
   612    if (fontIndex > fgFontFileArray.GetEntries() || !fontIndex)
   626    fgFontFileArray.Add(
new TObjString(
"timesi"));   
   627    fgFontFileArray.Add(
new TObjString(
"timesbd"));  
   628    fgFontFileArray.Add(
new TObjString(
"timesbi"));  
   631    fgFontFileArray.Add(
new TObjString(
"ariali"));   
   632    fgFontFileArray.Add(
new TObjString(
"arialbd"));  
   633    fgFontFileArray.Add(
new TObjString(
"arialbi"));  
   637    fgFontFileArray.Add(
new TObjString(
"courbd"));   
   638    fgFontFileArray.Add(
new TObjString(
"courbi"));   
   640    fgFontFileArray.Add(
new TObjString(
"symbol"));   
   642    fgFontFileArray.Add(
new TObjString(
"wingding")); 
   643    fgFontFileArray.Add(
new TObjString(
"symbol"));   
   645    fgExtendedFontStart = fgFontFileArray.GetEntries();
   648    fgFontFileArray.Add(
new TObjString(
"FreeSerifItalic.otf"));      
   649    fgFontFileArray.Add(
new TObjString(
"FreeSerifBold.otf"));        
   650    fgFontFileArray.Add(
new TObjString(
"FreeSerifBoldItalic.otf"));  
   652    fgFontFileArray.Add(
new TObjString(
"FreeSans.otf"));             
   653    fgFontFileArray.Add(
new TObjString(
"FreeSansOblique.otf"));      
   654    fgFontFileArray.Add(
new TObjString(
"FreeSansBold.otf"));         
   655    fgFontFileArray.Add(
new TObjString(
"FreeSansBoldOblique.otf"));  
   657    fgFontFileArray.Add(
new TObjString(
"FreeMono.otf"));             
   658    fgFontFileArray.Add(
new TObjString(
"FreeMonoOblique.otf"));      
   659    fgFontFileArray.Add(
new TObjString(
"FreeMonoBold.otf"));         
   660    fgFontFileArray.Add(
new TObjString(
"FreeMonoBoldOblique.otf"));  
   662    fgFontFileArray.Add(
new TObjString(
"symbol.ttf"));               
   663    fgFontFileArray.Add(
new TObjString(
"FreeSerif.otf"));            
   664    fgFontFileArray.Add(
new TObjString(
"wingding.ttf"));             
   665    fgFontFileArray.Add(
new TObjString(
"symbol.ttf"));               
   667    fgFontFileArray.Add(
new TObjString(
"STIXGeneral.otf"));          
   668    fgFontFileArray.Add(
new TObjString(
"STIXGeneralItalic.otf"));    
   669    fgFontFileArray.Add(
new TObjString(
"STIXGeneralBol.otf"));       
   670    fgFontFileArray.Add(
new TObjString(
"STIXGeneralBolIta.otf"));    
   672    fgFontFileArray.Add(
new TObjString(
"STIXSiz1Sym.otf"));          
   673    fgFontFileArray.Add(
new TObjString(
"STIXSiz1SymBol.otf"));       
   674    fgFontFileArray.Add(
new TObjString(
"STIXSiz2Sym.otf"));          
   675    fgFontFileArray.Add(
new TObjString(
"STIXSiz2SymBol.otf"));       
   677    fgFontFileArray.Add(
new TObjString(
"STIXSiz3Sym.otf"));          
   678    fgFontFileArray.Add(
new TObjString(
"STIXSiz3SymBol.otf"));       
   679    fgFontFileArray.Add(
new TObjString(
"STIXSiz4Sym.otf"));          
   680    fgFontFileArray.Add(
new TObjString(
"STIXSiz4SymBol.otf"));       
   682    fgFontFileArray.Add(
new TObjString(
"STIXSiz5Sym.otf"));          
   683    fgFontFileArray.Add(
new TObjString(
"DroidSansFallback.ttf"));    
   684    fgFontFileArray.Add(
new TObjString(
"DroidSansFallback.ttf"));    
   685    fgFontFileArray.Add(
new TObjString(
"DroidSansFallback.ttf"));    
   687    for (
Int_t i = 10; i <= 20; i+=2)
   688       fgFontSizeArray.push_back(i);
   689    for (
Int_t i = 24; i <= 64; i+=4)
   690       fgFontSizeArray.push_back(i);
   691    for (
Int_t i = 72; i <= 128; i+=8)
   692       fgFontSizeArray.push_back(i);
   694    fgStaticInitDone = 
kTRUE;
   703    while (it != fFontTrash.end())
   705       if ((*it)->IncTrashCount() > 10000)
   708          assert(mi != fFontMap.end());
   710          delete (*it)->GetFont();
   713          fFontTrash.erase(li);
 
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function. 
Float_t GetAscent() const
Get font's ascent. 
virtual void PreRender(Bool_t autoLight=kTRUE, Bool_t lightOn=kFALSE) const
Set-up GL state before FTFont rendering. 
void Render(const char *txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const
static const char * GetFontNameFromId(Int_t)
Get font name from TAttAxis font id. 
Collectable string 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 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. 
void RegisterFont(Int_t size, Int_t file, TGLFont::EMode mode, TGLFont &out)
Provide font with given size, file and FTGL class. 
static TObjArray fgFontFileArray
std::vector< Int_t > FontSizeVec_t
static Int_t GetFontSize(Int_t ds)
Get availabe font size. 
std::list< const TGLFont * >::iterator FontList_i
void Error(const char *location, const char *msgfmt,...)
Float_t GetDescent() const
Get font's descent. The returned value is positive. 
R__EXTERN TSystem * gSystem
static Int_t fgExtendedFontStart
void Warning(const char *location, const char *msgfmt,...)
Float_t GetLineHeight() const
Get font's line-height. 
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...
std::map< TGLFont, Int_t >::iterator FontMap_i
void SetManager(TGLFontManager *mng)
const FTFont * GetFont() const
TGLFontManager * fManager
static Bool_t fgStaticInitDone
virtual ~TGLFontManager()
Destructor. 
you should not use this method at all Int_t Int_t z
virtual void PostRender() const
Reset GL state after FTFont rendering. 
A FreeType GL font manager. 
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 Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource. 
virtual ~TGLFont()
Destructor. 
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. 
Int_t CeilNint(Double_t x)
Long64_t BinarySearch(Long64_t n, const T *array, T value)
const char * Data() const