aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Font.hh
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2012-10-02 12:24:47 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2012-10-03 08:27:16 (GMT)
commit7b6ab828c7e5453a2720462156d165707935c9ef (patch)
tree3b641791b20b1994935e149fd7461decb11bef8c /src/FbTk/Font.hh
parent032a23d1e790c5224194562a837cc80fc157ce9b (diff)
downloadfluxbox-7b6ab828c7e5453a2720462156d165707935c9ef.zip
fluxbox-7b6ab828c7e5453a2720462156d165707935c9ef.tar.bz2
Improved vertical alignment of text in FbTk::TextButton
The old formula for vertical align text inside FbTk::TextButton ('height/2 + font_ascent/2 - 1') produced not always good looking results, escpecially when different fonts are involved (eg, ClockTool and WorkspaceName have different fonts and font-sizes). '(height - font_ascent) / 2 - 1' produces better results. Additional changes: * added ASCII-Art to document the involved entities when calculating the baseline * rewritten tests/testFont.cc to accept multiples texts and multiple fonts * removed some internal parts of FbTk::Font from the public interface
Diffstat (limited to 'src/FbTk/Font.hh')
-rw-r--r--src/FbTk/Font.hh17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/FbTk/Font.hh b/src/FbTk/Font.hh
index fb399d9..6ea2571 100644
--- a/src/FbTk/Font.hh
+++ b/src/FbTk/Font.hh
@@ -43,17 +43,19 @@ class FbDrawable;
43class Font { 43class Font {
44public: 44public:
45 45
46 static const char DEFAULT_FONT[];
47
48
46 /// called at FbTk::App destruction time, cleans up cache 49 /// called at FbTk::App destruction time, cleans up cache
47 static void shutdown(); 50 static void shutdown();
48 51
49 /// @return true if multibyte is enabled, else false 52 /// @return true if multibyte is enabled, else false
50 static bool multibyte() { return s_multibyte; } 53 static bool multibyte();
51 /// @return true if utf-8 mode is enabled, else false 54 /// @return true if utf-8 mode is enabled, else false
52 static bool utf8() { return s_utf8mode; } 55 static bool utf8();
53
54 56
55 57
56 explicit Font(const char *name = "__DEFAULT__"); 58 explicit Font(const char* name = DEFAULT_FONT);
57 virtual ~Font(); 59 virtual ~Font();
58 /** 60 /**
59 Load a font 61 Load a font
@@ -76,9 +78,7 @@ public:
76 @return size of text in pixels 78 @return size of text in pixels
77 */ 79 */
78 unsigned int textWidth(const char* text, unsigned int size) const; 80 unsigned int textWidth(const char* text, unsigned int size) const;
79 unsigned int textWidth(const BiDiString &text) const { 81 unsigned int textWidth(const BiDiString &text) const;
80 return textWidth(text.visual().c_str(), text.visual().size());
81 }
82 82
83 unsigned int height() const; 83 unsigned int height() const;
84 int ascent() const; 84 int ascent() const;
@@ -119,9 +119,6 @@ private:
119 FbTk::FontImp* m_fontimp; ///< font implementation 119 FbTk::FontImp* m_fontimp; ///< font implementation
120 std::string m_fontstr; ///< font name 120 std::string m_fontstr; ///< font name
121 121
122 static bool s_multibyte; ///< if the fontimp should be a multibyte font
123 static bool s_utf8mode; ///< should the font use utf8 font imp
124
125 int m_angle; ///< rotation angle 122 int m_angle; ///< rotation angle
126 bool m_shadow; ///< shadow text 123 bool m_shadow; ///< shadow text
127 Color m_shadow_color; ///< shadow color 124 Color m_shadow_color; ///< shadow color