12#include "RConfigure.h"
23#include "TGLIncludes.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"
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)));
136 return fFont->Ascender();
144 return -
fFont->Descender();
152 return fFont->LineHeight();
161 const char* txt)
const
168 const_cast<FTFont*
>(
fFont)->
BBox(txt, dum, lly, dum, dum, ury, dum);
171 line_height = ury - lly;
183 const_cast<FTFont*
>(
fFont)->
BBox(txt, llx, lly, llz, urx, ury, urz);
195 const_cast<FTFont*
>(
fFont)->
BBox(txt, llx, lly, llz, urx, ury, urz);
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);
236 const Double_t dx = urx - llx, dy = ury - lly;
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.);
311 glTranslatef(0.0f, 0.0f, 0.5f*
fDepth * 0.2f*
fSize);
312 glScalef(1.0f, 1.0f,
fDepth);
337 glTranslatef(
x,
y, z);
340 Float_t llx, lly, llz, urx, ury, urz;
344 BBox(utxt.
Data(), llx, lly, llz, urx, ury, urz);
346 BBox(txt.
Data(), llx, lly, llz, urx, ury, urz);
377 glBitmap(0, 0, 0, 0,
x,
y, 0);
381 glTranslatef(
x,
y, 0);
389 glTranslatef(0.0f, 0.0f, 0.5f *
fDepth * 0.2f *
fSize);
390 glScalef(1.0f, 1.0f,
fDepth);
416 glPushAttrib(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT);
417 glEnable(GL_ALPHA_TEST);
418 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
419 glAlphaFunc(GL_GEQUAL, 0.0625);
422 glPushAttrib(GL_POLYGON_BIT | GL_ENABLE_BIT);
423 glEnable(GL_TEXTURE_2D);
424 glDisable(GL_CULL_FACE);
425 glEnable(GL_ALPHA_TEST);
426 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
427 glAlphaFunc(GL_GEQUAL, 0.0625);
432 glPushAttrib(GL_POLYGON_BIT | GL_ENABLE_BIT);
433 glEnable(GL_NORMALIZE);
434 glDisable(GL_CULL_FACE);
437 Warning(
"TGLFont::PreRender",
"Font mode undefined.");
438 glPushAttrib(GL_LIGHTING_BIT);
443 glEnable(GL_LIGHTING);
445 glDisable(GL_LIGHTING);
477 delete it->first.GetFont();
498 TString ttpath =
gEnv->GetValue(
"Root.TTGLFontPath", TROOT::GetTTFFontDir());
502 gSystem->FindFile(ttpath, file);
504 Error(
"RegisterFont",
"File for font id %d not found", fileID);
508 FTFont* ftfont =
nullptr;
512 ftfont =
new FTGLBitmapFont(file);
515 ftfont =
new FTGLPixmapFont(file);
518 ftfont =
new FTGLOutlineFont(file);
521 ftfont =
new FTGLPolygonFont(file);
524 ftfont =
new FTGLExtrdFont(file);
525 ftfont->Depth(0.2*
size);
528 ftfont =
new FTGLTextureFont(file);
531 Error(
"RegisterFont",
"invalid FTGL type");
534 ftfont->FaceSize(
size);
540 if (it->first.GetTrashCount() > 0) {
542 it->first.SetTrashCount(0);
566 if (cnt < farr->GetEntries())
569 Error(
"TGLFontManager::RegisterFont",
"unknown font name %s",
name);
585 assert(it->first.GetTrashCount() == 0);
586 it->first.IncTrashCount();
631 if (idx < 0) idx = 0;
640 if (ds < min) ds = min;
641 if (ds > max) ds = max;
652 Int_t fontIndex =
id / 10;
729 for (
Int_t i = 10; i <= 20; i+=2)
731 for (
Int_t i = 24; i <= 64; i+=4)
733 for (
Int_t i = 72; i <= 128; i+=8)
747 if ((*it)->IncTrashCount() > 10000)
752 delete (*it)->GetFont();
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
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.
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.
void SetManager(TGLFontManager *mng)
Float_t GetLineHeight() const
Get font's line-height.
Float_t Advance(const char *txt) const
Get advance.
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.
TGLFontManager * fManager
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
virtual void PostRender() const
Reset GL state after FTFont rendering.
virtual void PreRender(Bool_t autoLight=kTRUE, Bool_t lightOn=kFALSE) const
Set-up GL state before FTFont rendering.
void CopyAttributes(const TGLFont &o)
Assignment operator.
Collectable string class.
const char * Data() const
TString & Append(const char *cs)
Int_t CeilNint(Double_t x)
Returns the nearest integer of TMath::Ceil(x).
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.