23 #if defined(ION_PLATFORM_MAC) || defined(ION_PLATFORM_IOS)
42 font_image_map_(*this) {}
48 font_map_[BuildFontKeyFromFont(*font)] = font;
52 const std::string&
name,
size_t size_in_pixels,
53 size_t sdf_padding,
const void* data,
size_t data_size) {
58 #if defined(ION_PLATFORM_MAC) || defined(ION_PLATFORM_IOS)
60 name, size_in_pixels, sdf_padding, data, data_size));
63 name, size_in_pixels, sdf_padding, data, data_size));
70 const std::string& zipasset_name,
71 size_t size_in_pixels,
78 const std::string& data =
81 LOG(
ERROR) <<
"Unable to read data for font \"" << font_name <<
"\".";
85 return AddFont(font_name, size_in_pixels, sdf_padding, &data[0], data.size());
89 const std::string&
name,
size_t size_in_pixels,
size_t sdf_padding)
const {
90 const std::string key = BuildFontKey(name, size_in_pixels, sdf_padding);
91 FontMap::const_iterator it = font_map_.find(key);
92 return it == font_map_.end() ?
FontPtr() : it->second;
95 const std::string FontManager::BuildFontKey(
96 const std::string&
name,
size_t size_in_pixels,
size_t sdf_padding) {
98 s << name <<
'/' << size_in_pixels <<
'/' << sdf_padding;
bool IsInvalidReference(const T &value)
IsInvalidReference() returns true if a passed const reference of type T has an address of InvalidRefe...
This derived Font class represents a FreeType2 font.
#define LOG(severity)
Logs the streamed message unconditionally with a severity of severity.
const FontPtr AddFontFromZipasset(const std::string &font_name, const std::string &zipasset_name, size_t size_in_pixels, size_t sdf_padding)
Constructs and adds a font with name font_name from the zipasset with name zipasset_name.
This represents a single CoreText font.
static const std::string & GetFileData(const std::string &filename)
Returns the data of the passed filename if the manager contains it.
T * Get() const
Returns a raw pointer to the instance, which may be NULL.
base::ReferentPtr< Font >::Type FontPtr
void AddFont(const FontPtr &font)
Adds a Font to the manager.
~FontManager() override
The destructor is protected because all base::Referent classes must have protected or private destruc...
void Reset(T *new_shared)
Changes the pointer to point to the given shared, which may be NULL.
const FontPtr FindFont(const std::string &name, size_t size_in_pixels, size_t sdf_padding) const
Returns the Font associated with the given name and size.
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
FontManager()
FontManager functions.