diff options
Diffstat (limited to 'utils/themeeditor/graphics/rbfont.cpp')
-rw-r--r-- | utils/themeeditor/graphics/rbfont.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp index cd68af99fe..3b7397283c 100644 --- a/utils/themeeditor/graphics/rbfont.cpp +++ b/utils/themeeditor/graphics/rbfont.cpp | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include "rbfont.h" | 22 | #include "rbfont.h" |
23 | #include "rbfontcache.h" | 23 | #include "rbfontcache.h" |
24 | #include "rbtextcache.h" | ||
24 | 25 | ||
25 | #include <QFont> | 26 | #include <QFont> |
26 | #include <QBrush> | 27 | #include <QBrush> |
@@ -166,6 +167,13 @@ RBFont::~RBFont() | |||
166 | RBText* RBFont::renderText(QString text, QColor color, int viewWidth, | 167 | RBText* RBFont::renderText(QString text, QColor color, int viewWidth, |
167 | QGraphicsItem *parent) | 168 | QGraphicsItem *parent) |
168 | { | 169 | { |
170 | |||
171 | /* Checking for a cache hit first */ | ||
172 | QImage* image = RBTextCache::lookup(header.value("filename").toString() | ||
173 | + text); | ||
174 | if(image) | ||
175 | return new RBText(image, viewWidth, parent); | ||
176 | |||
169 | int firstChar = header.value("firstchar").toInt(); | 177 | int firstChar = header.value("firstchar").toInt(); |
170 | int height = header.value("height").toInt(); | 178 | int height = header.value("height").toInt(); |
171 | int maxWidth = header.value("maxwidth").toInt(); | 179 | int maxWidth = header.value("maxwidth").toInt(); |
@@ -184,10 +192,10 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth, | |||
184 | for(int i = 0; i < widths.count(); i++) | 192 | for(int i = 0; i < widths.count(); i++) |
185 | totalWidth += widths[i]; | 193 | totalWidth += widths[i]; |
186 | 194 | ||
187 | QImage image(totalWidth, height, QImage::Format_Indexed8); | 195 | image = new QImage(totalWidth, height, QImage::Format_Indexed8); |
188 | 196 | ||
189 | image.setColor(0, qRgba(0,0,0,0)); | 197 | image->setColor(0, qRgba(0,0,0,0)); |
190 | image.setColor(1, color.rgb()); | 198 | image->setColor(1, color.rgb()); |
191 | 199 | ||
192 | /* Drawing the text */ | 200 | /* Drawing the text */ |
193 | int startX = 0; | 201 | int startX = 0; |
@@ -214,9 +222,9 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth, | |||
214 | for(int bit = 0; bit < 8; bit++) | 222 | for(int bit = 0; bit < 8; bit++) |
215 | { | 223 | { |
216 | if(mask & data) | 224 | if(mask & data) |
217 | image.setPixel(x, y, 1); | 225 | image->setPixel(x, y, 1); |
218 | else | 226 | else |
219 | image.setPixel(x, y, 0); | 227 | image->setPixel(x, y, 0); |
220 | 228 | ||
221 | y++; | 229 | y++; |
222 | mask <<= 1; | 230 | mask <<= 1; |
@@ -230,6 +238,7 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth, | |||
230 | startX += widths[i]; | 238 | startX += widths[i]; |
231 | } | 239 | } |
232 | 240 | ||
241 | RBTextCache::insert(header.value("filename").toString() + text, image); | ||
233 | return new RBText(image, viewWidth, parent); | 242 | return new RBText(image, viewWidth, parent); |
234 | 243 | ||
235 | } | 244 | } |