#include <font.h>
Public Member Functions | |
FontInstance (FontService &service) | |
~FontInstance () | |
FontInstance (const FontInstance &rhs)=delete | |
FontInstance & | operator= (const FontInstance &rhs)=delete |
bool | create (const std::string &font, FontProperties &properties, utility::ErrorState &error) |
const FontProperties & | getProperties () const |
const std::string & | getFont () const |
bool | isValid () const |
nap::uint | getGlyphIndex (nap::uint character) const |
template<typename T > | |
T * | getOrCreateGlyphRepresentation (nap::uint index, float scale, utility::ErrorState &errorCode) |
IGlyphRepresentation * | getOrCreateGlyphRepresentation (nap::uint index, float scale, const rtti::TypeInfo &type, utility::ErrorState &errorCode) |
const Glyph * | getOrCreateGlyph (nap::uint index, float scale, utility::ErrorState &errorCode) |
void | getBoundingBox (const std::string &text, float scale, math::Rect &outRect) |
int | getCount () |
Protected Member Functions | |
void * | getFace () const |
Runtime version of a font that serves characters. Internally the font caches all the requested characters and visualization modes. A character is called a Glyph and a character visualization mode is a GlyphRepresentation. The instance is created by a Font on initialization. Use the getGlyphIndex() and getOrCreateGlyph() functions to fetch characters. All the characters (glyphs) are managed and therefore owned by this font. It is possible to create a font instance dynamically at run-time.
FontInstance | ( | FontService & | service | ) |
Create the instance based on font properties and a service
~FontInstance | ( | ) |
Destructor
|
delete |
Font can't be copied!
bool create | ( | const std::string & | font, |
FontProperties & | properties, | ||
utility::ErrorState & | error | ||
) |
Creates the actual typeface associated with the font based on the incoming set of properties. Call this after construction or when you want to change the font at run-time. If for some reason construction fails the errorState holds the error code. The previous typeface, if it exists, is destroyed when a new one is created successfully. When creation fails the current typeface remains active.
font | the font file to load. |
properties | font properties such as the size and resolution. |
error | contains the error message if construction of the typeface fails |
void getBoundingBox | ( | const std::string & | text, |
float | scale, | ||
math::Rect & | outRect | ||
) |
Returns the bounding box in pixels associated with a string of text. This bounding box tightly wraps the text and excludes initial horizontal bearing All requested glyphs are cached internally.
text | the string of characters to compute the bounding box for |
scale | glyph scaling factor |
outRect | contains the text bounds |
int getCount | ( | ) |
Returns the number of glyphs in this font, -1 when the font hasn't been created yet
|
protected |
Returns the handle to the free-type face managed by this resource Represents a FT_Face object
const std::string& getFont | ( | ) | const |
Get the index of a Glyph inside this font based on a character code Use this index to get a handle to a Glyph using getOrCreateGlyph()
character | the character code, 0 when not identified |
const Glyph* getOrCreateGlyph | ( | nap::uint | index, |
float | scale, | ||
utility::ErrorState & | errorCode | ||
) |
Returns a native Glyph object that can be represented using a Glyph Representation object. The Glyph is cached internally, to speed up future requests.
index | the index of the glyph inside the font. |
scale | glyph scaling factor |
errorCode | contains the error if the glyph could not be created or fetched |
IGlyphRepresentation* getOrCreateGlyphRepresentation | ( | nap::uint | index, |
float | scale, | ||
const rtti::TypeInfo & | type, | ||
utility::ErrorState & | errorCode | ||
) |
Use this to acquire a handle to a glyph representation, associated with a character at that index. The object can't be copied and is owned by this font. When the Glyph isn't present it is created and initialized afterwards. Use getGlyphIndex() to find the index of a specific character. type must be of type IGlyphRepresentation, multiple representations of every character are allowed. This means that you can associate multiple Glyph representations with the same character index.
index | the index of the glyph inside the font. |
scale | glyph scaling factor |
type | the type of glyph representation to create. |
errorCode | contains the error if the glyph could not be created or fetched. |
T * getOrCreateGlyphRepresentation | ( | nap::uint | index, |
float | scale, | ||
utility::ErrorState & | errorCode | ||
) |
Use this to acquire a handle to a glyph representation, associated with a character at that index. The object can't be copied and is owned by this font. When the Glyph isn't present it is created and initialized afterwards. Use getGlyphIndex() to find the index of a specific character. T must be of type IGlyphRepresentation, multiple representations of every character are allowed. This means that you can associate multiple Glyph representations with the same character index.
index | the index of the glyph inside the font. |
scale | glyph scaling factor |
errorCode | contains the error if the glyph could not be created or fetched |
const FontProperties& getProperties | ( | ) | const |
bool isValid | ( | ) | const |
|
delete |