18 #ifndef ION_TEXT_FONTMANAGER_H_
19 #define ION_TEXT_FONTMANAGER_H_
26 #include "ion/external/gtest/gunit_prod.h"
42 void AddFont(
const FontPtr& font);
50 const FontPtr AddFont(
const std::string&
name,
size_t size_in_pixels,
51 size_t sdf_padding,
const void* data,
size_t data_size);
56 const FontPtr AddFontFromZipasset(
const std::string& font_name,
57 const std::string& zipasset_name,
58 size_t size_in_pixels,
63 const FontPtr FindFont(
const std::string& name,
size_t size_in_pixels,
64 size_t sdf_padding)
const;
71 font_image_map_[key] = font_image;
73 font_image_map_.erase(key);
81 CacheFontImage(BuildFontKeyFromFont(*font), font_image);
86 const FontImageMap::const_iterator it = font_image_map_.find(key);
87 return it == font_image_map_.end() ?
FontImagePtr() : it->second;
92 return GetCachedFontImage(BuildFontKeyFromFont(*font));
105 static const std::string BuildFontKeyFromFont(
const Font& font) {
112 static const std::string BuildFontKey(
113 const std::string& name,
size_t size_in_pixels,
size_t sdf_padding);
118 FontImageMap font_image_map_;
121 FRIEND_TEST(FontManagerTest, BuildFontKey);
130 #endif // ION_TEXT_FONTMANAGER_H_
size_t GetSdfPadding() const
Returns the padding value used when generating SDF glyphs from the font.
void CacheFontImage(const FontPtr &font, const FontImagePtr &font_image)
This can be used to cache FontImage instances in the manager.
const FontImagePtr GetCachedFontImage(const FontPtr &font) const
Returns the FontImage associated with the given Font. It may be NULL.
size_t GetSizeInPixels() const
Returns the size of the font in pixels.
Thread-safe abstract base class.
The FontManager provides the main interface for fonts used to create text strings to render...
const FontImagePtr GetCachedFontImage(const std::string &key) const
Returns the FontImage associated with the given key. It may be NULL.
T * Get() const
Returns a raw pointer to the instance, which may be NULL.
const std::string & GetName() const
Returns the name of the font.
void CacheFontImage(const std::string &key, const FontImagePtr &font_image)
This can be used to cache FontImage instances in the manager.
base::ReferentPtr< FontImage >::Type FontImagePtr
Convenience typedef for shared pointer to a FontImage.
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
base::ReferentPtr< FontManager >::Type FontManagerPtr
Convenience typedef for shared pointer to a FontManager.
Font is a base class for implementation-specific representations of fonts.