Browse Source

Text: ability to create glyph cache from all characters.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
61377a931e
  1. 2
      src/Text/AbstractFont.cpp
  2. 12
      src/Text/AbstractFont.h

2
src/Text/AbstractFont.cpp

@ -105,6 +105,8 @@ void AbstractFont::close() {
void AbstractFont::createGlyphCache(GlyphCache* const cache, const std::string& characters) {
CORRADE_ASSERT(isOpened(), "Text::AbstractFont::createGlyphCache(): no font opened", );
CORRADE_ASSERT(!characters.empty() || features() & Feature::Enumerable,
"Text::AbstractFont::createGlyphCache(): the font is not enumerable, can't create cache from all characters", );
doCreateGlyphCache(cache, Utility::Unicode::utf32(characters));
}

12
src/Text/AbstractFont.h

@ -81,7 +81,13 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* The format is multi-file, thus openSingleData() convenience
* function cannot be used.
*/
MultiFile = 1 << 1
MultiFile = 1 << 1,
/**
* The font is enumerable, i.e. it is possible to loop over all
* characters in the font.
*/
Enumerable = 1 << 2
};
/** @brief Set of features supported by this importer */
@ -146,7 +152,9 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @param cache Glyph cache instance
* @param characters UTF-8 characters to render
*
* Fills the cache with given characters.
* Fills the cache with given characters. If @ref Feature "Feature::Enumerable"
* is supported, @p characters can be empty and all glyphs from given
* font will be added to the cache.
*/
void createGlyphCache(GlyphCache* cache, const std::string& characters);

Loading…
Cancel
Save