aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/XFontImp.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2007-01-05 13:43:54 (GMT)
committersimonb <simonb>2007-01-05 13:43:54 (GMT)
commitad7fd2d8675141925bdef7c29d3392d6ac6b0db0 (patch)
tree776c13dccaecc0eeb54c514040ac00a74f347a99 /src/FbTk/XFontImp.cc
parent3a79de034f87df155f540af2186c5d87dc187b3b (diff)
downloadfluxbox-ad7fd2d8675141925bdef7c29d3392d6ac6b0db0.zip
fluxbox-ad7fd2d8675141925bdef7c29d3392d6ac6b0db0.tar.bz2
fix loading of rotated fonts on style change
Diffstat (limited to 'src/FbTk/XFontImp.cc')
-rw-r--r--src/FbTk/XFontImp.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/FbTk/XFontImp.cc b/src/FbTk/XFontImp.cc
index 515b1e2..0c404a1 100644
--- a/src/FbTk/XFontImp.cc
+++ b/src/FbTk/XFontImp.cc
@@ -45,8 +45,10 @@ using std::nothrow;
45namespace FbTk { 45namespace FbTk {
46 46
47XFontImp::XFontImp(const char *fontname):m_fontstruct(0) { 47XFontImp::XFontImp(const char *fontname):m_fontstruct(0) {
48 for (int i = ROT0; i <= ROT270; ++i) 48 for (int i = ROT0; i <= ROT270; ++i) {
49 m_rotfonts[i] = 0; 49 m_rotfonts[i] = 0;
50 m_rotfonts_loaded[i] = false;
51 }
50 52
51 if (fontname != 0) 53 if (fontname != 0)
52 load(fontname); 54 load(fontname);
@@ -78,19 +80,23 @@ bool XFontImp::load(const string &fontname) {
78 80
79 m_fontstruct = font; //set new font 81 m_fontstruct = font; //set new font
80 82
81 for (int i = ROT0; i <= ROT270; ++i) 83 for (int i = ROT0; i <= ROT270; ++i) {
82 if (m_rotfonts[i] != 0) 84 m_rotfonts_loaded[i] = false;
85 if (m_rotfonts[i] != 0) {
83 freeRotFont(m_rotfonts[i]); 86 freeRotFont(m_rotfonts[i]);
87 m_rotfonts[i] = 0;
88 }
89 }
84 90
85 return true; 91 return true;
86} 92}
87 93
88void XFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) const { 94void XFontImp::drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y, FbTk::Orientation orient) {
89 if (m_fontstruct == 0) 95 if (m_fontstruct == 0)
90 return; 96 return;
91 97
92 // use roated font functions? 98 // use roated font functions?
93 if (orient != ROT0 && m_rotfonts[orient] != 0) { 99 if (orient != ROT0 && validOrientation(orient)) {
94 drawRotText(w.drawable(), screen, gc, text, len, x, y, orient); 100 drawRotText(w.drawable(), screen, gc, text, len, x, y, orient);
95 return; 101 return;
96 } 102 }
@@ -389,7 +395,12 @@ bool XFontImp::validOrientation(FbTk::Orientation orient) {
389 if (orient == ROT0 || m_rotfonts[orient]) 395 if (orient == ROT0 || m_rotfonts[orient])
390 return true; 396 return true;
391 397
398 if (m_rotfonts_loaded[orient])
399 return false; // load must have failed
400
401 m_rotfonts_loaded[orient] = true;
392 rotate(orient); 402 rotate(orient);
403
393 return m_rotfonts[orient] != 0; 404 return m_rotfonts[orient] != 0;
394} 405}
395 406