2
// Copyright (c) 2002 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot org)
4
// Permission is hereby granted, free of charge, to any person obtaining a
5
// copy of this software and associated documentation files (the "Software"),
6
// to deal in the Software without restriction, including without limitation
7
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
// and/or sell copies of the Software, and to permit persons to whom the
9
// Software is furnished to do so, subject to the following conditions:
11
// The above copyright notice and this permission notice shall be included in
12
// all copies or substantial portions of the Software.
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
// DEALINGS IN THE SOFTWARE.
22
//$Id: Font.hh 4043 2005-06-03 07:25:48Z mathias $
28
#include <X11/Xresource.h>
34
#endif // HAVE_CONFIG_H
48
Handles the client to fontimp bridge.
53
/// called at FbTk::App creation time, initializes some stuff
56
/// called at FbTk::App destruction time, cleans up what was inited first
57
static void shutdown();
59
/// @return true if multibyte is enabled, else false
60
static bool multibyte() { return s_multibyte; }
61
/// @return true if utf-8 mode is enabled, else false
62
static bool utf8() { return s_utf8mode; }
66
Font(const char *name = "fixed");
70
@return true on success, else false and it'll fall back on the last
73
bool load(const std::string &name);
75
void setHalo(bool flag) { m_halo = flag; if (m_halo) setShadow(false); }
76
void setHaloColor(const Color& color) { m_halo_color = color; }
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; }
84
@param text text to check size
85
@param size length of text in bytes
86
@return size of text in pixels
88
unsigned int textWidth(const char * const text, unsigned int size) const;
89
unsigned int height() const;
93
Rotate font in any angle
94
(currently only 90 degrees supported and just XFont implementation)
96
void rotate(float angle);
99
Draws text to drawable
100
@param w the drawable
101
@param screen screen number
102
@param gc Graphic Context
103
@param text the text buffer
104
@param len size of text buffer
107
@param rotate if the text should be drawn rotated (if it's rotated before)
109
void drawText(const FbDrawable &w, int screen, GC gc,
110
const char *text, size_t len,
111
int x, int y, bool rotate=true) const;
112
/// @return true if the font is rotated, else false
113
bool isRotated() const { return m_rotated; }
114
/// @return rotated angle
115
float angle() const { return m_angle; }
116
bool hasShadow() const { return m_shadow; }
117
bool hasHalo() const { return m_halo; }
120
FbTk::FontImp* m_fontimp; ///< font implementation
121
std::string m_fontstr; ///< font name
123
static bool s_multibyte; ///< if the fontimp should be a multibyte font
124
static bool s_utf8mode; ///< should the font use utf8 font imp
126
bool m_rotated; ///< wheter we're rotated or not
127
float m_angle; ///< rotation angle
128
bool m_shadow; ///< shadow text
129
Color m_shadow_color; ///< shadow color
130
int m_shadow_offx; ///< offset y for shadow
131
int m_shadow_offy; ///< offset x for shadow
132
bool m_halo; ///< halo text
133
Color m_halo_color; ///< halo color
141
} //end namespace FbTk
143
#endif //FBTK_FONT_HH