8 #ifndef META_OCEAN_CV_FONTS_FREETYPE_FT_FONT_MANAGER_H
9 #define META_OCEAN_CV_FONTS_FREETYPE_FT_FONT_MANAGER_H
15 #include <unordered_map>
44 class OCEAN_CV_FONTS_EXPORT
Face
51 typedef std::unordered_map<uint64_t, SharedFont>
FontMap;
67 inline Face(
FTFontManager& fontManager,
const FT_Face& ftFace,
const std::string& filename);
87 const std::string& filename()
const;
120 FT_Face ftFace_ =
nullptr;
129 typedef std::unordered_map<std::string, Face>
FaceMap;
134 typedef std::unordered_map<std::string, FaceMap>
FamilyMap;
165 bool registerFont(
const std::string& fontFile, std::string* familyName =
nullptr, std::string* styleName =
nullptr);
184 bool registerFont(
const void* fontMemory,
const size_t fontMemorySize, std::string* familyName =
nullptr, std::string* styleName =
nullptr);
195 bool registerFont(
const FT_Face& ftFace,
const std::string& filename, std::string* familyName =
nullptr, std::string* styleName =
nullptr);
207 SharedFont font(
const std::string& familyName,
const unsigned int size,
const std::string& styleName = std::string(),
const unsigned int dpi = 72u);
215 bool hasFont(
const std::string& familyName,
const std::string& styleName = std::string())
const;
228 std::vector<std::string>
styleNames(
const std::string& familyName)
const;
234 inline bool isValid()
const;
249 fontManager_(face.fontManager_)
251 *
this = std::move(face);
255 fontManager_(fontManager),
264 if (ftFace_ !=
nullptr)
266 FT_Done_Face(ftFace_);
This class wrapps a FreeType face.
Definition: FTFontManager.h:45
Face(const Face &face)=delete
Disabled copy constructor.
~Face()
Destructs a Face object.
Definition: FTFontManager.h:262
Face & operator=(const Face &face)=delete
Disabled copy operator.
std::string filename_
The name of the file from which the FreeType face can be acquired if requested.
Definition: FTFontManager.h:117
FontMap fontMap_
The map of font objects, one object for each individual combination of size and dpi.
Definition: FTFontManager.h:123
Face(Face &&face)
Move constructor.
Definition: FTFontManager.h:248
const std::string & filename() const
Returns the filename of this face object.
Definition: FTFontManager.h:270
FTFontManager & fontManager_
The owner of the face object.
Definition: FTFontManager.h:114
std::unordered_map< uint64_t, SharedFont > FontMap
Definition of a map mapping size and dpi to font objects.
Definition: FTFontManager.h:51
Face & operator=(Face &&face)
Move operator.
SharedFont font(const unsigned int size, const unsigned int dpi)
Returns the font associated with this Face object for a specified size.
FT_Face ftFace_
The FreeType face (which represents a font) associated with this object, nullptr if the face object n...
Definition: FTFontManager.h:120
This class implements the actual manager for all FreeType fonts.
Definition: FTFontManager.h:34
FTFontManager()
Creates a new manager for fonts.
~FTFontManager()
Destructs the FontManager object.
bool isValid() const
Returns whether this manager is valid and ready to use.
Definition: FTFontManager.h:275
bool registerFont(const void *fontMemory, const size_t fontMemorySize, std::string *familyName=nullptr, std::string *styleName=nullptr)
Registers a new font by a given font file which is already in memory.
std::vector< std::string > styleNames(const std::string &familyName) const
Returns the style names of all registered fonts with specified family name.
size_t registerSystemFonts()
Registers all fonts available on the system.
FamilyMap familyMap_
The map mapping font family names to face maps.
Definition: FTFontManager.h:239
std::unordered_map< std::string, Face > FaceMap
Definition of a map mapping style names to Face objects.
Definition: FTFontManager.h:129
Lock lock_
The manager's lock.
Definition: FTFontManager.h:245
size_t registerFonts(const std::string &fontDirectory)
Registers all font files located in a specified directory.
SharedFont font(const std::string &familyName, const unsigned int size, const std::string &styleName=std::string(), const unsigned int dpi=72u)
Returns a font with specific family name and size.
bool registerFont(const FT_Face &ftFace, const std::string &filename, std::string *familyName=nullptr, std::string *styleName=nullptr)
Registers a new font by a FreeType face.
bool hasFont(const std::string &familyName, const std::string &styleName=std::string()) const
Returns whether a specific font is registered.
FT_Library library_
The FreeType library object.
Definition: FTFontManager.h:242
bool registerFont(const std::string &fontFile, std::string *familyName=nullptr, std::string *styleName=nullptr)
Registers a new font by a given font file.
std::vector< std::string > familyNames() const
Returns the family names of all registered fonts.
std::unordered_map< std::string, FaceMap > FamilyMap
Definition of a map mapping family names to face maps.
Definition: FTFontManager.h:134
This class implements the manager for all fonts.
Definition: FontManager.h:36
This class implements a recursive lock object.
Definition: Lock.h:31
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
std::shared_ptr< Font > SharedFont
Definition of a shared font pointer.
Definition: Font.h:27
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15