diff options
Diffstat (limited to 'plugingui/font.h')
-rw-r--r-- | plugingui/font.h | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/plugingui/font.h b/plugingui/font.h index b47fbde..e29528d 100644 --- a/plugingui/font.h +++ b/plugingui/font.h @@ -24,11 +24,10 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_FONT_H__ -#define __DRUMGIZMO_FONT_H__ +#pragma once #include <string> -#include <map> +#include <array> #include "pixelbuffer.h" #include "image.h" @@ -37,27 +36,29 @@ namespace GUI { class Font { public: - Font(std::string fontfile = ":font.png"); - - void setFace(std::string face); - std::string face(); + Font(const std::string& fontfile = ":font.png"); - void setSize(size_t points); - size_t size(); + size_t textWidth(const std::string& text) const; + size_t textHeight(const std::string& text = "") const; - size_t textWidth(std::string text); - size_t textHeight(std::string text = ""); + void setLetterSpacing(int letterSpacing); + int letterSpacing() const; - PixelBufferAlpha *render(std::string text); + PixelBufferAlpha *render(const std::string& text) const; private: - Image img_font; + Image img_font; - std::map<char, int> character_offset; - std::map<char, size_t> character_width; - std::map<char, int> character_pre_bias; - std::map<char, int> character_post_bias; -}; + class Character { + public: + int offset{0}; + size_t width{0}; + int pre_bias{0}; + int post_bias{0}; + }; + std::array<Character, 255> characters; + int spacing{1}; }; -#endif/*__DRUMGIZMO_FONT_H__*/ + +} // GUI:: |