diff options
author | fluxgen <fluxgen> | 2002-08-04 15:36:19 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-08-04 15:36:19 (GMT) |
commit | b76f3ce744a1783b80bc08e861c06b66a8a44ff7 (patch) | |
tree | 606a20d17c3f9fa77fa72b51c99693f33fdd8405 /src | |
parent | 024d181abb16b896e53a5eb2ea094998e39e57a5 (diff) | |
download | fluxbox_lack-b76f3ce744a1783b80bc08e861c06b66a8a44ff7.zip fluxbox_lack-b76f3ce744a1783b80bc08e861c06b66a8a44ff7.tar.bz2 |
removed dep on i18n and used MB_CUR_MAX direct
Diffstat (limited to 'src')
-rw-r--r-- | src/Font.cc | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/Font.cc b/src/Font.cc index 0ca7d5a..5f70f29 100644 --- a/src/Font.cc +++ b/src/Font.cc | |||
@@ -19,12 +19,16 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | //$Id: Font.cc,v 1.6 2002/05/02 07:19:02 fluxgen Exp $ | 22 | //$Id: Font.cc,v 1.7 2002/08/04 15:36:19 fluxgen Exp $ |
23 | 23 | ||
24 | 24 | ||
25 | #include "Font.hh" | 25 | #include "Font.hh" |
26 | |||
27 | #include "StringUtil.hh" | 26 | #include "StringUtil.hh" |
27 | |||
28 | #ifdef HAVE_CONFIG_H | ||
29 | #include "../config.h" | ||
30 | #endif // HAVE_CONFIG_H | ||
31 | |||
28 | //use gnu extensions | 32 | //use gnu extensions |
29 | #ifndef _GNU_SOURCE | 33 | #ifndef _GNU_SOURCE |
30 | #define _GNU_SOURCE | 34 | #define _GNU_SOURCE |
@@ -36,13 +40,9 @@ | |||
36 | #include <string> | 40 | #include <string> |
37 | #include <cstdio> | 41 | #include <cstdio> |
38 | 42 | ||
39 | #ifdef HAVE_CONFIG_H | ||
40 | # include "../config.h" | ||
41 | #endif // HAVE_CONFIG_H | ||
42 | #ifdef HAVE_SETLOCALE | 43 | #ifdef HAVE_SETLOCALE |
43 | #include <locale.h> | 44 | #include <locale.h> |
44 | #endif //HAVE_SETLOCALE | 45 | #endif //HAVE_SETLOCALE |
45 | #include "i18n.hh" | ||
46 | 46 | ||
47 | namespace FbTk | 47 | namespace FbTk |
48 | { | 48 | { |
@@ -54,8 +54,11 @@ m_display(display) { | |||
54 | m_font.fontstruct = 0; | 54 | m_font.fontstruct = 0; |
55 | m_font.set_extents = 0; | 55 | m_font.set_extents = 0; |
56 | m_font.set = 0; | 56 | m_font.set = 0; |
57 | //TODO: should only be done once | 57 | |
58 | m_multibyte = I18n::instance()->multibyte(); | 58 | // MB_CUR_MAX returns the size of a char in the current locale |
59 | if (MB_CUR_MAX > 1) | ||
60 | m_multibyte = true; | ||
61 | |||
59 | if (name!=0) { | 62 | if (name!=0) { |
60 | load(name); | 63 | load(name); |
61 | } | 64 | } |
@@ -96,7 +99,7 @@ bool Font::loadFromDatabase(XrmDatabase &database, const char *rname, const char | |||
96 | XrmValue value; | 99 | XrmValue value; |
97 | char *value_type; | 100 | char *value_type; |
98 | 101 | ||
99 | //this should probably be moved to a Database class so we can keep | 102 | //This should probably be moved to a Database class so we can keep |
100 | //track of database init | 103 | //track of database init |
101 | 104 | ||
102 | if (XrmGetResource(database, rname, rclass, &value_type, &value)) { | 105 | if (XrmGetResource(database, rname, rclass, &value_type, &value)) { |
@@ -109,7 +112,7 @@ bool Font::loadFromDatabase(XrmDatabase &database, const char *rname, const char | |||
109 | return false; | 112 | return false; |
110 | 113 | ||
111 | } | 114 | } |
112 | unsigned int Font::getTextWidth(const char *text, unsigned int size) const { | 115 | unsigned int Font::textWidth(const char *text, unsigned int size) const { |
113 | if (text==0) | 116 | if (text==0) |
114 | return 0; | 117 | return 0; |
115 | if (multibyte()) { | 118 | if (multibyte()) { |
@@ -126,11 +129,15 @@ unsigned int Font::getTextWidth(const char *text, unsigned int size) const { | |||
126 | return 0; | 129 | return 0; |
127 | } | 130 | } |
128 | 131 | ||
129 | unsigned int Font::getHeight() const { | 132 | unsigned int Font::height() const { |
130 | if (multibyte() && getFontSetExtents()) | 133 | if (!isLoaded()) |
131 | return getFontSetExtents()->max_ink_extent.height; | 134 | return 0; |
132 | if (getFontStruct()) | 135 | |
133 | return getFontStruct()->ascent + getFontStruct()->descent; | 136 | if (multibyte() && fontSetExtents()) |
137 | return fontSetExtents()->max_ink_extent.height; | ||
138 | if (fontStruct()) | ||
139 | return fontStruct()->ascent + fontStruct()->descent; | ||
140 | |||
134 | return 0; | 141 | return 0; |
135 | } | 142 | } |
136 | 143 | ||