all repos — fluxbox @ 460d3850919831c107b28c09881f857647444745

custom fork of the fluxbox windowmanager

utf8
fluxgen fluxgen
commit

460d3850919831c107b28c09881f857647444745

parent

0ea4319159dbe49d67b83c93dce745b9c2772404

2 files changed, 40 insertions(+), 17 deletions(-)

jump to
M src/XftFontImp.ccsrc/XftFontImp.cc

@@ -19,12 +19,13 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: XftFontImp.cc,v 1.1 2002/10/14 18:14:20 fluxgen Exp $ +//$Id: XftFontImp.cc,v 1.2 2002/10/16 23:13:15 fluxgen Exp $ #include "XftFontImp.hh" #include "BaseDisplay.hh" -XftFontImp::XftFontImp(const char *name):m_xftfont(0) { +XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0), +m_utf8mode(utf8) { if (name != 0) load(name); }

@@ -83,30 +84,51 @@ XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen),

&rendcol, &xftcolor); // draw string - XftDrawString8 (draw, - &xftcolor, - m_xftfont, - x, y, - (XftChar8 *)(text), len); +#ifdef X_HAVE_UTF8_STRING + if (m_utf8mode) { + XftDrawStringUtf8(draw, + &xftcolor, + m_xftfont, + x, y, + (XftChar8 *)(text), len); + } else +#endif // X_HAVE_UTF8_STRING + { + XftDrawString8(draw, + &xftcolor, + m_xftfont, + x, y, + (XftChar8 *)(text), len); + } XftColorFree(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen), &xftcolor); XftDrawDestroy(draw); } -unsigned int XftFontImp::textWidth(const char *text, unsigned int len) const { +unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) const { if (m_xftfont == 0) return 0; XGlyphInfo ginfo; - XftTextExtents8(BaseDisplay::getXDisplay(), - m_xftfont, - (XftChar8 *)text, len, - &ginfo); +#ifdef X_HAVE_UTF8_STRING + if (m_utf8mode) { + XftTextExtentsUtf8(BaseDisplay::getXDisplay(), + m_xftfont, + (XftChar8 *)text, len, + &ginfo); + } else +#endif //X_HAVE_UTF8_STRING + { + XftTextExtents8(BaseDisplay::getXDisplay(), + m_xftfont, + (XftChar8 *)text, len, + &ginfo); + } return ginfo.xOff; } unsigned int XftFontImp::height() const { if (m_xftfont == 0) return 0; - return m_xftfont->ascent + m_xftfont->descent; + return m_xftfont->height; }
M src/XftFontImp.hhsrc/XftFontImp.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: XftFontImp.hh,v 1.2 2002/10/15 16:44:26 fluxgen Exp $ +//$Id: XftFontImp.hh,v 1.3 2002/10/16 23:13:54 fluxgen Exp $ #ifndef XFTFONTIMP_HH #define XFTFONTIMP_HH

@@ -29,15 +29,16 @@ #include <X11/Xft/Xft.h>

class XftFontImp:public FbTk::FontImp { public: - explicit XftFontImp(const char *fontname=0); + XftFontImp(const char *fontname, bool utf8); ~XftFontImp(); bool load(const std::string &name); void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; - unsigned int textWidth(const char *text, unsigned int len) const; + unsigned int textWidth(const char * const text, unsigned int len) const; unsigned int height() const; bool loaded() const { return m_xftfont != 0; } private: - XftFont *m_xftfont; + XftFont *m_xftfont; + bool m_utf8mode; }; #endif // XFTFONTIMP_HH