Handles a pool of fonts and their associated string caches to make it easier to use fonts across various parts of an application.
More...
#include <BppFontPool.hpp>
|
| void | add (const std::string &name, const BppFontSptr &font, const BppStringCacheSptr &cache) |
| | Adds an existing font and string cache pair to the pool. More...
|
| |
| void | add (const std::string &name, BppFontSptr &&font, BppStringCacheSptr &&cache) |
| | Adds an existing font and string cache pair to the pool. More...
|
| |
| void | addWithCache (const std::string &name, const BppFontSptr &font) |
| | Adds an existing font along with a newly created corresponding string cache. More...
|
| |
| void | addWithCache (const std::string &name, const std::string &fontpath) |
| | Adds a newly loaded font along with a newly created corresponding string cache. More...
|
| |
| void | addWithoutCache (const std::string &name, const BppFontSptr &font) |
| | Adds an existing font without a corresponding string cache. More...
|
| |
| void | addWithoutCache (const std::string &name, const std::string &fontpath) |
| | Loads a font from an image archive file and adds it without a corresponding string cache. More...
|
| |
| void | alias (const std::string &existing, const std::string &newname) |
| | Adds a new name for an already added font. More...
|
| |
| BppFontSptr | getFont (const std::string &font) const |
| | Returns a shared pointer to a stored font, or an empty shared pointer if the font is not present. More...
|
| |
| BppStringCacheSptr | getStringCache (const std::string &font) const |
| | Returns a shared pointer to a string cache, or an empty shared pointer if the font is not present. More...
|
| |
| template<class String > |
| BppImageSptr | render (const std::string &font, const String &str, BppFont::Flags flags=BppFont::AlignLeft) const |
| | Renders text without going through a string cache. More...
|
| |
| template<class String > |
| ConstBppImageSptr | text (const std::string &font, const String &str, BppFont::Flags flags=BppFont::AlignLeft) const |
| | Gets text from a string cache if present, or renders from the font otherwise. More...
|
| |
Handles a pool of fonts and their associated string caches to make it easier to use fonts across various parts of an application.
- Author
- Jeff Jackowski
Definition at line 23 of file BppFontPool.hpp.
◆ add() [1/2]
Adds an existing font and string cache pair to the pool.
- Parameters
-
| name | A name for the font. Used as the key value to find the font and its string cache later. |
| font | The font object. |
| cache | A string cache made to work with the font. |
- Exceptions
-
Definition at line 15 of file BppFontPool.cpp.
◆ add() [2/2]
Adds an existing font and string cache pair to the pool.
- Parameters
-
| name | A name for the font. Used as the key value to find the font and its string cache later. |
| font | The font object. This pool will take ownership of the font. |
| cache | A string cache made to work with the font. This pool will take ownership of the string cache. |
- Exceptions
-
Definition at line 30 of file BppFontPool.cpp.
◆ addWithCache() [1/2]
| void duds::ui::graphics::BppFontPool::addWithCache |
( |
const std::string & |
name, |
|
|
const BppFontSptr & |
font |
|
) |
| |
Adds an existing font along with a newly created corresponding string cache.
- Parameters
-
| name | A name for the font. Used as the key value to find the font and its string cache later. |
| font | The font object. |
Definition at line 66 of file BppFontPool.cpp.
◆ addWithCache() [2/2]
| void duds::ui::graphics::BppFontPool::addWithCache |
( |
const std::string & |
name, |
|
|
const std::string & |
fontpath |
|
) |
| |
Adds a newly loaded font along with a newly created corresponding string cache.
- Parameters
-
| name | A name for the font. Used as the key value to find the font and its string cache later. |
| fontpath | The path to the image archive file with the font data. |
Definition at line 80 of file BppFontPool.cpp.
◆ addWithoutCache() [1/2]
| void duds::ui::graphics::BppFontPool::addWithoutCache |
( |
const std::string & |
name, |
|
|
const BppFontSptr & |
font |
|
) |
| |
Adds an existing font without a corresponding string cache.
- Parameters
-
| name | A name for the font. Used as the key value to find the font and its string cache later. |
| font | The font object. |
Definition at line 45 of file BppFontPool.cpp.
◆ addWithoutCache() [2/2]
| void duds::ui::graphics::BppFontPool::addWithoutCache |
( |
const std::string & |
name, |
|
|
const std::string & |
fontpath |
|
) |
| |
Loads a font from an image archive file and adds it without a corresponding string cache.
- Parameters
-
| name | A name for the font. Used as the key value to find the font and its string cache later. |
| fontpath | The path to the image archive file with the font data. |
Definition at line 56 of file BppFontPool.cpp.
◆ alias()
| void duds::ui::graphics::BppFontPool::alias |
( |
const std::string & |
existing, |
|
|
const std::string & |
newname |
|
) |
| |
Adds a new name for an already added font.
The font and its string cache will both be available from both names, and any other aliased names.
- Parameters
-
| existing | The name of the already added font to alias. |
| newname | The additional name to give the existing font. |
- Exceptions
-
Definition at line 91 of file BppFontPool.cpp.
◆ getFc()
| void duds::ui::graphics::BppFontPool::getFc |
( |
FontAndCache & |
fc, |
|
|
const std::string & |
font |
|
) |
| const |
|
private |
◆ getFont()
| BppFontSptr duds::ui::graphics::BppFontPool::getFont |
( |
const std::string & |
font | ) |
const |
Returns a shared pointer to a stored font, or an empty shared pointer if the font is not present.
- Parameters
-
| font | The name of the font to find. |
- Returns
- The shared pointer to the font. It will be empty if there is no font with the given name.
Definition at line 104 of file BppFontPool.cpp.
◆ getStringCache()
| BppStringCacheSptr duds::ui::graphics::BppFontPool::getStringCache |
( |
const std::string & |
font | ) |
const |
Returns a shared pointer to a string cache, or an empty shared pointer if the font is not present.
- Parameters
-
| font | The name of the font with the string cache. |
- Returns
- The shared pointer to the string cache. It will be empty if there is no font with the given name.
Definition at line 114 of file BppFontPool.cpp.
◆ render()
Renders text without going through a string cache.
Calls BppFont::render() and returns the result.
- Template Parameters
-
| String | The type of the string to render. It can be std::string for UTF-8, or std::u32string for UTF-32. |
- Parameters
-
| font | The name of the font to use. |
| str | The string to render. |
| flags | The option flags. The default is to render varying width, fixed height text with each line aligned to the left. |
- Returns
- The image with the rendered text.
Definition at line 144 of file BppFontPool.hpp.
◆ text()
Gets text from a string cache if present, or renders from the font otherwise.
Calls BppStringCache::text() and returns the result.
- Template Parameters
-
| String | The type of the string to render. It can be std::string for UTF-8, or std::u32string for UTF-32. |
- Parameters
-
| font | The name of the font to use. |
| str | The string to render. |
| flags | The option flags. The default is to render varying width, fixed height text with each line aligned to the left. |
- Returns
- The image with the rendered text.
Definition at line 170 of file BppFontPool.hpp.
◆ block
◆ fonts
| std::unordered_map<std::string, FontAndCache> duds::ui::graphics::BppFontPool::fonts |
|
private |
The documentation for this class was generated from the following files: