Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TTFhandle Class Reference

Dynamic handle to work with freetype 2 library.

in ROOT7 TTFhandle will completely replace TTF class

Definition at line 22 of file TTFhandle.h.

Classes

struct  FontStruct
 
struct  FT_Library_Wrapper
 Thread-local wrapper to the freetype library. More...
 
struct  GlyphStruct
 
class  Tristate
 

Public Member Functions

 TTFhandle ()
 
virtual ~TTFhandle ()
 
Bool_t ApplyAlignRotate (Int_t &px, Int_t &py, Int_t align, Int_t pad_width, Int_t pad_height)
 Apply align and configured rotation matrix to text position px and py will be shifted to the place where glyph drawing can be started Method returns false when glyphs not need to be drawn while position is outside of specified pad dimentsions.
 
void CleanupGlyphs ()
 Remove temporary data created by LayoutGlyphs.
 
Int_t GetAscent () const
 
long GetBoxXMax () const
 
long GetBoxXMin () const
 
long GetBoxYMax () const
 
long GetBoxYMin () const
 
void * GetFontFace () const
 Return current font index.
 
Bool_t GetGlyphData (UInt_t n, Int_t &offx, Int_t &offy, UChar_t *&buffer, UInt_t &width, UInt_t &rows, UInt_t &pitch)
 Returns data for glyph bitmap Instead direct access to FT_BitmapGlyph one can obtain all relevant fields Thus one do not requires work with TrueType classes directly Return kFALSE when glyph not exists or if it width is zero.
 
Int_t GetGlyphsHeight () const
 Returns height of all glyphs.
 
Int_t GetGlyphsWidth () const
 Returns width of all glyphs.
 
Bool_t GetHinting () const
 Returns true if hinting for this instance is enabled If SetHinting() was not called before - use global value configured with SetHinitingPrefer method.
 
Bool_t GetKerning () const
 Returns true if kerning for this instance is enabled If SetKerning() was not called before - use global value configured with SetKerningPrefer method.
 
UInt_t GetNumGlyphs () const
 return number of glyphs
 
Bool_t GetSmoothing () const
 Returns true if smoothing for this instance is enabled If SetSmoothing() was not called before - use global value configured with SetSmoothingPrefer method.
 
void GetTextAdvance (UInt_t &a, const char *text)
 Get advance (a) when text is horizontal.
 
void GetTextExtent (UInt_t &w, UInt_t &h, const char *text)
 Get width (w) and height (h) when text is horizontal.
 
void GetTextExtent (UInt_t &w, UInt_t &h, const wchar_t *text)
 Get width (w) and height (h) when text is horizontal.
 
Int_t GetTrailingBlanksWidth () const
 
Int_t GetWidth () const
 
virtual TClass * IsA () const
 
void LayoutGlyphs ()
 Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
 
void PrepareString (const char *string)
 Put the characters in "string" in the "glyphs" array.
 
void PrepareString (const wchar_t *string)
 Put the characters in "string" in the "glyphs" array.
 
void SetHinting (Bool_t state)
 
void SetKerning (Bool_t state)
 
void SetRotationMatrix (Float_t angle)
 Set the rotation matrix used to rotate the font outlines.
 
void SetSmoothing (Bool_t state)
 
Int_t SetTextFont (const char *fontname, Int_t italic=0)
 Set text font to specified name.
 
void SetTextFont (Font_t fontnumber)
 Set specified font.
 
Bool_t SetTextSize (Float_t textsize)
 Set current text size.
 
virtual void Streamer (TBuffer &)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
void Version (Int_t &major, Int_t &minor, Int_t &patch)
 

Static Public Member Functions

static TClass * Class ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Bool_t GetHintingPrefer ()
 Returns true if hinting of text drawing is enabled by default.
 
static Bool_t GetKerningPrefer ()
 Returns true if kerning of text drawing is enabled by default.
 
static Bool_t GetSmoothingPrefer ()
 Returns true if smoothing of text drawing is enabled by default.
 
static Bool_t Init ()
 
static void SetHintingPrefer (Bool_t on)
 Set global flag to switch on/off hinting of TTF text drawing This flag is used when SetHiniting() flag not set before.
 
static void SetKerningPrefer (Bool_t on)
 Set global flag to switch on/off kerning of TTF text drawing This flag is used when SetKerning() flag not set before.
 
static void SetSmoothingPrefer (Bool_t on)
 Set global flag to switch on/off smoothing of TTF text drawing This flag is used when SetSmoothing() flag not set before.
 

Private Member Functions

UInt_t CharToUnicode (UInt_t code)
 Map char to unicode. Returns 0 in case no mapping exists.
 
void ComputeTrailingBlanksWidth (Int_t n)
 Compute the trailing blanks width.
 
void FillTTFGlypths (void *vect)
 Fill vector from TTF class Only for backward compatibility of old API.
 
Int_t SelectFontHandle (Int_t arg, const char *name=nullptr)
 Return thread_local instance of FontStruct for speified font.
 

Private Attributes

Int_t fAscent = 0
 string ascent, used to compute Y alignment
 
FontStruct * fFont = nullptr
 selected font
 
std::vector< GlyphStruct > fGlyphs
 glyphs
 
Tristate fHinting
 use hinting (false by default)
 
Tristate fKerning
 use kerning (true by default)
 
long fRotationXX = 0
 
long fRotationXY = 0
 rotation matrix members
 
Tristate fSmoothing
 use anti-aliasing (true when >8 planes, false otherwise)
 
Int_t fTBlankW = 0
 trailing blanks width
 
Int_t fWidth = 0
 string width, used to compute X alignment
 
long xMax = 0
 
long xMin = 0
 
long yMax = 0
 boundaries
 
long yMin = 0
 

Static Private Attributes

static thread_local FT_Library_Wrapper fFT_Library
 
static std::atomic< Bool_t > fKerningPrefer = kTRUE
 
static std::atomic< Bool_t > gHintingPrefer = kFALSE
 
static std::atomic< Bool_t > gSmoothingPrefer = kTRUE
 

Friends

class TTF
 

#include <TTFhandle.h>

Constructor & Destructor Documentation

◆ TTFhandle()

TTFhandle::TTFhandle ( )

Definition at line 94 of file TTFhandle.cxx.

◆ ~TTFhandle()

TTFhandle::~TTFhandle ( )
virtual

Definition at line 102 of file TTFhandle.cxx.

Member Function Documentation

◆ ApplyAlignRotate()

Bool_t TTFhandle::ApplyAlignRotate ( Int_t & px,
Int_t & py,
Int_t align,
Int_t pad_width,
Int_t pad_height )

Apply align and configured rotation matrix to text position px and py will be shifted to the place where glyph drawing can be started Method returns false when glyphs not need to be drawn while position is outside of specified pad dimentsions.

Definition at line 324 of file TTFhandle.cxx.

◆ CharToUnicode()

UInt_t TTFhandle::CharToUnicode ( UInt_t code)
private

Map char to unicode. Returns 0 in case no mapping exists.

Definition at line 110 of file TTFhandle.cxx.

◆ Class()

static TClass * TTFhandle::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TTFhandle::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TTFhandle::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 114 of file TTFhandle.h.

◆ CleanupGlyphs()

void TTFhandle::CleanupGlyphs ( )

Remove temporary data created by LayoutGlyphs.

Definition at line 433 of file TTFhandle.cxx.

◆ ComputeTrailingBlanksWidth()

void TTFhandle::ComputeTrailingBlanksWidth ( Int_t n)
private

Compute the trailing blanks width.

It is use to compute the text width in GetTextExtent n is the number of trailing blanks in a string.

Definition at line 140 of file TTFhandle.cxx.

◆ DeclFileName()

static const char * TTFhandle::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 114 of file TTFhandle.h.

◆ FillTTFGlypths()

void TTFhandle::FillTTFGlypths ( void * vect)
private

Fill vector from TTF class Only for backward compatibility of old API.

Definition at line 304 of file TTFhandle.cxx.

◆ GetAscent()

Int_t TTFhandle::GetAscent ( ) const
inline

Definition at line 87 of file TTFhandle.h.

◆ GetBoxXMax()

long TTFhandle::GetBoxXMax ( ) const
inline

Definition at line 91 of file TTFhandle.h.

◆ GetBoxXMin()

long TTFhandle::GetBoxXMin ( ) const
inline

Definition at line 90 of file TTFhandle.h.

◆ GetBoxYMax()

long TTFhandle::GetBoxYMax ( ) const
inline

Definition at line 93 of file TTFhandle.h.

◆ GetBoxYMin()

long TTFhandle::GetBoxYMin ( ) const
inline

Definition at line 92 of file TTFhandle.h.

◆ GetFontFace()

void * TTFhandle::GetFontFace ( ) const

Return current font index.

Definition at line 495 of file TTFhandle.cxx.

◆ GetGlyphData()

Bool_t TTFhandle::GetGlyphData ( UInt_t n,
Int_t & offx,
Int_t & offy,
UChar_t *& buffer,
UInt_t & width,
UInt_t & rows,
UInt_t & pitch )

Returns data for glyph bitmap Instead direct access to FT_BitmapGlyph one can obtain all relevant fields Thus one do not requires work with TrueType classes directly Return kFALSE when glyph not exists or if it width is zero.

Definition at line 401 of file TTFhandle.cxx.

◆ GetGlyphsHeight()

Int_t TTFhandle::GetGlyphsHeight ( ) const

Returns height of all glyphs.

Definition at line 390 of file TTFhandle.cxx.

◆ GetGlyphsWidth()

Int_t TTFhandle::GetGlyphsWidth ( ) const

Returns width of all glyphs.

Definition at line 382 of file TTFhandle.cxx.

◆ GetHinting()

Bool_t TTFhandle::GetHinting ( ) const

Returns true if hinting for this instance is enabled If SetHinting() was not called before - use global value configured with SetHinitingPrefer method.

Definition at line 815 of file TTFhandle.cxx.

◆ GetHintingPrefer()

Bool_t TTFhandle::GetHintingPrefer ( )
static

Returns true if hinting of text drawing is enabled by default.

Definition at line 793 of file TTFhandle.cxx.

◆ GetKerning()

Bool_t TTFhandle::GetKerning ( ) const

Returns true if kerning for this instance is enabled If SetKerning() was not called before - use global value configured with SetKerningPrefer method.

Definition at line 827 of file TTFhandle.cxx.

◆ GetKerningPrefer()

Bool_t TTFhandle::GetKerningPrefer ( )
static

Returns true if kerning of text drawing is enabled by default.

Definition at line 759 of file TTFhandle.cxx.

◆ GetNumGlyphs()

UInt_t TTFhandle::GetNumGlyphs ( ) const

return number of glyphs

Definition at line 294 of file TTFhandle.cxx.

◆ GetSmoothing()

Bool_t TTFhandle::GetSmoothing ( ) const

Returns true if smoothing for this instance is enabled If SetSmoothing() was not called before - use global value configured with SetSmoothingPrefer method.

Definition at line 803 of file TTFhandle.cxx.

◆ GetSmoothingPrefer()

Bool_t TTFhandle::GetSmoothingPrefer ( )
static

Returns true if smoothing of text drawing is enabled by default.

Definition at line 776 of file TTFhandle.cxx.

◆ GetTextAdvance()

void TTFhandle::GetTextAdvance ( UInt_t & a,
const char * text )

Get advance (a) when text is horizontal.

Definition at line 174 of file TTFhandle.cxx.

◆ GetTextExtent() [1/2]

void TTFhandle::GetTextExtent ( UInt_t & w,
UInt_t & h,
const char * text )

Get width (w) and height (h) when text is horizontal.

Definition at line 161 of file TTFhandle.cxx.

◆ GetTextExtent() [2/2]

void TTFhandle::GetTextExtent ( UInt_t & w,
UInt_t & h,
const wchar_t * text )

Get width (w) and height (h) when text is horizontal.

Definition at line 186 of file TTFhandle.cxx.

◆ GetTrailingBlanksWidth()

Int_t TTFhandle::GetTrailingBlanksWidth ( ) const
inline

Definition at line 88 of file TTFhandle.h.

◆ GetWidth()

Int_t TTFhandle::GetWidth ( ) const
inline

Definition at line 89 of file TTFhandle.h.

◆ Init()

Bool_t TTFhandle::Init ( )
static

Definition at line 742 of file TTFhandle.cxx.

◆ IsA()

virtual TClass * TTFhandle::IsA ( ) const
inlinevirtual
Returns
TClass describing current object

Definition at line 114 of file TTFhandle.h.

◆ LayoutGlyphs()

void TTFhandle::LayoutGlyphs ( )

Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).

Perform the Glyphs transformation. Compute the string control box. If required take the "kerning" into account. SetRotation and PrepareString should have been called before.

Definition at line 203 of file TTFhandle.cxx.

◆ PrepareString() [1/2]

void TTFhandle::PrepareString ( const char * string)

Put the characters in "string" in the "glyphs" array.

Definition at line 441 of file TTFhandle.cxx.

◆ PrepareString() [2/2]

void TTFhandle::PrepareString ( const wchar_t * string)

Put the characters in "string" in the "glyphs" array.

Definition at line 466 of file TTFhandle.cxx.

◆ SelectFontHandle()

Int_t TTFhandle::SelectFontHandle ( Int_t arg,
const char * name = nullptr )
private

Return thread_local instance of FontStruct for speified font.

Definition at line 531 of file TTFhandle.cxx.

◆ SetHinting()

void TTFhandle::SetHinting ( Bool_t state)
inline

Definition at line 68 of file TTFhandle.h.

◆ SetHintingPrefer()

void TTFhandle::SetHintingPrefer ( Bool_t on)
static

Set global flag to switch on/off hinting of TTF text drawing This flag is used when SetHiniting() flag not set before.

Definition at line 785 of file TTFhandle.cxx.

◆ SetKerning()

void TTFhandle::SetKerning ( Bool_t state)
inline

Definition at line 69 of file TTFhandle.h.

◆ SetKerningPrefer()

void TTFhandle::SetKerningPrefer ( Bool_t on)
static

Set global flag to switch on/off kerning of TTF text drawing This flag is used when SetKerning() flag not set before.

Definition at line 751 of file TTFhandle.cxx.

◆ SetRotationMatrix()

void TTFhandle::SetRotationMatrix ( Float_t angle)

Set the rotation matrix used to rotate the font outlines.

Definition at line 503 of file TTFhandle.cxx.

◆ SetSmoothing()

void TTFhandle::SetSmoothing ( Bool_t state)
inline

Definition at line 67 of file TTFhandle.h.

◆ SetSmoothingPrefer()

void TTFhandle::SetSmoothingPrefer ( Bool_t on)
static

Set global flag to switch on/off smoothing of TTF text drawing This flag is used when SetSmoothing() flag not set before.

Definition at line 768 of file TTFhandle.cxx.

◆ SetTextFont() [1/2]

Int_t TTFhandle::SetTextFont ( const char * fontname,
Int_t italic = 0 )

Set text font to specified name.

  • font : font name
  • italic : the fonts should be slanted. Used for symbol font.

Set text font to specified name. This function returns 0 if the specified font is found, 1 if not.

Definition at line 577 of file TTFhandle.cxx.

◆ SetTextFont() [2/2]

void TTFhandle::SetTextFont ( Font_t fontnumber)

Set specified font.

List of the currently supported fonts (screen and PostScript)

Font number TTF Names PostScript/PDF Names
1 Free Serif Italic Times-Italic
2 Free Serif Bold Times-Bold
3 Free Serif Bold Italic Times-BoldItalic
4 Tex Gyre Regular Helvetica
5 Tex Gyre Italic Helvetica-Oblique
6 Tex Gyre Bold Helvetica-Bold
7 Tex Gyre Bold Italic Helvetica-BoldOblique
8 Free Mono Courier
9 Free Mono Oblique Courier-Oblique
10 Free Mono Bold Courier-Bold
11 Free Mono Bold Oblique Courier-BoldOblique
12 Symbol Symbol
13 Free Serif Times-Roman
14 Wingdings ZapfDingbats

Definition at line 646 of file TTFhandle.cxx.

◆ SetTextSize()

Bool_t TTFhandle::SetTextSize ( Float_t textsize)

Set current text size.

Definition at line 713 of file TTFhandle.cxx.

◆ Streamer()

virtual void TTFhandle::Streamer ( TBuffer & )
virtual

◆ StreamerNVirtual()

void TTFhandle::StreamerNVirtual ( TBuffer & ClassDef_StreamerNVirtual_b)
inline

Definition at line 114 of file TTFhandle.h.

◆ Version()

void TTFhandle::Version ( Int_t & major,
Int_t & minor,
Int_t & patch )

Definition at line 734 of file TTFhandle.cxx.

Friends And Related Symbol Documentation

◆ TTF

friend class TTF
friend

Definition at line 23 of file TTFhandle.h.

Member Data Documentation

◆ fAscent

Int_t TTFhandle::fAscent = 0
private

string ascent, used to compute Y alignment

Definition at line 44 of file TTFhandle.h.

◆ fFont

FontStruct* TTFhandle::fFont = nullptr
private

selected font

Definition at line 41 of file TTFhandle.h.

◆ fFT_Library

thread_local TTFhandle::FT_Library_Wrapper TTFhandle::fFT_Library
staticprivate

Definition at line 56 of file TTFhandle.h.

◆ fGlyphs

std::vector<GlyphStruct> TTFhandle::fGlyphs
private

glyphs

Definition at line 43 of file TTFhandle.h.

◆ fHinting

Tristate TTFhandle::fHinting
private

use hinting (false by default)

Definition at line 39 of file TTFhandle.h.

◆ fKerning

Tristate TTFhandle::fKerning
private

use kerning (true by default)

Definition at line 37 of file TTFhandle.h.

◆ fKerningPrefer

std::atomic< Bool_t > TTFhandle::fKerningPrefer = kTRUE
staticprivate

Definition at line 59 of file TTFhandle.h.

◆ fRotationXX

long TTFhandle::fRotationXX = 0
private

Definition at line 42 of file TTFhandle.h.

◆ fRotationXY

long TTFhandle::fRotationXY = 0
private

rotation matrix members

Definition at line 42 of file TTFhandle.h.

◆ fSmoothing

Tristate TTFhandle::fSmoothing
private

use anti-aliasing (true when >8 planes, false otherwise)

Definition at line 38 of file TTFhandle.h.

◆ fTBlankW

Int_t TTFhandle::fTBlankW = 0
private

trailing blanks width

Definition at line 46 of file TTFhandle.h.

◆ fWidth

Int_t TTFhandle::fWidth = 0
private

string width, used to compute X alignment

Definition at line 47 of file TTFhandle.h.

◆ gHintingPrefer

std::atomic< Bool_t > TTFhandle::gHintingPrefer = kFALSE
staticprivate

Definition at line 58 of file TTFhandle.h.

◆ gSmoothingPrefer

std::atomic< Bool_t > TTFhandle::gSmoothingPrefer = kTRUE
staticprivate

Definition at line 57 of file TTFhandle.h.

◆ xMax

long TTFhandle::xMax = 0
private

Definition at line 45 of file TTFhandle.h.

◆ xMin

long TTFhandle::xMin = 0
private

Definition at line 45 of file TTFhandle.h.

◆ yMax

long TTFhandle::yMax = 0
private

boundaries

Definition at line 45 of file TTFhandle.h.

◆ yMin

long TTFhandle::yMin = 0
private

Definition at line 45 of file TTFhandle.h.

Libraries for TTFhandle:

The documentation for this class was generated from the following files: