diff options
Diffstat (limited to 'src/FbTk/XftFontImp.cc')
-rw-r--r-- | src/FbTk/XftFontImp.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/FbTk/XftFontImp.cc b/src/FbTk/XftFontImp.cc index 5acf0af..b80474a 100644 --- a/src/FbTk/XftFontImp.cc +++ b/src/FbTk/XftFontImp.cc | |||
@@ -36,8 +36,10 @@ namespace FbTk { | |||
36 | XftFontImp::XftFontImp(const char *name, bool utf8): | 36 | XftFontImp::XftFontImp(const char *name, bool utf8): |
37 | m_utf8mode(utf8), m_name("") { | 37 | m_utf8mode(utf8), m_name("") { |
38 | 38 | ||
39 | for (int r = ROT0; r <= ROT270; r++) | 39 | for (int r = ROT0; r <= ROT270; r++) { |
40 | m_xftfonts[r] = 0; | 40 | m_xftfonts[r] = 0; |
41 | m_xftfonts_loaded[r] = false; | ||
42 | } | ||
41 | 43 | ||
42 | if (name != 0) | 44 | if (name != 0) |
43 | load(name); | 45 | load(name); |
@@ -62,21 +64,24 @@ bool XftFontImp::load(const std::string &name) { | |||
62 | } | 64 | } |
63 | 65 | ||
64 | // destroy all old fonts and set new | 66 | // destroy all old fonts and set new |
65 | for (int r = ROT0; r <= ROT270; r++) | 67 | for (int r = ROT0; r <= ROT270; r++) { |
68 | m_xftfonts_loaded[r] = false; | ||
66 | if (m_xftfonts[r] != 0) { | 69 | if (m_xftfonts[r] != 0) { |
67 | XftFontClose(App::instance()->display(), m_xftfonts[r]); | 70 | XftFontClose(App::instance()->display(), m_xftfonts[r]); |
68 | m_xftfonts[r] = 0; | 71 | m_xftfonts[r] = 0; |
69 | } | 72 | } |
73 | } | ||
70 | 74 | ||
71 | m_xftfonts[ROT0] = newxftfont; | 75 | m_xftfonts[ROT0] = newxftfont; |
76 | m_xftfonts_loaded[ROT0] = true; | ||
72 | m_name = name; | 77 | m_name = name; |
73 | 78 | ||
74 | return true; | 79 | return true; |
75 | } | 80 | } |
76 | 81 | ||
77 | void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const { | 82 | void XftFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) { |
78 | 83 | ||
79 | if (m_xftfonts[orient] == 0) | 84 | if (!validOrientation(orient)) |
80 | return; | 85 | return; |
81 | 86 | ||
82 | // we adjust y slightly so that the baseline is in the right spot | 87 | // we adjust y slightly so that the baseline is in the right spot |
@@ -212,9 +217,14 @@ bool XftFontImp::validOrientation(FbTk::Orientation orient) { | |||
212 | if (orient == ROT0 || m_xftfonts[orient]) | 217 | if (orient == ROT0 || m_xftfonts[orient]) |
213 | return true; | 218 | return true; |
214 | 219 | ||
220 | if (m_xftfonts_loaded[orient]) | ||
221 | return false; // m_xftfonts is zero here | ||
222 | |||
215 | if (m_xftfonts[ROT0] == 0) | 223 | if (m_xftfonts[ROT0] == 0) |
216 | return false; | 224 | return false; |
217 | 225 | ||
226 | m_xftfonts_loaded[orient] = true; | ||
227 | |||
218 | // otherwise, try to load that orientation | 228 | // otherwise, try to load that orientation |
219 | // radians is actually anti-clockwise, so we reverse it | 229 | // radians is actually anti-clockwise, so we reverse it |
220 | double radians = -(orient) * 90 * M_PI / 180; | 230 | double radians = -(orient) * 90 * M_PI / 180; |