Open CASCADE Technology 6.6.0
Data Structures | Public Member Functions | Protected Member Functions | Protected Attributes
OpenGl_Font Class Reference

Texture font.

#include <OpenGl_Font.hxx>

Inheritance diagram for OpenGl_Font:
Inheritance graph
[legend]

Data Structures

struct  RectI
struct  Tile
 Simple structure stores tile rectangle. More...

Public Member Functions

 OpenGl_Font (const Handle< Font_FTFont > &theFont, const TCollection_AsciiString &theKey="")
 Main constructor.
virtual ~OpenGl_Font ()
 Destroy object.
virtual void Release (const OpenGl_Context *theCtx)
 Destroy object - will release GPU memory if any.
const TCollection_AsciiStringResourceKey () const
const Handle< Font_FTFont > & FTFont () const
bool IsValid () const
bool WasInitialized () const
 Notice that this method doesn't return initialization success state. Use IsValid() instead.
bool Init (const Handle< OpenGl_Context > &theCtx)
 Initialize GL resources. FreeType font instance should be already initialized!
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.
float Ascender () const
float Descender () const
float LineSpacing () const
void RenderGlyph (const Handle< OpenGl_Context > &theCtx, const Standard_Utf32Char theUChar, const Standard_Utf32Char theUCharNext, Tile &theGlyph, OpenGl_Vec2 &thePen)
 Compute glyph rectangle at specified pen position (on baseline) and render it to texture if not already.

Protected Member Functions

bool renderGlyph (const Handle< OpenGl_Context > &theCtx, const Standard_Utf32Char theChar)
 Render new glyph to the texture.
bool createTexture (const Handle< OpenGl_Context > &theCtx)
 Allocate new texture.

Protected Attributes

TCollection_AsciiString myKey
 key of shared resource
Handle< Font_FTFontmyFont
 FreeType font instance.
Standard_ShortReal myAscender
 ascender provided my FT font
Standard_ShortReal myDescender
 descender provided my FT font
Standard_ShortReal myLineSpacing
 line spacing provided my FT font
Standard_Integer myTileSizeX
 tile width
Standard_Integer myTileSizeY
 tile height
Standard_Integer myLastTileId
 id of last tile
RectI myLastTilePx
Standard_Integer myTextureFormat
 texture format
NCollection_Vector< Handle
< OpenGl_Texture > > 
myTextures
 array of textures
NCollection_Vector< TilemyTiles
 array of loaded tiles
NCollection_DataMap
< Standard_Utf32Char,
Standard_Integer
myGlyphMap

Constructor & Destructor Documentation

OpenGl_Font::OpenGl_Font ( const Handle< Font_FTFont > &  theFont,
const TCollection_AsciiString theKey = "" 
)
virtual OpenGl_Font::~OpenGl_Font ( ) [virtual]

Member Function Documentation

float OpenGl_Font::AdvanceX ( const Standard_Utf32Char  theUChar,
const Standard_Utf32Char  theUCharNext 
) [inline]
float OpenGl_Font::Ascender ( ) const [inline]
Returns:
vertical distance from the horizontal baseline to the highest character coordinate
bool OpenGl_Font::createTexture ( const Handle< OpenGl_Context > &  theCtx) [protected]
float OpenGl_Font::Descender ( ) const [inline]
Returns:
vertical distance from the horizontal baseline to the lowest character coordinate
const Handle< Font_FTFont >& OpenGl_Font::FTFont ( ) const [inline]
Returns:
FreeType font instance specified on construction.
bool OpenGl_Font::Init ( const Handle< OpenGl_Context > &  theCtx)
bool OpenGl_Font::IsValid ( ) const [inline]
Returns:
true if font was loaded successfully.
float OpenGl_Font::LineSpacing ( ) const [inline]
Returns:
default line spacing (the baseline-to-baseline distance)
virtual void OpenGl_Font::Release ( const OpenGl_Context theCtx) [virtual]

Implements OpenGl_Resource.

bool OpenGl_Font::renderGlyph ( const Handle< OpenGl_Context > &  theCtx,
const Standard_Utf32Char  theChar 
) [protected]
void OpenGl_Font::RenderGlyph ( const Handle< OpenGl_Context > &  theCtx,
const Standard_Utf32Char  theUChar,
const Standard_Utf32Char  theUCharNext,
Tile theGlyph,
OpenGl_Vec2 thePen 
)
Parameters:
theCtxactive context
theUCharunicode symbol to render
theUCharNextnext symbol to compute advance with kerning when available
theGlyphcomputed glyph position rectangle, texture ID and UV coordinates
thePenpen position on baseline to place new glyph
const TCollection_AsciiString& OpenGl_Font::ResourceKey ( ) const [inline]
Returns:
key of shared resource
bool OpenGl_Font::WasInitialized ( ) const [inline]
Returns:
true if initialization was already called.

Field Documentation

Handle< Font_FTFont > OpenGl_Font::myFont [protected]

The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines