Open CASCADE Technology  7.2.0
Public Member Functions | Protected Member Functions | Protected Attributes

Font_FTFont Class Reference

Wrapper over FreeType font. Notice that this class uses internal buffers for loaded glyphs and it is absolutely UNSAFE to load/read glyph from concurrent threads! More...

#include <Font_FTFont.hxx>

Inheritance diagram for Font_FTFont:
Inheritance graph
[legend]

Public Member Functions

 Font_FTFont (const Handle< Font_FTLibrary > &theFTLib=Handle< Font_FTLibrary >())
 Create uninitialized instance. More...
 
virtual ~Font_FTFont ()
 Destructor. More...
 
bool IsValid () const
 
const Image_PixMapGlyphImage () const
 
bool Init (const NCollection_String &theFontPath, const unsigned int thePointSize, const unsigned int theResolution)
 Initialize the font. More...
 
bool Init (const NCollection_String &theFontName, const Font_FontAspect theFontAspect, const unsigned int thePointSize, const unsigned int theResolution)
 Initialize the font. More...
 
virtual void Release ()
 Release currently loaded font. More...
 
bool RenderGlyph (const Standard_Utf32Char theChar)
 Render specified glyph into internal buffer (bitmap). More...
 
unsigned int GlyphMaxSizeX () const
 
unsigned int GlyphMaxSizeY () const
 
float Ascender () const
 
float Descender () const
 
float LineSpacing () const
 
unsigned int PointSize () const
 Configured point size. More...
 
float AdvanceX (const Standard_Utf32Char theUCharNext)
 Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally. More...
 
float AdvanceX (const Standard_Utf32Char theUChar, const Standard_Utf32Char theUCharNext)
 Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally. More...
 
float AdvanceY (const Standard_Utf32Char theUCharNext)
 Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically. More...
 
float AdvanceY (const Standard_Utf32Char theUChar, const Standard_Utf32Char theUCharNext)
 Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically. More...
 
Standard_Integer GlyphsNumber () const
 
void GlyphRect (Font_Rect &theRect) const
 Retrieve glyph bitmap rectangle. More...
 
Font_Rect BoundingBox (const NCollection_String &theString, const Graphic3d_HorizontalTextAlignment theAlignX, const Graphic3d_VerticalTextAlignment theAlignY)
 Computes bounding box of the given text using plain-text formatter (Font_TextFormatter). Note that bounding box takes into account the text alignment options. Its corners are relative to the text alignment anchor point, their coordinates can be negative. More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object. More...
 
Standard_Boolean IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
Standard_Boolean IsKind (const opencascade::handle< Standard_Type > &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_Boolean IsKind (const Standard_CString theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 
void IncrementRefCounter () const
 Increments the reference counter of this object. More...
 
Standard_Integer DecrementRefCounter () const
 Decrements the reference counter of this object; returns the decremented value. More...
 

Protected Member Functions

template<typename theInput_t >
int32_t toFTPoints (const theInput_t thePointSize) const
 Convert value to 26.6 fixed-point format for FT library API. More...
 
template<typename theReturn_t , typename theFTUnits_t >
theReturn_t fromFTPoints (const theFTUnits_t theFTUnits) const
 Convert value from 26.6 fixed-point format for FT library API. More...
 
bool loadGlyph (const Standard_Utf32Char theUChar)
 Load glyph without rendering it. More...
 

Protected Attributes

Handle< Font_FTLibrarymyFTLib
 handle to the FT library object More...
 
FT_Face myFTFace
 FT face object. More...
 
NCollection_String myFontPath
 font path More...
 
unsigned int myPointSize
 point size set by FT_Set_Char_Size More...
 
int32_t myLoadFlags
 default load flags More...
 
Image_PixMap myGlyphImg
 cached glyph plane More...
 
FT_VectormyKernAdvance
 buffer variable More...
 
Standard_Utf32Char myUChar
 currently loaded unicode character More...
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object. More...
 
- Static Public Member Functions inherited from Standard_Transient
static const char * get_type_name ()
 Returns a type descriptor about this object. More...
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class. More...
 

Detailed Description

Wrapper over FreeType font. Notice that this class uses internal buffers for loaded glyphs and it is absolutely UNSAFE to load/read glyph from concurrent threads!

Constructor & Destructor Documentation

◆ Font_FTFont()

Font_FTFont::Font_FTFont ( const Handle< Font_FTLibrary > &  theFTLib = HandleFont_FTLibrary >())

Create uninitialized instance.

◆ ~Font_FTFont()

virtual Font_FTFont::~Font_FTFont ( )
virtual

Destructor.

Member Function Documentation

◆ AdvanceX() [1/2]

float Font_FTFont::AdvanceX ( const Standard_Utf32Char  theUCharNext)

Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally.

◆ AdvanceX() [2/2]

float Font_FTFont::AdvanceX ( const Standard_Utf32Char  theUChar,
const Standard_Utf32Char  theUCharNext 
)

Compute advance to the next character with kerning applied when applicable. Assuming text rendered horizontally.

◆ AdvanceY() [1/2]

float Font_FTFont::AdvanceY ( const Standard_Utf32Char  theUCharNext)

Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically.

◆ AdvanceY() [2/2]

float Font_FTFont::AdvanceY ( const Standard_Utf32Char  theUChar,
const Standard_Utf32Char  theUCharNext 
)

Compute advance to the next character with kerning applied when applicable. Assuming text rendered vertically.

◆ Ascender()

float Font_FTFont::Ascender ( ) const
Returns
vertical distance from the horizontal baseline to the highest character coordinate.

◆ BoundingBox()

Font_Rect Font_FTFont::BoundingBox ( const NCollection_String theString,
const Graphic3d_HorizontalTextAlignment  theAlignX,
const Graphic3d_VerticalTextAlignment  theAlignY 
)

Computes bounding box of the given text using plain-text formatter (Font_TextFormatter). Note that bounding box takes into account the text alignment options. Its corners are relative to the text alignment anchor point, their coordinates can be negative.

◆ Descender()

float Font_FTFont::Descender ( ) const
Returns
vertical distance from the horizontal baseline to the lowest character coordinate.

◆ fromFTPoints()

template<typename theReturn_t , typename theFTUnits_t >
theReturn_t Font_FTFont::fromFTPoints ( const theFTUnits_t  theFTUnits) const
inlineprotected

Convert value from 26.6 fixed-point format for FT library API.

◆ GlyphImage()

const Image_PixMap& Font_FTFont::GlyphImage ( ) const
inline
Returns
image plane for currently rendered glyph

◆ GlyphMaxSizeX()

unsigned int Font_FTFont::GlyphMaxSizeX ( ) const
Returns
maximal glyph width in pixels (rendered to bitmap).

◆ GlyphMaxSizeY()

unsigned int Font_FTFont::GlyphMaxSizeY ( ) const
Returns
maximal glyph height in pixels (rendered to bitmap).

◆ GlyphRect()

void Font_FTFont::GlyphRect ( Font_Rect theRect) const

Retrieve glyph bitmap rectangle.

◆ GlyphsNumber()

Standard_Integer Font_FTFont::GlyphsNumber ( ) const
Returns
glyphs number in this font.

◆ Init() [1/2]

bool Font_FTFont::Init ( const NCollection_String theFontPath,
const unsigned int  thePointSize,
const unsigned int  theResolution 
)

Initialize the font.

Parameters
theFontPathpath to the font
thePointSizethe face size in points (1/72 inch)
theResolutionthe resolution of the target device in dpi
Returns
true on success

◆ Init() [2/2]

bool Font_FTFont::Init ( const NCollection_String theFontName,
const Font_FontAspect  theFontAspect,
const unsigned int  thePointSize,
const unsigned int  theResolution 
)

Initialize the font.

Parameters
theFontNamethe font name
theFontAspectthe font style
thePointSizethe face size in points (1/72 inch)
theResolutionthe resolution of the target device in dpi
Returns
true on success

◆ IsValid()

bool Font_FTFont::IsValid ( ) const
inline
Returns
true if font is loaded

◆ LineSpacing()

float Font_FTFont::LineSpacing ( ) const
Returns
default line spacing (the baseline-to-baseline distance).

◆ loadGlyph()

bool Font_FTFont::loadGlyph ( const Standard_Utf32Char  theUChar)
protected

Load glyph without rendering it.

◆ PointSize()

unsigned int Font_FTFont::PointSize ( ) const
inline

Configured point size.

◆ Release()

virtual void Font_FTFont::Release ( )
virtual

Release currently loaded font.

Reimplemented in Font_BRepFont.

◆ RenderGlyph()

bool Font_FTFont::RenderGlyph ( const Standard_Utf32Char  theChar)

Render specified glyph into internal buffer (bitmap).

◆ toFTPoints()

template<typename theInput_t >
int32_t Font_FTFont::toFTPoints ( const theInput_t  thePointSize) const
inlineprotected

Convert value to 26.6 fixed-point format for FT library API.

Field Documentation

◆ myFontPath

NCollection_String Font_FTFont::myFontPath
protected

font path

◆ myFTFace

FT_Face Font_FTFont::myFTFace
protected

FT face object.

◆ myFTLib

Handle< Font_FTLibrary > Font_FTFont::myFTLib
protected

handle to the FT library object

◆ myGlyphImg

Image_PixMap Font_FTFont::myGlyphImg
protected

cached glyph plane

◆ myKernAdvance

FT_Vector* Font_FTFont::myKernAdvance
protected

buffer variable

◆ myLoadFlags

int32_t Font_FTFont::myLoadFlags
protected

default load flags

◆ myPointSize

unsigned int Font_FTFont::myPointSize
protected

point size set by FT_Set_Char_Size

◆ myUChar

Standard_Utf32Char Font_FTFont::myUChar
protected

currently loaded unicode character


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