From 5d76d943eca9734f7df2dc351871815385c571b3 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 31 Oct 2015 14:44:23 +0100 Subject: Font refactoring. Some rendering optimizations on ScrollBar, LineEdit and ListBoxBasic. --- plugingui/font.h | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'plugingui/font.h') diff --git a/plugingui/font.h b/plugingui/font.h index b47fbde..c7fe67e 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 -#include +#include #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); + size_t textHeight(const std::string& text = ""); - size_t textWidth(std::string text); - size_t textHeight(std::string text = ""); - - PixelBufferAlpha *render(std::string text); + PixelBufferAlpha *render(const std::string& text); private: - Image img_font; + Image img_font; - std::map character_offset; - std::map character_width; - std::map character_pre_bias; - std::map character_post_bias; -}; + struct Character { + int offset = 0; + size_t width = 0; + int pre_bias = 0; + int post_bias = 0; + }; + std::array characters; + +// std::map character_offset; +// std::map character_width; +// std::map character_pre_bias; +// std::map character_post_bias; }; -#endif/*__DRUMGIZMO_FONT_H__*/ + +} // GUI:: -- cgit v1.2.3