diff options
Diffstat (limited to 'src/FbTk/XftFontImp.cc')
-rw-r--r-- | src/FbTk/XftFontImp.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/FbTk/XftFontImp.cc b/src/FbTk/XftFontImp.cc index a724463..40b9b9e 100644 --- a/src/FbTk/XftFontImp.cc +++ b/src/FbTk/XftFontImp.cc | |||
@@ -72,7 +72,7 @@ bool XftFontImp::load(const std::string &name) { | |||
72 | return true; | 72 | return true; |
73 | } | 73 | } |
74 | 74 | ||
75 | void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char *text, size_t len, int x, int y, FbTk::Orientation orient) const { | 75 | void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const { |
76 | if (m_xftfonts[orient] == 0) | 76 | if (m_xftfonts[orient] == 0) |
77 | return; | 77 | return; |
78 | 78 | ||
@@ -130,14 +130,14 @@ void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char *te | |||
130 | XGlyphInfo ginfo; | 130 | XGlyphInfo ginfo; |
131 | XftTextExtentsUtf8(w.display(), | 131 | XftTextExtentsUtf8(w.display(), |
132 | m_xftfonts[ROT0], | 132 | m_xftfonts[ROT0], |
133 | (XftChar8 *)text, len, | 133 | (XftChar8 *)text.data(), len, |
134 | &ginfo); | 134 | &ginfo); |
135 | if (ginfo.xOff != 0) { | 135 | if (ginfo.xOff != 0) { |
136 | XftDrawStringUtf8(draw, | 136 | XftDrawStringUtf8(draw, |
137 | &xftcolor, | 137 | &xftcolor, |
138 | font, | 138 | font, |
139 | x, y, | 139 | x, y, |
140 | (XftChar8 *)(text), len); | 140 | (XftChar8 *)(text.data()), len); |
141 | XftColorFree(w.display(), | 141 | XftColorFree(w.display(), |
142 | DefaultVisual(w.display(), screen), | 142 | DefaultVisual(w.display(), screen), |
143 | DefaultColormap(w.display(), screen), &xftcolor); | 143 | DefaultColormap(w.display(), screen), &xftcolor); |
@@ -151,7 +151,7 @@ void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char *te | |||
151 | &xftcolor, | 151 | &xftcolor, |
152 | font, | 152 | font, |
153 | x, y, | 153 | x, y, |
154 | (XftChar8 *)(text), len); | 154 | (XftChar8 *)(text.data()), len); |
155 | 155 | ||
156 | 156 | ||
157 | XftColorFree(w.display(), | 157 | XftColorFree(w.display(), |
@@ -160,7 +160,7 @@ void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const char *te | |||
160 | XftDrawDestroy(draw); | 160 | XftDrawDestroy(draw); |
161 | } | 161 | } |
162 | 162 | ||
163 | unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) const { | 163 | unsigned int XftFontImp::textWidth(const FbString &text, unsigned int len) const { |
164 | if (m_xftfonts[ROT0] == 0) | 164 | if (m_xftfonts[ROT0] == 0) |
165 | return 0; | 165 | return 0; |
166 | 166 | ||
@@ -174,7 +174,7 @@ unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) co | |||
174 | if (m_utf8mode) { | 174 | if (m_utf8mode) { |
175 | XftTextExtentsUtf8(disp, | 175 | XftTextExtentsUtf8(disp, |
176 | font, | 176 | font, |
177 | (XftChar8 *)text, len, | 177 | (XftChar8 *)text.data(), len, |
178 | &ginfo); | 178 | &ginfo); |
179 | if (ginfo.xOff != 0) | 179 | if (ginfo.xOff != 0) |
180 | return ginfo.xOff; | 180 | return ginfo.xOff; |
@@ -183,9 +183,13 @@ unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) co | |||
183 | } | 183 | } |
184 | #endif //HAVE_XFT_UTF8_STRING | 184 | #endif //HAVE_XFT_UTF8_STRING |
185 | 185 | ||
186 | std::string localestr = text; | ||
187 | localestr.erase(len, std::string::npos); | ||
188 | localestr = FbStringUtil::FbStrToLocale(localestr); | ||
189 | |||
186 | XftTextExtents8(disp, | 190 | XftTextExtents8(disp, |
187 | font, | 191 | font, |
188 | (XftChar8 *)text, len, | 192 | (XftChar8 *)localestr.data(), localestr.size(), |
189 | &ginfo); | 193 | &ginfo); |
190 | 194 | ||
191 | return ginfo.xOff; | 195 | return ginfo.xOff; |