diff options
author | fluxgen <fluxgen> | 2002-10-16 23:13:54 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-10-16 23:13:54 (GMT) |
commit | 460d3850919831c107b28c09881f857647444745 (patch) | |
tree | 538bbce57aada7c85820ac04b2ffc0d6390be9b3 /src/XftFontImp.cc | |
parent | 0ea4319159dbe49d67b83c93dce745b9c2772404 (diff) | |
download | fluxbox-460d3850919831c107b28c09881f857647444745.zip fluxbox-460d3850919831c107b28c09881f857647444745.tar.bz2 |
utf8
Diffstat (limited to 'src/XftFontImp.cc')
-rw-r--r-- | src/XftFontImp.cc | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/src/XftFontImp.cc b/src/XftFontImp.cc index d31a74e..619b791 100644 --- a/src/XftFontImp.cc +++ b/src/XftFontImp.cc | |||
@@ -19,12 +19,13 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | //$Id: XftFontImp.cc,v 1.1 2002/10/14 18:14:20 fluxgen Exp $ | 22 | //$Id: XftFontImp.cc,v 1.2 2002/10/16 23:13:15 fluxgen Exp $ |
23 | 23 | ||
24 | #include "XftFontImp.hh" | 24 | #include "XftFontImp.hh" |
25 | #include "BaseDisplay.hh" | 25 | #include "BaseDisplay.hh" |
26 | 26 | ||
27 | XftFontImp::XftFontImp(const char *name):m_xftfont(0) { | 27 | XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0), |
28 | m_utf8mode(utf8) { | ||
28 | if (name != 0) | 29 | if (name != 0) |
29 | load(name); | 30 | load(name); |
30 | } | 31 | } |
@@ -83,30 +84,51 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_ | |||
83 | &rendcol, &xftcolor); | 84 | &rendcol, &xftcolor); |
84 | 85 | ||
85 | // draw string | 86 | // draw string |
86 | XftDrawString8 (draw, | 87 | #ifdef X_HAVE_UTF8_STRING |
87 | &xftcolor, | 88 | if (m_utf8mode) { |
88 | m_xftfont, | 89 | XftDrawStringUtf8(draw, |
89 | x, y, | 90 | &xftcolor, |
90 | (XftChar8 *)(text), len); | 91 | m_xftfont, |
92 | x, y, | ||
93 | (XftChar8 *)(text), len); | ||
94 | } else | ||
95 | #endif // X_HAVE_UTF8_STRING | ||
96 | { | ||
97 | XftDrawString8(draw, | ||
98 | &xftcolor, | ||
99 | m_xftfont, | ||
100 | x, y, | ||
101 | (XftChar8 *)(text), len); | ||
102 | } | ||
91 | 103 | ||
92 | XftColorFree(disp, DefaultVisual(disp, screen), | 104 | XftColorFree(disp, DefaultVisual(disp, screen), |
93 | DefaultColormap(disp, screen), &xftcolor); | 105 | DefaultColormap(disp, screen), &xftcolor); |
94 | XftDrawDestroy(draw); | 106 | XftDrawDestroy(draw); |
95 | } | 107 | } |
96 | 108 | ||
97 | unsigned int XftFontImp::textWidth(const char *text, unsigned int len) const { | 109 | unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) const { |
98 | if (m_xftfont == 0) | 110 | if (m_xftfont == 0) |
99 | return 0; | 111 | return 0; |
100 | XGlyphInfo ginfo; | 112 | XGlyphInfo ginfo; |
101 | XftTextExtents8(BaseDisplay::getXDisplay(), | 113 | #ifdef X_HAVE_UTF8_STRING |
102 | m_xftfont, | 114 | if (m_utf8mode) { |
103 | (XftChar8 *)text, len, | 115 | XftTextExtentsUtf8(BaseDisplay::getXDisplay(), |
104 | &ginfo); | 116 | m_xftfont, |
117 | (XftChar8 *)text, len, | ||
118 | &ginfo); | ||
119 | } else | ||
120 | #endif //X_HAVE_UTF8_STRING | ||
121 | { | ||
122 | XftTextExtents8(BaseDisplay::getXDisplay(), | ||
123 | m_xftfont, | ||
124 | (XftChar8 *)text, len, | ||
125 | &ginfo); | ||
126 | } | ||
105 | return ginfo.xOff; | 127 | return ginfo.xOff; |
106 | } | 128 | } |
107 | 129 | ||
108 | unsigned int XftFontImp::height() const { | 130 | unsigned int XftFontImp::height() const { |
109 | if (m_xftfont == 0) | 131 | if (m_xftfont == 0) |
110 | return 0; | 132 | return 0; |
111 | return m_xftfont->ascent + m_xftfont->descent; | 133 | return m_xftfont->height; |
112 | } | 134 | } |