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) | |
ofTrueTypeFont & | operator= (const ofTrueTypeFont &mom) |
ofTrueTypeFont (ofTrueTypeFont &&mom) | |
ofTrueTypeFont & | operator= (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 ofRectangle & | getGlyphBBox () 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< ofPath > | getStringAsPoints (const std::string &str, bool vflip=true, bool filled=true) const |
const ofMesh & | getStringMesh (const std::string &s, float x, float y, bool vflip=true) const |
const ofTexture & | getFontTexture () 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()
|
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()
|
inlinestatic |
◆ drawString()
void ofTrueTypeFont::drawString | ( | const std::string & | s, |
float | x, | ||
float | y | ||
) | const |
Draws a string s at position x,y.
- Parameters
-
s String to draw x X position of string y Y 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
-
x X position of shapes y Y 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()
|
inline |
◆ getCharWidth()
|
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
-
s The string to get bounding box of. x X position of returned rectangle. y Y 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()
|
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
-
filename The name of the font file to load. fontsize The size in pixels to load the font. _bAntiAliased true if the font should be anti-aliased. _bFullCharacterSet true if the full character set should be cached. makeContours true if the vector contours should be cached. simplifyAmt the amount to simplify the vector contours. Larger number means more simplified. dpi the 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()
|
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
-
spacing Scale 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
-
height Line 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
-
size Scales 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
-
s The 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
-
s The string to get the width of.
- Returns
- the string width.
Friends And Related Symbol Documentation
◆ ofExitCallback
|
friend |
The documentation for this class was generated from the following files:
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/graphics/ofTrueTypeFont.h
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/graphics/ofTrueTypeFont.cpp