45 return (
name ==
"wingding.ttf") || (
name.find(
"symbol.ttf") == 0);
74 Error(
"TTFhandle::InitClose",
"error initializing FreeType");
96 Int_t n = face->num_charmaps;
97 for (
Int_t i = 0; i <
n; i++) {
98 FT_CharMap charmap = face->charmaps[i];
99 auto platform = charmap->platform_id;
100 auto encoding = charmap->encoding_id;
101 if ((
platform == 3 && encoding == 1) ||
107 Error(
"TTF::CharToUnicode",
"error in FT_Set_CharMap");
226 glyph.fImage =
nullptr;
238 fWidth += face->glyph->advance.x;
249 if (bbox.xMin <
fCBox.xMin)
fCBox.xMin = bbox.xMin;
250 if (bbox.yMin <
fCBox.yMin)
fCBox.yMin = bbox.yMin;
251 if (bbox.xMax >
fCBox.xMax)
fCBox.xMax = bbox.xMax;
252 if (bbox.yMax >
fCBox.yMax)
fCBox.yMax = bbox.yMax;
281 glyph.fImage =
nullptr;
294 const unsigned char *
p = (
const unsigned char*)
string;
323 const wchar_t *
p = string;
355#if defined(FREETYPE_PATCH) && \
356 (FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 1) && (FREETYPE_PATCH == 2)
378 thread_local std::map<std::string, TTFontHandle>
_fonts;
387 return fFont ? 0 : 1;
393 fFont = &iter->second;
403 for (
auto &font :
_fonts) {
404 if (font.second.face) {
406 font.second.face =
nullptr;
432 Fatal(
"SetTextFont",
"Fail to create font handle for font %s",
basename);
442 Error(
"SetTextFont",
"no free type library initialized");
497 {
"Root.TTFont.0",
"FreeSansBold.otf" },
498 {
"Root.TTFont.1",
"FreeSerifItalic.otf" },
499 {
"Root.TTFont.2",
"FreeSerifBold.otf" },
500 {
"Root.TTFont.3",
"FreeSerifBoldItalic.otf" },
501 {
"Root.TTFont.4",
"texgyreheros-regular.otf" },
502 {
"Root.TTFont.5",
"texgyreheros-italic.otf" },
503 {
"Root.TTFont.6",
"texgyreheros-bold.otf" },
504 {
"Root.TTFont.7",
"texgyreheros-bolditalic.otf" },
505 {
"Root.TTFont.8",
"FreeMono.otf" },
506 {
"Root.TTFont.9",
"FreeMonoOblique.otf" },
507 {
"Root.TTFont.10",
"FreeMonoBold.otf" },
508 {
"Root.TTFont.11",
"FreeMonoBoldOblique.otf" },
509 {
"Root.TTFont.12",
"symbol.ttf" },
510 {
"Root.TTFont.13",
"FreeSerif.otf" },
511 {
"Root.TTFont.14",
"wingding.ttf" },
512 {
"Root.TTFont.15",
"symbol.ttf" },
513 {
"Root.TTFont.STIXGen",
"STIXGeneral.otf" },
514 {
"Root.TTFont.STIXGenIt",
"STIXGeneralItalic.otf" },
515 {
"Root.TTFont.STIXGenBd",
"STIXGeneralBol.otf" },
516 {
"Root.TTFont.STIXGenBdIt",
"STIXGeneralBolIta.otf" },
517 {
"Root.TTFont.STIXSiz1Sym",
"STIXSiz1Sym.otf" },
518 {
"Root.TTFont.STIXSiz1SymBd",
"STIXSiz1SymBol.otf" },
519 {
"Root.TTFont.STIXSiz2Sym",
"STIXSiz2Sym.otf" },
520 {
"Root.TTFont.STIXSiz2SymBd",
"STIXSiz2SymBol.otf" },
521 {
"Root.TTFont.STIXSiz3Sym",
"STIXSiz3Sym.otf" },
522 {
"Root.TTFont.STIXSiz3SymBd",
"STIXSiz3SymBol.otf" },
523 {
"Root.TTFont.STIXSiz4Sym",
"STIXSiz4Sym.otf" },
524 {
"Root.TTFont.STIXSiz4SymBd",
"STIXSiz4SymBol.otf" },
525 {
"Root.TTFont.STIXSiz5Sym",
"STIXSiz5Sym.otf" },
526 {
"Root.TTFont.ME",
"DroidSansFallback.ttf" },
527 {
"Root.TTFont.CJKMing",
"DroidSansFallback.ttf" },
528 {
"Root.TTFont.CJKGothic",
"DroidSansFallback.ttf" }
564 Error(
"TTFhandle::SetTextSize",
"current font not selected");
572 Error(
"TTFhandle::SetTextSize",
"error in FT_Set_Char_Size: 0x%x (input size %f, calc. size 0x%x)", err,
textsize,
tsize);
648 fgHandle = std::make_unique<TTFhandle>();
720 static FT_BBox dummy;
737 return fgHandle->CharToUnicode(code);
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
float Float_t
Float 4 bytes (float)
short Font_t
Font number (short)
short Short_t
Signed Short integer 2 bytes (short)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t fontnumber
Option_t Option_t SetTextFont
Option_t Option_t textsize
Option_t Option_t TPoint TPoint angle
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 fontname
Option_t Option_t TPoint TPoint const char text
R__EXTERN TSystem * gSystem
thread_local TTF gCleanupTTF
thread_local std::unique_ptr< TTFhandle > fgHandle
const_iterator begin() const
const_iterator end() const
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
TTF helper class containing glyphs description.
Interface to the freetype 2 library.
static void SetKerning(Bool_t state)
Set kerning flag.
static Bool_t IsInitialized()
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
static void GetTextExtent(UInt_t &w, UInt_t &h, const char *text)
Get width (w) and height (h) when text is horizontal.
static Bool_t GetKerning()
static void Version(Int_t &major, Int_t &minor, Int_t &patch)
static Int_t GetTrailingBlanksWidth()
static void SetHinting(Bool_t state)
Set hinting flag.
static void Init()
Init TTF environment.
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
static void CleanupGlyphs()
Remove temporary data created by LayoutGlyphs.
static void SetTextFont(Font_t fontnumber)
Set specified font.
static Short_t CharToUnicode(UInt_t code)
Map char to unicode. Returns 0 in case no mapping exists.
static TTGlyph * GetGlyphs()
static Int_t GetNumGlyphs()
static void ComputeTrailingBlanksWidth(Int_t n)
Compute the trailing blanks width.
virtual ~TTF()
Cleanup TTF environment.
static const FT_BBox & GetBox()
static void GetTextAdvance(UInt_t &a, const char *text)
Get advance (a) when text is horizontal.
static Bool_t GetHinting()
static Bool_t GetSmoothing()
static void SetTextSize(Float_t textsize)
static FT_Matrix * GetRotMatrix()
void GetTextExtent(UInt_t &w, UInt_t &h, const char *text)
Get width (w) and height (h) when text is horizontal.
Bool_t fKerning
use kerning (true by default)
std::unique_ptr< FT_Matrix > fRotMatrix
rotation matrix
std::vector< TTF::TTGlyph > fGlyphs
glyphs
Int_t fAscent
string ascent, used to compute Y alignment
Int_t SelectFontHandle(Int_t arg, const char *name=nullptr)
Return thread_local instance of TTFontHandle for speified font.
Bool_t SetTextSize(Float_t textsize)
Set current text size.
void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
UInt_t CharToUnicode(UInt_t code)
Map char to unicode. Returns 0 in case no mapping exists.
FT_BitmapGlyph GetGlyphBitmap(UInt_t n, Bool_t smooth=kFALSE)
Return bitmap for specified glyph.
static void SetHinting(Bool_t state)
FT_BBox fCBox
string control box
void SetTextFont(Font_t fontnumber)
Set specified font.
Int_t fTBlankW
trailing blanks width
Int_t GetTrailingBlanksWidth() const
TTFontHandle * fFont
selected font
static Bool_t fgHinting
use hinting (false by default)
void Version(Int_t &major, Int_t &minor, Int_t &patch)
FT_Face GetFontFace() const
Return current font index.
void CleanupGlyphs()
Remove temporary data created by LayoutGlyphs.
void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
static Bool_t GetSmoothing()
void ComputeTrailingBlanksWidth(Int_t n)
Compute the trailing blanks width.
void GetTextAdvance(UInt_t &a, const char *text)
Get advance (a) when text is horizontal.
static Bool_t fgSmoothing
use anti-aliasing (true when >8 planes, false otherwise)
static FT_Library InitClose(Int_t direction=0)
Initialize or close FreeType library If argument is 0 - just return current handle Library initialize...
Int_t fWidth
string width, used to compute X alignment
static Bool_t GetHinting()
static void SetSmoothing(Bool_t state)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.