#ifndef _GUI_FONT_FACTORY_H #define _GUI_FONT_FACTORY_H #include #include #include "gui_freetype_font.h" struct TrueTypeFontParameters { TrueTypeFontParameters( const irr::core::string& fileName, unsigned int size, bool antiAlias, bool transparency ) : FileName(fileName), Size(size), AntiAlias(antiAlias), Transparency(transparency) {} TrueTypeFontParameters() : Size(0), AntiAlias(false), Transparency(false) {} bool isValid(); irr::core::string FileName; unsigned int Size; bool AntiAlias; bool Transparency; }; // A font factory for truetype fonts, using the freetype library class TrueTypeFontFactory : public irr::gui::IGUIFontFactory { public: TrueTypeFontFactory(irr::video::IVideoDriver* driver); virtual ~TrueTypeFontFactory(); //! adds a font to the GUI Environment based on its name //! In this case the name has the format: "filename|parameters" //! valid parameters are: //! the size in digits //! a for antialiasing //! t for transparency //! example: "vera.ttf|18at" would load file vera.ttf with size 18 antialiased and transparent /** \param typeName: name of the font to add. \return Returns pointer to the new font or null if not successful. */ virtual irr::gui::IGUIFont* addGUIFont(const irr::core::string& fontName); //! return a string for the given parameters which can be used in addGUIFont static irr::core::string makeFontName(const TrueTypeFontParameters ¶meters); //! return the parameters which can be received by parsing the given fontname static TrueTypeFontParameters parseFontName(const irr::core::string& fontName); private: irr::video::IVideoDriver* Driver; // note: using std::map instead or irr::map, because the irr::map has so far no good interface typedef std::map, CGUITTFace*> FaceMap; FaceMap mFaceMap; typedef std::map, irr::gui::IGUIFont*> FontMap; FontMap mFontMap; }; #endif // _GUI_FONT_FACTORY_H