diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
commit | 6352e8e3196f78388b6c771073f9e03eaa612673 (patch) | |
tree | e23772f79a7fbc41bc9108951e9e136857484bf4 /source/core/StarFont.hpp | |
parent | 6741a057e5639280d85d0f88ba26f000baa58f61 (diff) |
everything everywhere
all at once
Diffstat (limited to 'source/core/StarFont.hpp')
-rw-r--r-- | source/core/StarFont.hpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/source/core/StarFont.hpp b/source/core/StarFont.hpp new file mode 100644 index 0000000..954f27a --- /dev/null +++ b/source/core/StarFont.hpp @@ -0,0 +1,48 @@ +#ifndef STAR_FONT_HPP +#define STAR_FONT_HPP + +#include "StarString.hpp" +#include "StarImage.hpp" +#include "StarByteArray.hpp" +#include "StarMap.hpp" + +namespace Star { + +STAR_EXCEPTION(FontException, StarException); + +STAR_STRUCT(FontImpl); +STAR_CLASS(Font); + +class Font { +public: + static FontPtr loadTrueTypeFont(String const& fileName, unsigned pixelSize = 12); + static FontPtr loadTrueTypeFont(ByteArrayConstPtr const& bytes, unsigned pixelSize = 12); + + Font(); + + Font(Font const&) = delete; + Font const& operator=(Font const&) = delete; + + // Create a new font from the same data + FontPtr clone() const; + + void setPixelSize(unsigned pixelSize); + + unsigned height() const; + unsigned width(String::Char c); + + // May return empty image on unrenderable character (Normally, this will + // render a box, but if there is an internal freetype error this may return + // an empty image). + Image render(String::Char c); + +private: + FontImplPtr m_fontImpl; + ByteArrayConstPtr m_fontBuffer; + unsigned m_pixelSize; + HashMap<pair<String::Char, unsigned>, unsigned> m_widthCache; +}; + +} + +#endif |