aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Font.hh
diff options
context:
space:
mode:
authormathias <mathias>2005-06-03 07:25:48 (GMT)
committermathias <mathias>2005-06-03 07:25:48 (GMT)
commitef76b45ab1857af1b12f0c336bfb8c0f19140aeb (patch)
treee380d87f9e4c5e1b27f7aeb8d3aa8acbe0e09d2c /src/FbTk/Font.hh
parent9c27e2e7993c9ccd604f77219a1f07c1be22e75a (diff)
downloadfluxbox-ef76b45ab1857af1b12f0c336bfb8c0f19140aeb.zip
fluxbox-ef76b45ab1857af1b12f0c336bfb8c0f19140aeb.tar.bz2
- Usage of xft-fonts is prefered, except a font-description starts with '-'
- Removed "antialias"-option completly, to enable/disable "antialias" use either <fontname>:antialias=<bool> in the style or use Xft.antialias: <bool> in your .Xdefaults - Added new styleresources: *.font.effect: <halo|shadow> *.font.shadow.x : <int> - shadow x offset *.font.shadow.y : <int> - shadow y offset *.font.shadow.color : <color> - color of shadow *.font.halo.color : <color> - color of halo - Removed 'shadow' and 'halo' options from fontdefinitions: !! Style authors have to update their styles !! - Simplified XmbFontImp to not try all possible fonts to match locale - Style authors may specify multiple fonts: <font1>|<font2>|<font3> if loading of font1 fails, fluxbox probes <font2>, etc. The last font is "fixed". Hints for style authors: - if xft tries to load a font it will _ALWAYS_ return a valid font, it doesnt have to look like the one you want to have, read more about it: http://fontconfig.org/fontconfig-user.html - export XFT_DEBUG=1 before running fluxbox helps to see which fonts are picked. eg: *.font: Verdana,Arial-12:antialias=true|-artwiz-snap-*- if fluxbox is compiled with xft this will NEVER try to load "-artwiz-snap-*-" since xft gives for sure a font, most likely Verdana or Arial but noone knows. So, if fluxbox has no xft support the first fontpattern fails and fluxbox tries the next one, which might be successful. if everything fails, it will use "fixed" - Added caching of fonts, fonts are only loaded once. - Fixed #1090902 (slow utf8 start)
Diffstat (limited to 'src/FbTk/Font.hh')
-rw-r--r--src/FbTk/Font.hh40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/FbTk/Font.hh b/src/FbTk/Font.hh
index d8f0f46..d322097 100644
--- a/src/FbTk/Font.hh
+++ b/src/FbTk/Font.hh
@@ -28,7 +28,6 @@
28#include <X11/Xresource.h> 28#include <X11/Xresource.h>
29 29
30#include <string> 30#include <string>
31#include <memory>
32 31
33#ifdef HAVE_CONFIG_H 32#ifdef HAVE_CONFIG_H
34#include "config.h" 33#include "config.h"
@@ -38,6 +37,8 @@
38#include <iconv.h> 37#include <iconv.h>
39#endif // HAVE_ICONV 38#endif // HAVE_ICONV
40 39
40#include "Color.hh"
41
41namespace FbTk { 42namespace FbTk {
42 43
43class FontImp; 44class FontImp;
@@ -56,13 +57,13 @@ public:
56 static void shutdown(); 57 static void shutdown();
57 58
58 /// @return true if multibyte is enabled, else false 59 /// @return true if multibyte is enabled, else false
59 static bool multibyte() { return m_multibyte; } 60 static bool multibyte() { return s_multibyte; }
60 /// @return true if utf-8 mode is enabled, else false 61 /// @return true if utf-8 mode is enabled, else false
61 static bool utf8() { return m_utf8mode; } 62 static bool utf8() { return s_utf8mode; }
62 63
63 64
64 65
65 Font(const char *name=0, bool antialias = false); 66 Font(const char *name = "fixed");
66 virtual ~Font(); 67 virtual ~Font();
67 /** 68 /**
68 Load a font 69 Load a font
@@ -70,10 +71,15 @@ public:
70 loaded font 71 loaded font
71 */ 72 */
72 bool load(const std::string &name); 73 bool load(const std::string &name);
73 74
74 void setAntialias(bool flag); 75 void setHalo(bool flag) { m_halo = flag; if (m_halo) setShadow(false); }
75 inline void setShadow(bool flag) { m_shadow = flag; if (m_shadow) setHalo(false); } 76 void setHaloColor(const Color& color) { m_halo_color = color; }
76 inline void setHalo(bool flag) { m_halo = flag; if (m_halo) setShadow(false); } 77
78 void setShadow(bool flag) { m_shadow = flag; if (m_shadow) setHalo(false); }
79 void setShadowColor(const Color& color) { m_shadow_color = color; }
80 void setShadowOffX(int offx) { m_shadow_offx = offx; }
81 void setShadowOffY(int offy) { m_shadow_offy = offy; }
82
77 /** 83 /**
78 @param text text to check size 84 @param text text to check size
79 @param size length of text in bytes 85 @param size length of text in bytes
@@ -103,28 +109,28 @@ public:
103 void drawText(const FbDrawable &w, int screen, GC gc, 109 void drawText(const FbDrawable &w, int screen, GC gc,
104 const char *text, size_t len, 110 const char *text, size_t len,
105 int x, int y, bool rotate=true) const; 111 int x, int y, bool rotate=true) const;
106 bool isAntialias() const { return m_antialias; }
107 /// @return true if the font is rotated, else false 112 /// @return true if the font is rotated, else false
108 bool isRotated() const { return m_rotated; } 113 bool isRotated() const { return m_rotated; }
109 /// @return rotated angle 114 /// @return rotated angle
110 float angle() const { return m_angle; } 115 float angle() const { return m_angle; }
111 bool shadow() const { return m_shadow; } 116 bool hasShadow() const { return m_shadow; }
112 bool halo() const { return m_halo; } 117 bool hasHalo() const { return m_halo; }
113private: 118private:
114 119
115 std::auto_ptr<FontImp> m_fontimp; ///< font implementation 120 FbTk::FontImp* m_fontimp; ///< font implementation
116 std::string m_fontstr; ///< font name 121 std::string m_fontstr; ///< font name
117 static bool m_multibyte; ///< if the fontimp should be a multibyte font 122
118 static bool m_utf8mode; ///< should the font use utf8 font imp 123 static bool s_multibyte; ///< if the fontimp should be a multibyte font
119 bool m_antialias; ///< is font antialias 124 static bool s_utf8mode; ///< should the font use utf8 font imp
125
120 bool m_rotated; ///< wheter we're rotated or not 126 bool m_rotated; ///< wheter we're rotated or not
121 float m_angle; ///< rotation angle 127 float m_angle; ///< rotation angle
122 bool m_shadow; ///< shadow text 128 bool m_shadow; ///< shadow text
123 std::string m_shadow_color; ///< shadow color 129 Color m_shadow_color; ///< shadow color
124 int m_shadow_offx; ///< offset y for shadow 130 int m_shadow_offx; ///< offset y for shadow
125 int m_shadow_offy; ///< offset x for shadow 131 int m_shadow_offy; ///< offset x for shadow
126 bool m_halo; ///< halo text 132 bool m_halo; ///< halo text
127 std::string m_halo_color; ///< halo color 133 Color m_halo_color; ///< halo color
128#ifdef HAVE_ICONV 134#ifdef HAVE_ICONV
129 iconv_t m_iconv; 135 iconv_t m_iconv;
130#else 136#else