From 61377a931e73d560ae04d5747897fe3223a6bea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 23 Jun 2013 17:23:47 +0200 Subject: [PATCH] Text: ability to create glyph cache from all characters. --- src/Text/AbstractFont.cpp | 2 ++ src/Text/AbstractFont.h | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Text/AbstractFont.cpp b/src/Text/AbstractFont.cpp index ba2039a88..aad5e564a 100644 --- a/src/Text/AbstractFont.cpp +++ b/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)); } diff --git a/src/Text/AbstractFont.h b/src/Text/AbstractFont.h index de2f4cf45..6b1450bc2 100644 --- a/src/Text/AbstractFont.h +++ b/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);