Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | List of all members
vl::FontManager Class Reference

The FontManager class keeps a map associating a font path, size and smoothing flag to a Font object. More...

#include <FontManager.hpp>

+ Inheritance diagram for vl::FontManager:

Public Member Functions

 FontManager (void *free_type_library=NULL)
 Constructor: uses the given FT_Library handle otherwise will initialize and use its own FT_Library. More...
 
 ~FontManager ()
 Destructor: releases all fonts and disposes the FT_Library if not NULL. More...
 
FontacquireFont (const String &font, int size, bool smooth=false)
 Creates or returns an already created Font. More...
 
const std::vector< ref< Font > > & fonts () const
 Returns the list of Fonts created till now. More...
 
void releaseFont (Font *font)
 Releases a given Font and its associated resources and memory. More...
 
void releaseAllFonts ()
 Releases all Fonts and associated resources and memory. More...
 
const void * freeTypeLibrary () const
 Returns the FT_Library handle. More...
 
void * freeTypeLibrary ()
 Returns the FT_Library handle. More...
 
void * setFreeTypeLibrary (void *ftlib)
 Sets the FT_Library to the given one and returns the former one. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Attributes

std::vector< ref< Font > > mFonts
 
void * mFreeTypeLibrary
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

The FontManager class keeps a map associating a font path, size and smoothing flag to a Font object.

See also

Definition at line 45 of file FontManager.hpp.

Constructor & Destructor Documentation

◆ FontManager()

FontManager::FontManager ( void *  free_type_library = NULL)

Constructor: uses the given FT_Library handle otherwise will initialize and use its own FT_Library.

Definition at line 42 of file FontManager.cpp.

References vl::Log::error(), mFreeTypeLibrary, NULL, and VL_TRAP.

◆ ~FontManager()

FontManager::~FontManager ( )

Destructor: releases all fonts and disposes the FT_Library if not NULL.

If you don't want the FontManager to dispose the associated FT_Library then call setFreeTypeLibrary(NULL) before the FontManager is destroyed.

Definition at line 58 of file FontManager.cpp.

References mFreeTypeLibrary, NULL, and releaseAllFonts().

Member Function Documentation

◆ acquireFont()

Font * FontManager::acquireFont ( const String font,
int  size,
bool  smooth = false 
)

Creates or returns an already created Font.

Definition at line 68 of file FontManager.cpp.

References fonts(), vl::ref< T >::get(), vl::Font::loadFont(), mFonts, vl::Font::setSize(), and vl::Font::setSmooth().

Referenced by vl::VectorGraphics::setFont(), and vl::VolumePlot::VolumePlot().

◆ fonts()

const std::vector< ref<Font> >& vl::FontManager::fonts ( ) const
inline

Returns the list of Fonts created till now.

Definition at line 62 of file FontManager.hpp.

Referenced by acquireFont().

◆ freeTypeLibrary() [1/2]

const void* vl::FontManager::freeTypeLibrary ( ) const
inline

Returns the FT_Library handle.

Definition at line 71 of file FontManager.hpp.

◆ freeTypeLibrary() [2/2]

void* vl::FontManager::freeTypeLibrary ( )
inline

Returns the FT_Library handle.

Definition at line 74 of file FontManager.hpp.

◆ releaseAllFonts()

void FontManager::releaseAllFonts ( )

Releases all Fonts and associated resources and memory.

Definition at line 94 of file FontManager.cpp.

References mFonts.

Referenced by ~FontManager().

◆ releaseFont()

void FontManager::releaseFont ( Font font)

Releases a given Font and its associated resources and memory.

Definition at line 87 of file FontManager.cpp.

References mFonts.

◆ setFreeTypeLibrary()

void* vl::FontManager::setFreeTypeLibrary ( void *  ftlib)
inline

Sets the FT_Library to the given one and returns the former one.

It is the user responsibility to dispose the returned one (if non-NULL).

Definition at line 78 of file FontManager.hpp.

Member Data Documentation

◆ mFonts

std::vector< ref<Font> > vl::FontManager::mFonts
protected

Definition at line 81 of file FontManager.hpp.

Referenced by acquireFont(), releaseAllFonts(), and releaseFont().

◆ mFreeTypeLibrary

void* vl::FontManager::mFreeTypeLibrary
protected

Definition at line 82 of file FontManager.hpp.

Referenced by FontManager(), and ~FontManager().


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