diff options
author | fluxgen <fluxgen> | 2003-12-01 19:57:01 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-12-01 19:57:01 (GMT) |
commit | 1586e9a25621cff81b9d3770617aec73fcb14054 (patch) | |
tree | b77dd0503f6a0382f28396696b970082bc886b28 | |
parent | 1136a8688a19abd30d0b4603555e641777ce2492 (diff) | |
download | fluxbox_paul-1586e9a25621cff81b9d3770617aec73fcb14054.zip fluxbox_paul-1586e9a25621cff81b9d3770617aec73fcb14054.tar.bz2 |
fixed shadow option bug
-rw-r--r-- | src/FbTk/Font.cc | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc index 071fc1e..8f4cd42 100644 --- a/src/FbTk/Font.cc +++ b/src/FbTk/Font.cc | |||
@@ -19,7 +19,7 @@ | |||
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.5 2003/11/28 23:27:29 fluxgen Exp $ | 22 | //$Id: Font.cc,v 1.6 2003/12/01 19:57:01 fluxgen Exp $ |
23 | 23 | ||
24 | 24 | ||
25 | #include "Font.hh" | 25 | #include "Font.hh" |
@@ -140,17 +140,46 @@ void Font::setAntialias(bool flag) { | |||
140 | bool Font::load(const std::string &name) { | 140 | bool Font::load(const std::string &name) { |
141 | if (name.size() == 0) | 141 | if (name.size() == 0) |
142 | return false; | 142 | return false; |
143 | // copy name so we can manipulate it | ||
144 | std::string new_name = name; | ||
143 | 145 | ||
144 | // find font option "shadow" | ||
145 | m_shadow = false; | 146 | m_shadow = false; |
146 | size_t start_pos = name.find_first_of(":"); | 147 | |
147 | if (start_pos != std::string::npos) { | 148 | // find font option "shadow" |
148 | if (name.find_first_of("shadow", start_pos) != std::string::npos) | 149 | size_t start_pos = new_name.find_first_of(':'); |
150 | if (start_pos != std::string::npos) { | ||
151 | size_t shadow_pos = new_name.find("shadow", start_pos); | ||
152 | if (shadow_pos != std::string::npos) { | ||
149 | m_shadow = true; | 153 | m_shadow = true; |
154 | // erase "shadow" since it's not a valid option for the font | ||
155 | new_name.erase(shadow_pos, 6); | ||
156 | |||
157 | // is the option row empty? | ||
158 | if (new_name.find_first_not_of("\t ,", start_pos + 1) == std::string::npos) | ||
159 | new_name.erase(start_pos); // erase the ':' and the rest of the line | ||
160 | else { | ||
161 | // there might be some options left so we need to remove the "," | ||
162 | // before/after "shadow" option | ||
163 | size_t pos = new_name.find_last_not_of("\t ", shadow_pos); | ||
164 | if (pos != std::string::npos) { | ||
165 | if (new_name[pos] == ',') | ||
166 | new_name.erase(pos, 1); | ||
167 | |||
168 | } | ||
169 | |||
170 | // ok, we removed the "," and "shadow" now we need to determine | ||
171 | // if we need to remove the ":" , so we search for anything except | ||
172 | // \t and space and if we dont find anything the ":" is removed | ||
173 | if (new_name.find_first_not_of("\t ", start_pos + 1) == std::string::npos) | ||
174 | new_name.erase(start_pos, 1); | ||
175 | |||
176 | } | ||
177 | |||
178 | } | ||
150 | } | 179 | } |
151 | 180 | ||
152 | m_fontstr = name; | 181 | m_fontstr = name; |
153 | return m_fontimp->load(name.c_str()); | 182 | return m_fontimp->load(new_name.c_str()); |
154 | } | 183 | } |
155 | 184 | ||
156 | unsigned int Font::textWidth(const char * const text, unsigned int size) const { | 185 | unsigned int Font::textWidth(const char * const text, unsigned int size) const { |