aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Font.cc
diff options
context:
space:
mode:
authormathias <mathias>2006-10-30 19:31:15 (GMT)
committermathias <mathias>2006-10-30 19:31:15 (GMT)
commite5e76e7761f52ba7c0deca75bcecae4fbd3e2ff5 (patch)
treec84838a84802805e9b1463045e86200b7cef917f /src/FbTk/Font.cc
parent426c12c25c2ef095a882619ad7424684b88465b8 (diff)
downloadfluxbox-e5e76e7761f52ba7c0deca75bcecae4fbd3e2ff5.zip
fluxbox-e5e76e7761f52ba7c0deca75bcecae4fbd3e2ff5.tar.bz2
Cosmetic patch from Slava Semushin
Diffstat (limited to 'src/FbTk/Font.cc')
-rw-r--r--src/FbTk/Font.cc44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc
index 1e89180..a6bf32d 100644
--- a/src/FbTk/Font.cc
+++ b/src/FbTk/Font.cc
@@ -1,6 +1,6 @@
1// Font.cc 1// Font.cc
2// Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) 2// Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation 6// to deal in the Software without restriction, including without limitation
@@ -32,7 +32,7 @@
32#include "config.h" 32#include "config.h"
33#endif // HAVE_CONFIG_H 33#endif // HAVE_CONFIG_H
34 34
35// for antialias 35// for antialias
36#ifdef USE_XFT 36#ifdef USE_XFT
37#include "XftFontImp.hh" 37#include "XftFontImp.hh"
38#endif // USE_XFT 38#endif // USE_XFT
@@ -55,7 +55,6 @@
55#define __USE_GNU 55#define __USE_GNU
56#endif //__USE_GNU 56#endif //__USE_GNU
57 57
58#include <iostream>
59#ifdef HAVE_CSTRING 58#ifdef HAVE_CSTRING
60 #include <cstring> 59 #include <cstring>
61#else 60#else
@@ -79,8 +78,9 @@
79 #include <stdlib.h> 78 #include <stdlib.h>
80#endif 79#endif
81 80
82using namespace std; 81using std::string;
83 82using std::map;
83using std::list;
84 84
85namespace { 85namespace {
86 86
@@ -89,12 +89,12 @@ namespace {
89#endif //HAVE_SETLOCALE 89#endif //HAVE_SETLOCALE
90 90
91// use to map <font1>|<font2>|<font3> => <fontthatworks> 91// use to map <font1>|<font2>|<font3> => <fontthatworks>
92typedef std::map<std::string, std::string> StringMap; 92typedef map<string, string> StringMap;
93typedef StringMap::iterator StringMapIt; 93typedef StringMap::iterator StringMapIt;
94StringMap lookup_map; 94StringMap lookup_map;
95 95
96// stores <fontthatworks and the fontimp 96// stores <fontthatworks and the fontimp
97typedef std::map<std::string, FbTk::FontImp* > FontCache; 97typedef map<string, FbTk::FontImp* > FontCache;
98typedef FontCache::iterator FontCacheIt; 98typedef FontCache::iterator FontCacheIt;
99FontCache font_cache; 99FontCache font_cache;
100 100
@@ -114,7 +114,7 @@ void resetEffects(FbTk::Font& font) {
114 114
115namespace FbTk { 115namespace FbTk {
116 116
117bool Font::s_multibyte = false; 117bool Font::s_multibyte = false;
118bool Font::s_utf8mode = false; 118bool Font::s_utf8mode = false;
119 119
120 120
@@ -135,7 +135,7 @@ void Font::shutdown() {
135 135
136Font::Font(const char *name): 136Font::Font(const char *name):
137 m_fontimp(0), 137 m_fontimp(0),
138 m_shadow(false), m_shadow_color("black", DefaultScreen(App::instance()->display())), 138 m_shadow(false), m_shadow_color("black", DefaultScreen(App::instance()->display())),
139 m_shadow_offx(2), m_shadow_offy(2), 139 m_shadow_offx(2), m_shadow_offy(2),
140 m_halo(false), m_halo_color("white", DefaultScreen(App::instance()->display())) 140 m_halo(false), m_halo_color("white", DefaultScreen(App::instance()->display()))
141{ 141{
@@ -165,11 +165,11 @@ Font::Font(const char *name):
165Font::~Font() { 165Font::~Font() {
166} 166}
167 167
168bool Font::load(const std::string &name) { 168bool Font::load(const string &name) {
169 169
170 if (name.size() == 0) 170 if (name.size() == 0)
171 return false; 171 return false;
172 172
173 StringMapIt lookup_entry; 173 StringMapIt lookup_entry;
174 FontCacheIt cache_entry; 174 FontCacheIt cache_entry;
175 175
@@ -181,13 +181,13 @@ bool Font::load(const std::string &name) {
181 resetEffects(*this); 181 resetEffects(*this);
182 return true; 182 return true;
183 } 183 }
184 184
185 // split up the namelist 185 // split up the namelist
186 typedef std::list<std::string> StringList; 186 typedef list<string> StringList;
187 typedef StringList::iterator StringListIt; 187 typedef StringList::iterator StringListIt;
188 StringList names; 188 StringList names;
189 FbTk::StringUtil::stringtok<StringList>(names, name, "|"); 189 FbTk::StringUtil::stringtok<StringList>(names, name, "|");
190 190
191 StringListIt name_it; 191 StringListIt name_it;
192 for (name_it = names.begin(); name_it != names.end(); name_it++) { 192 for (name_it = names.begin(); name_it != names.end(); name_it++) {
193 FbTk::StringUtil::removeTrailingWhitespace(*name_it); 193 FbTk::StringUtil::removeTrailingWhitespace(*name_it);
@@ -202,12 +202,12 @@ bool Font::load(const std::string &name) {
202 } 202 }
203 203
204 FontImp* tmp_font(0); 204 FontImp* tmp_font(0);
205 205
206#ifdef USE_XFT 206#ifdef USE_XFT
207 if ((*name_it)[0] != '-') 207 if ((*name_it)[0] != '-')
208 tmp_font = new XftFontImp(0, s_utf8mode); 208 tmp_font = new XftFontImp(0, s_utf8mode);
209#endif // USE_XFT 209#endif // USE_XFT
210 210
211 if (!tmp_font) { 211 if (!tmp_font) {
212#ifdef USE_XMB 212#ifdef USE_XMB
213 if (s_multibyte || s_utf8mode) 213 if (s_multibyte || s_utf8mode)
@@ -225,7 +225,7 @@ bool Font::load(const std::string &name) {
225 resetEffects(*this); 225 resetEffects(*this);
226 return true; 226 return true;
227 } 227 }
228 228
229 delete tmp_font; 229 delete tmp_font;
230 } 230 }
231 231
@@ -244,7 +244,7 @@ int Font::ascent() const {
244 return m_fontimp->ascent(); 244 return m_fontimp->ascent();
245} 245}
246 246
247int Font::descent() const { 247int Font::descent() const {
248 return m_fontimp->descent(); 248 return m_fontimp->descent();
249} 249}
250 250
@@ -253,14 +253,14 @@ bool Font::validOrientation(FbTk::Orientation orient) {
253} 253}
254 254
255void Font::drawText(const FbDrawable &w, int screen, GC gc, 255void Font::drawText(const FbDrawable &w, int screen, GC gc,
256 const FbString &text, size_t len, int x, int y, 256 const FbString &text, size_t len, int x, int y,
257 Orientation orient) const { 257 Orientation orient) const {
258 if (text.empty() || len == 0) 258 if (text.empty() || len == 0)
259 return; 259 return;
260 260
261 // so we don't end up in a loop with m_shadow 261 // so we don't end up in a loop with m_shadow
262 static bool first_run = true; 262 static bool first_run = true;
263 263
264 // draw "effects" first 264 // draw "effects" first
265 if (first_run) { 265 if (first_run) {
266 if (m_shadow) { 266 if (m_shadow) {
@@ -284,7 +284,7 @@ void Font::drawText(const FbDrawable &w, int screen, GC gc,
284 284
285 m_fontimp->drawText(w, screen, gc, text, len, x, y, orient); 285 m_fontimp->drawText(w, screen, gc, text, len, x, y, orient);
286 286
287} 287}
288 288
289}; 289};
290 290