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 21 of file TTFhandle.h.

Classes

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

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
 
Bool_t GetKerning () const
 
UInt_t GetNumGlyphs () const
 return number of glyphs
 
Bool_t GetSmoothing () const
 
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 TClassIsA () 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 TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Bool_t Init ()
 

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
 
FontStructfFont = nullptr
 selected font
 
std::vector< GlyphStructfGlyphs
 glyphs
 
Bool_t fHinting = kFALSE
 use hinting (false by default)
 
Bool_t fKerning = kTRUE
 use kerning (true by default)
 
long fRotationXX = 0
 
long fRotationXY = 0
 rotation matrix members
 
Bool_t fSmoothing = kTRUE
 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
 

Friends

class TTF
 

#include <TTFhandle.h>

Constructor & Destructor Documentation

◆ TTFhandle()

TTFhandle::TTFhandle ( )

Definition at line 87 of file TTFhandle.cxx.

◆ ~TTFhandle()

TTFhandle::~TTFhandle ( )
virtual

Definition at line 95 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 308 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 103 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 97 of file TTFhandle.h.

◆ CleanupGlyphs()

void TTFhandle::CleanupGlyphs ( )

Remove temporary data created by LayoutGlyphs.

Definition at line 417 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 133 of file TTFhandle.cxx.

◆ DeclFileName()

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

Definition at line 97 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 288 of file TTFhandle.cxx.

◆ GetAscent()

Int_t TTFhandle::GetAscent ( ) const
inline

Definition at line 76 of file TTFhandle.h.

◆ GetBoxXMax()

long TTFhandle::GetBoxXMax ( ) const
inline

Definition at line 80 of file TTFhandle.h.

◆ GetBoxXMin()

long TTFhandle::GetBoxXMin ( ) const
inline

Definition at line 79 of file TTFhandle.h.

◆ GetBoxYMax()

long TTFhandle::GetBoxYMax ( ) const
inline

Definition at line 82 of file TTFhandle.h.

◆ GetBoxYMin()

long TTFhandle::GetBoxYMin ( ) const
inline

Definition at line 81 of file TTFhandle.h.

◆ GetFontFace()

void * TTFhandle::GetFontFace ( ) const

Return current font index.

Definition at line 479 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 385 of file TTFhandle.cxx.

◆ GetGlyphsHeight()

Int_t TTFhandle::GetGlyphsHeight ( ) const

Returns height of all glyphs.

Definition at line 374 of file TTFhandle.cxx.

◆ GetGlyphsWidth()

Int_t TTFhandle::GetGlyphsWidth ( ) const

Returns width of all glyphs.

Definition at line 366 of file TTFhandle.cxx.

◆ GetHinting()

Bool_t TTFhandle::GetHinting ( ) const
inline

Definition at line 65 of file TTFhandle.h.

◆ GetKerning()

Bool_t TTFhandle::GetKerning ( ) const
inline

Definition at line 66 of file TTFhandle.h.

◆ GetNumGlyphs()

UInt_t TTFhandle::GetNumGlyphs ( ) const

return number of glyphs

Definition at line 278 of file TTFhandle.cxx.

◆ GetSmoothing()

Bool_t TTFhandle::GetSmoothing ( ) const
inline

Definition at line 64 of file TTFhandle.h.

◆ GetTextAdvance()

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

Get advance (a) when text is horizontal.

Definition at line 167 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 154 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 179 of file TTFhandle.cxx.

◆ GetTrailingBlanksWidth()

Int_t TTFhandle::GetTrailingBlanksWidth ( ) const
inline

Definition at line 77 of file TTFhandle.h.

◆ GetWidth()

Int_t TTFhandle::GetWidth ( ) const
inline

Definition at line 78 of file TTFhandle.h.

◆ Init()

Bool_t TTFhandle::Init ( )
static

Definition at line 726 of file TTFhandle.cxx.

◆ IsA()

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

Definition at line 97 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 196 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 425 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 450 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 515 of file TTFhandle.cxx.

◆ SetHinting()

void TTFhandle::SetHinting ( Bool_t state)
inline

Definition at line 57 of file TTFhandle.h.

◆ SetKerning()

void TTFhandle::SetKerning ( Bool_t state)
inline

Definition at line 58 of file TTFhandle.h.

◆ SetRotationMatrix()

void TTFhandle::SetRotationMatrix ( Float_t angle)

Set the rotation matrix used to rotate the font outlines.

Definition at line 487 of file TTFhandle.cxx.

◆ SetSmoothing()

void TTFhandle::SetSmoothing ( Bool_t state)
inline

Definition at line 56 of file TTFhandle.h.

◆ 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 561 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 630 of file TTFhandle.cxx.

◆ SetTextSize()

Bool_t TTFhandle::SetTextSize ( Float_t textsize)

Set current text size.

Definition at line 697 of file TTFhandle.cxx.

◆ Streamer()

virtual void TTFhandle::Streamer ( TBuffer & )
virtual

◆ StreamerNVirtual()

void TTFhandle::StreamerNVirtual ( TBuffer & ClassDef_StreamerNVirtual_b)
inline

Definition at line 97 of file TTFhandle.h.

◆ Version()

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

Definition at line 718 of file TTFhandle.cxx.

Friends And Related Symbol Documentation

◆ TTF

friend class TTF
friend

Definition at line 22 of file TTFhandle.h.

Member Data Documentation

◆ fAscent

Int_t TTFhandle::fAscent = 0
private

string ascent, used to compute Y alignment

Definition at line 36 of file TTFhandle.h.

◆ fFont

FontStruct* TTFhandle::fFont = nullptr
private

selected font

Definition at line 33 of file TTFhandle.h.

◆ fFT_Library

thread_local TTFhandle::FT_Library_Wrapper TTFhandle::fFT_Library
staticprivate

Definition at line 48 of file TTFhandle.h.

◆ fGlyphs

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

glyphs

Definition at line 35 of file TTFhandle.h.

◆ fHinting

Bool_t TTFhandle::fHinting = kFALSE
private

use hinting (false by default)

Definition at line 31 of file TTFhandle.h.

◆ fKerning

Bool_t TTFhandle::fKerning = kTRUE
private

use kerning (true by default)

Definition at line 29 of file TTFhandle.h.

◆ fRotationXX

long TTFhandle::fRotationXX = 0
private

Definition at line 34 of file TTFhandle.h.

◆ fRotationXY

long TTFhandle::fRotationXY = 0
private

rotation matrix members

Definition at line 34 of file TTFhandle.h.

◆ fSmoothing

Bool_t TTFhandle::fSmoothing = kTRUE
private

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

Definition at line 30 of file TTFhandle.h.

◆ fTBlankW

Int_t TTFhandle::fTBlankW = 0
private

trailing blanks width

Definition at line 38 of file TTFhandle.h.

◆ fWidth

Int_t TTFhandle::fWidth = 0
private

string width, used to compute X alignment

Definition at line 39 of file TTFhandle.h.

◆ xMax

long TTFhandle::xMax = 0
private

Definition at line 37 of file TTFhandle.h.

◆ xMin

long TTFhandle::xMin = 0
private

Definition at line 37 of file TTFhandle.h.

◆ yMax

long TTFhandle::yMax = 0
private

boundaries

Definition at line 37 of file TTFhandle.h.

◆ yMin

long TTFhandle::yMin = 0
private

Definition at line 37 of file TTFhandle.h.

Libraries for TTFhandle:

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