reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

#include <ofTrueTypeFont.h>

Public Member Functions

 ofTrueTypeFont ()
 Construct a default ofTrueTypeFont.
 
virtual ~ofTrueTypeFont ()
 Destroy the ofTrueTypeFont.
 
 ofTrueTypeFont (const ofTrueTypeFont &mom)
 
ofTrueTypeFontoperator= (const ofTrueTypeFont &mom)
 
 ofTrueTypeFont (ofTrueTypeFont &&mom)
 
ofTrueTypeFontoperator= (ofTrueTypeFont &&mom)
 
void setDirection (ofTrueTypeFontDirection direction)
 
float getCharWidth (uint32_t c) const
 
float getCharAdvance (uint32_t c) const
 
Load Font
bool load (const of::filesystem::path &filename, int fontsize, bool _bAntiAliased=true, bool _bFullCharacterSet=true, bool makeContours=false, float simplifyAmt=0.0f, int dpi=0)
 Loads the font specified by filename, allows you to control size, aliasing, and other parameters.
 
 OF_DEPRECATED_MSG ("Use load instead", bool loadFont(std::string filename, int fontsize, bool _bAntiAliased=true, bool _bFullCharacterSet=false, bool makeContours=false, float simplifyAmt=0.0f, int dpi=0))
 
bool load (const ofTrueTypeFontSettings &settings)
 
bool isLoaded () const
 Has the font been loaded successfully?
 
Font Size
int getSize () const
 Returns the size of the font.
 
float getLineHeight () const
 Computes line height based on font size.
 
void setLineHeight (float height)
 Sets line height for text drawn on screen.
 
float getAscenderHeight () const
 Get the ascender distance for this font.
 
float getDescenderHeight () const
 Get the descender distance for this font.
 
const ofRectanglegetGlyphBBox () const
 Get the global bounding box for this font.
 
float getLetterSpacing () const
 Returns letter spacing of font object.
 
void setLetterSpacing (float spacing)
 Sets the letter spacing of the font object.
 
float getSpaceSize () const
 Returns a variable that represents how wide spaces are.
 
void setSpaceSize (float size)
 Sets the width for the whitespace character for this font.
 
float stringWidth (const std::string &s) const
 Returns the string width.
 
float stringHeight (const std::string &s) const
 Returns the string height.
 
ofRectangle getStringBoundingBox (const std::string &s, float x, float y, bool vflip=true) const
 Returns the bounding box of a string as a rectangle.
 
Drawing
void drawString (const std::string &s, float x, float y) const
 Draws a string s at position x,y.
 
void drawStringAsShapes (const std::string &s, float x, float y) const
 Draws the string as if it was geometrical shapes.
 
ofPath getCharacterAsPoints (uint32_t character, bool vflip=true, bool filled=true) const
 
std::vector< ofPathgetStringAsPoints (const std::string &str, bool vflip=true, bool filled=true) const
 
const ofMeshgetStringMesh (const std::string &s, float x, float y, bool vflip=true) const
 
const ofTexturegetFontTexture () const
 
ofTexture getStringTexture (const std::string &s, bool vflip=true) const
 
glm::vec2 getFirstGlyphPosForTexture (const std::string &str, bool vflip) const
 
bool isValidGlyph (uint32_t) const
 

Static Public Member Functions

static double int26p6_to_dbl (long p)
 
static int dbl_to_int26p6 (double p)
 

Friends

void ofExitCallback ()
 

Font Settings

bool isAntiAliased () const
 Is the font anti-aliased?
 
bool hasFullCharacterSet () const
 Does the font have a full character set?
 
std::size_t getNumCharacters () const
 Get the number of characters in the loaded character set.
 
static void setGlobalDpi (int newDpi)
 Set the default dpi for all typefaces.
 

Constructor & Destructor Documentation

◆ ofTrueTypeFont() [1/3]

ofTrueTypeFont::ofTrueTypeFont ( )

Construct a default ofTrueTypeFont.

◆ ~ofTrueTypeFont()

ofTrueTypeFont::~ofTrueTypeFont ( )
virtual

Destroy the ofTrueTypeFont.

◆ ofTrueTypeFont() [2/3]

ofTrueTypeFont::ofTrueTypeFont ( const ofTrueTypeFont mom)

◆ ofTrueTypeFont() [3/3]

ofTrueTypeFont::ofTrueTypeFont ( ofTrueTypeFont &&  mom)

Member Function Documentation

◆ dbl_to_int26p6()

static int ofTrueTypeFont::dbl_to_int26p6 ( double  p)
inlinestatic

◆ drawString()

void ofTrueTypeFont::drawString ( const std::string &  s,
float  x,
float  y 
) const

Draws a string s at position x,y.

Parameters
sString to draw
xX position of string
yY position of string

◆ drawStringAsShapes()

void ofTrueTypeFont::drawStringAsShapes ( const std::string &  s,
float  x,
float  y 
) const

Draws the string as if it was geometrical shapes.

Uses the information contained in ofTTFContour and ofTTFCharacter.

Parameters
xX position of shapes
yY position of shapes

◆ getAscenderHeight()

float ofTrueTypeFont::getAscenderHeight ( ) const

Get the ascender distance for this font.

The ascender is the vertical distance from the baseline to the highest "character" coordinate. The meaning of "character" coordinate depends on the font. Some fonts take accents into account, others do not, and still others define it simply to be the highest coordinate over all glyphs.

Returns
the font ascender height in pixels.

◆ getCharacterAsPoints()

ofPath ofTrueTypeFont::getCharacterAsPoints ( uint32_t  character,
bool  vflip = true,
bool  filled = true 
) const

◆ getCharAdvance()

float ofTrueTypeFont::getCharAdvance ( uint32_t  c) const
inline

◆ getCharWidth()

float ofTrueTypeFont::getCharWidth ( uint32_t  c) const
inline

◆ getDescenderHeight()

float ofTrueTypeFont::getDescenderHeight ( ) const

Get the descender distance for this font.

The descender is the vertical distance from the baseline to the lowest "character" coordinate. The meaning of "character" coordinate depends on the font. Some fonts take accents into account, others do not, and still others define it simply to be the lowest coordinate over all glyphs. This value will be negative for descenders below the baseline (which is typical).

Returns
the font descender height in pixels.

◆ getFirstGlyphPosForTexture()

glm::vec2 ofTrueTypeFont::getFirstGlyphPosForTexture ( const std::string &  str,
bool  vflip 
) const

◆ getFontTexture()

const ofTexture & ofTrueTypeFont::getFontTexture ( ) const

◆ getGlyphBBox()

const ofRectangle & ofTrueTypeFont::getGlyphBBox ( ) const

Get the global bounding box for this font.

The global bounding box is the rectangle inside of which all glyphs in the font can fit. Glyphs are drawn starting from (0,0) in the returned box (though note that the box can extend in any direction out from the origin).

Returns
the font descender height in pixels.

◆ getLetterSpacing()

float ofTrueTypeFont::getLetterSpacing ( ) const

Returns letter spacing of font object.

You can control this by the ofTrueTypeFont::setLetterSpacing() function. 1.f = default spacing, less than 1.0 means tighter spacing, greater than 1.0 means wider spacing.

Returns
the letter spacing of font object.

◆ getLineHeight()

float ofTrueTypeFont::getLineHeight ( ) const

Computes line height based on font size.

Returns
the current line height.

◆ getNumCharacters()

std::size_t ofTrueTypeFont::getNumCharacters ( ) const

Get the number of characters in the loaded character set.

If you allocate the font using different parameters, you can load in partial and full character sets, this helps you know how many characters it can represent.

Returns
Number of characters in loaded character set.

◆ getSize()

int ofTrueTypeFont::getSize ( ) const

Returns the size of the font.

Returns
Size of font, set when font was loaded.

◆ getSpaceSize()

float ofTrueTypeFont::getSpaceSize ( ) const

Returns a variable that represents how wide spaces are.

The value returned is a scalar for the advance (=width) of the whitespace glyph, so 1.0 means that a space will be the default width of a whitespace glyph of this font, 2.0 means that it's 2 times the default width, etc.

Returns
the width of the space.

◆ getStringAsPoints()

vector< ofPath > ofTrueTypeFont::getStringAsPoints ( const std::string &  str,
bool  vflip = true,
bool  filled = true 
) const

◆ getStringBoundingBox()

ofRectangle ofTrueTypeFont::getStringBoundingBox ( const std::string &  s,
float  x,
float  y,
bool  vflip = true 
) const

Returns the bounding box of a string as a rectangle.

Parameters
sThe string to get bounding box of.
xX position of returned rectangle.
yY position of returned rectangle.
Returns
the bounding box of a string as a rectangle.

◆ getStringMesh()

const ofMesh & ofTrueTypeFont::getStringMesh ( const std::string &  s,
float  x,
float  y,
bool  vflip = true 
) const

◆ getStringTexture()

ofTexture ofTrueTypeFont::getStringTexture ( const std::string &  s,
bool  vflip = true 
) const

◆ hasFullCharacterSet()

bool ofTrueTypeFont::hasFullCharacterSet ( ) const

Does the font have a full character set?

Returns
true if the font was allocated with a full character set.

◆ int26p6_to_dbl()

static double ofTrueTypeFont::int26p6_to_dbl ( long  p)
inlinestatic

◆ isAntiAliased()

bool ofTrueTypeFont::isAntiAliased ( ) const

Is the font anti-aliased?

Returns
true if the font was set to be anti-aliased.

◆ isLoaded()

bool ofTrueTypeFont::isLoaded ( ) const

Has the font been loaded successfully?

Returns
true if the font was loaded.

◆ isValidGlyph()

bool ofTrueTypeFont::isValidGlyph ( uint32_t  glyph) const

◆ load() [1/2]

bool ofTrueTypeFont::load ( const of::filesystem::path &  filename,
int  fontsize,
bool  _bAntiAliased = true,
bool  _bFullCharacterSet = true,
bool  makeContours = false,
float  simplifyAmt = 0.0f,
int  dpi = 0 
)

Loads the font specified by filename, allows you to control size, aliasing, and other parameters.

loads a font, and allows you to set the following parameters: the filename, the size, if the font is anti-aliased, if it has a full character set, if you need it to have contours (for getStringPoints) and parameters that control the simplification amount for those contours and the dpi of the font.

default (without dpi), non-full char set, anti aliased, 96 dpi

Parameters
filenameThe name of the font file to load.
fontsizeThe size in pixels to load the font.
_bAntiAliasedtrue if the font should be anti-aliased.
_bFullCharacterSettrue if the full character set should be cached.
makeContourstrue if the vector contours should be cached.
simplifyAmtthe amount to simplify the vector contours. Larger number means more simplified.
dpithe dots per inch used to specify rendering size.
Returns
true if the font was loaded correctly.

◆ load() [2/2]

bool ofTrueTypeFont::load ( const ofTrueTypeFontSettings settings)

◆ OF_DEPRECATED_MSG()

ofTrueTypeFont::OF_DEPRECATED_MSG ( "Use load instead"  ,
bool   loadFontstd::string filename, int fontsize, bool _bAntiAliased=true, bool _bFullCharacterSet=false, bool makeContours=false, float simplifyAmt=0.0f, int dpi=0 
)

◆ operator=() [1/2]

ofTrueTypeFont & ofTrueTypeFont::operator= ( const ofTrueTypeFont mom)

◆ operator=() [2/2]

ofTrueTypeFont & ofTrueTypeFont::operator= ( ofTrueTypeFont &&  mom)

◆ setDirection()

void ofTrueTypeFont::setDirection ( ofTrueTypeFontDirection  direction)
Returns
current font direction

◆ setGlobalDpi()

void ofTrueTypeFont::setGlobalDpi ( int  newDpi)
static

Set the default dpi for all typefaces.

◆ setLetterSpacing()

void ofTrueTypeFont::setLetterSpacing ( float  spacing)

Sets the letter spacing of the font object.

1.f = default spacing, less than 1.f would be tighter spacing, greater than 1.f would be wider spacing.

Parameters
spacingScale for spacing between letters for this font.

◆ setLineHeight()

void ofTrueTypeFont::setLineHeight ( float  height)

Sets line height for text drawn on screen.

Note the line height is automatically computed based on the font size, when you load in the font.

Parameters
heightLine height for text drawn on screen.

◆ setSpaceSize()

void ofTrueTypeFont::setSpaceSize ( float  size)

Sets the width for the whitespace character for this font.

This number, which defaults to 1.0, scales the width of a whitespace, based on the width of the whitespace glyph of this font.

Setting spaceSize to 2.f will make whitespaces twice as wide, 0.5f will make whitespaces half as wide, etc.

Parameters
sizeScales the width of the whitespace glyph for this font.

◆ stringHeight()

float ofTrueTypeFont::stringHeight ( const std::string &  s) const

Returns the string height.

This is essentially the height component of the ofTrueTypeFont::getStringBoundingBox() rectangle.

Parameters
sThe string to get the height of.
Returns
the string height.

◆ stringWidth()

float ofTrueTypeFont::stringWidth ( const std::string &  s) const

Returns the string width.

This is essentially the width component of the ofTrueTypeFont::getStringBoundingBox() rectangle.

Parameters
sThe string to get the width of.
Returns
the string width.

Friends And Related Symbol Documentation

◆ ofExitCallback

void ofExitCallback ( )
friend

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