cosmetic + try to avoid App::instance()->display() calls when not needed
This commit is contained in:
parent
97d2577f1a
commit
bf48239dee
1 changed files with 12 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
||||||
// XftFontImp.cc Xft font implementation for FbTk
|
// XftFontImp.cc Xft font implementation for FbTk
|
||||||
// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
|
// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
// to deal in the Software without restriction, including without limitation
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
//$Id: XftFontImp.cc,v 1.4 2004/08/29 08:33:13 rathnor Exp $
|
//$Id: XftFontImp.cc,v 1.5 2004/09/10 16:12:49 akir Exp $
|
||||||
|
|
||||||
#include "XftFontImp.hh"
|
#include "XftFontImp.hh"
|
||||||
#include "App.hh"
|
#include "App.hh"
|
||||||
|
@ -43,10 +43,10 @@ XftFontImp::~XftFontImp() {
|
||||||
|
|
||||||
bool XftFontImp::load(const std::string &name) {
|
bool XftFontImp::load(const std::string &name) {
|
||||||
//Note: assumes screen 0 for now, changes on draw if needed
|
//Note: assumes screen 0 for now, changes on draw if needed
|
||||||
|
|
||||||
Display *disp = App::instance()->display();
|
Display *disp = App::instance()->display();
|
||||||
XftFont *newxftfont = XftFontOpenName(disp, 0, name.c_str());
|
XftFont *newxftfont = XftFontOpenName(disp, 0, name.c_str());
|
||||||
|
|
||||||
if (newxftfont == 0) { // failed to open font, lets test with XLFD
|
if (newxftfont == 0) { // failed to open font, lets test with XLFD
|
||||||
newxftfont = XftFontOpenXlfd(disp, 0, name.c_str());
|
newxftfont = XftFontOpenXlfd(disp, 0, name.c_str());
|
||||||
if (newxftfont == 0)
|
if (newxftfont == 0)
|
||||||
|
@ -87,7 +87,7 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
|
||||||
rendcol.green = xcol.green;
|
rendcol.green = xcol.green;
|
||||||
rendcol.blue = xcol.blue;
|
rendcol.blue = xcol.blue;
|
||||||
rendcol.alpha = 0xFFFF;
|
rendcol.alpha = 0xFFFF;
|
||||||
XftColor xftcolor;
|
XftColor xftcolor;
|
||||||
XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen),
|
XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen),
|
||||||
&rendcol, &xftcolor);
|
&rendcol, &xftcolor);
|
||||||
|
|
||||||
|
@ -107,14 +107,14 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
|
||||||
m_xftfont,
|
m_xftfont,
|
||||||
x, y,
|
x, y,
|
||||||
(XftChar8 *)(text), len);
|
(XftChar8 *)(text), len);
|
||||||
XftColorFree(disp, DefaultVisual(disp, screen),
|
XftColorFree(disp, DefaultVisual(disp, screen),
|
||||||
DefaultColormap(disp, screen), &xftcolor);
|
DefaultColormap(disp, screen), &xftcolor);
|
||||||
XftDrawDestroy(draw);
|
XftDrawDestroy(draw);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // HAVE_XFT_UTF8_STRING
|
#endif // HAVE_XFT_UTF8_STRING
|
||||||
|
|
||||||
XftDrawString8(draw,
|
XftDrawString8(draw,
|
||||||
&xftcolor,
|
&xftcolor,
|
||||||
m_xftfont,
|
m_xftfont,
|
||||||
|
@ -122,7 +122,7 @@ void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_
|
||||||
(XftChar8 *)(text), len);
|
(XftChar8 *)(text), len);
|
||||||
|
|
||||||
|
|
||||||
XftColorFree(disp, DefaultVisual(disp, screen),
|
XftColorFree(disp, DefaultVisual(disp, screen),
|
||||||
DefaultColormap(disp, screen), &xftcolor);
|
DefaultColormap(disp, screen), &xftcolor);
|
||||||
XftDrawDestroy(draw);
|
XftDrawDestroy(draw);
|
||||||
}
|
}
|
||||||
|
@ -132,10 +132,11 @@ unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) co
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
XGlyphInfo ginfo;
|
XGlyphInfo ginfo;
|
||||||
|
Display* disp = App::instance()->display();
|
||||||
|
|
||||||
#ifdef HAVE_XFT_UTF8_STRING
|
#ifdef HAVE_XFT_UTF8_STRING
|
||||||
if (m_utf8mode) {
|
if (m_utf8mode) {
|
||||||
XftTextExtentsUtf8(App::instance()->display(),
|
XftTextExtentsUtf8(disp,
|
||||||
m_xftfont,
|
m_xftfont,
|
||||||
(XftChar8 *)text, len,
|
(XftChar8 *)text, len,
|
||||||
&ginfo);
|
&ginfo);
|
||||||
|
@ -146,7 +147,7 @@ unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) co
|
||||||
}
|
}
|
||||||
#endif //HAVE_XFT_UTF8_STRING
|
#endif //HAVE_XFT_UTF8_STRING
|
||||||
|
|
||||||
XftTextExtents8(App::instance()->display(),
|
XftTextExtents8(disp,
|
||||||
m_xftfont,
|
m_xftfont,
|
||||||
(XftChar8 *)text, len,
|
(XftChar8 *)text, len,
|
||||||
&ginfo);
|
&ginfo);
|
||||||
|
@ -157,7 +158,7 @@ unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) co
|
||||||
unsigned int XftFontImp::height() const {
|
unsigned int XftFontImp::height() const {
|
||||||
if (m_xftfont == 0)
|
if (m_xftfont == 0)
|
||||||
return 0;
|
return 0;
|
||||||
return m_xftfont->height;
|
return m_xftfont->height;
|
||||||
//m_xftfont->ascent + m_xftfont->descent;
|
//m_xftfont->ascent + m_xftfont->descent;
|
||||||
// curiously, fonts seem to have a smaller height, but the "height"
|
// curiously, fonts seem to have a smaller height, but the "height"
|
||||||
// is specified within the actual font, so it must be right, right?
|
// is specified within the actual font, so it must be right, right?
|
||||||
|
|
Loading…
Reference in a new issue