diff options
Diffstat (limited to 'utils/themeeditor/graphics/rbfont.cpp')
-rw-r--r-- | utils/themeeditor/graphics/rbfont.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp index 07308fac7e..cd68af99fe 100644 --- a/utils/themeeditor/graphics/rbfont.cpp +++ b/utils/themeeditor/graphics/rbfont.cpp | |||
@@ -20,6 +20,7 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "rbfont.h" | 22 | #include "rbfont.h" |
23 | #include "rbfontcache.h" | ||
23 | 24 | ||
24 | #include <QFont> | 25 | #include <QFont> |
25 | #include <QBrush> | 26 | #include <QBrush> |
@@ -29,6 +30,8 @@ | |||
29 | #include <QImage> | 30 | #include <QImage> |
30 | #include <QSettings> | 31 | #include <QSettings> |
31 | 32 | ||
33 | #include <QDebug> | ||
34 | |||
32 | quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB; | 35 | quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB; |
33 | 36 | ||
34 | RBFont::RBFont(QString file) | 37 | RBFont::RBFont(QString file) |
@@ -52,6 +55,18 @@ RBFont::RBFont(QString file) | |||
52 | } | 55 | } |
53 | header.insert("filename", file); | 56 | header.insert("filename", file); |
54 | 57 | ||
58 | /* Checking for a cache entry */ | ||
59 | RBFontCache::CacheInfo* cache = RBFontCache::lookup(file); | ||
60 | if(cache) | ||
61 | { | ||
62 | imageData = cache->imageData; | ||
63 | offsetData = cache->offsetData; | ||
64 | widthData = cache->widthData; | ||
65 | header = cache->header; | ||
66 | |||
67 | return; | ||
68 | } | ||
69 | |||
55 | /* Opening the file */ | 70 | /* Opening the file */ |
56 | QFile fin(file); | 71 | QFile fin(file); |
57 | fin.open(QFile::ReadOnly); | 72 | fin.open(QFile::ReadOnly); |
@@ -134,16 +149,18 @@ RBFont::RBFont(QString file) | |||
134 | 149 | ||
135 | fin.close(); | 150 | fin.close(); |
136 | 151 | ||
152 | /* Caching the font data */ | ||
153 | cache = new RBFontCache::CacheInfo; | ||
154 | cache->imageData = imageData; | ||
155 | cache->offsetData = offsetData; | ||
156 | cache->widthData = widthData; | ||
157 | cache->header = header; | ||
158 | RBFontCache::insert(file, cache); | ||
159 | |||
137 | } | 160 | } |
138 | 161 | ||
139 | RBFont::~RBFont() | 162 | RBFont::~RBFont() |
140 | { | 163 | { |
141 | if(imageData) | ||
142 | delete[] imageData; | ||
143 | if(offsetData) | ||
144 | delete[] offsetData; | ||
145 | if(widthData) | ||
146 | delete[] widthData; | ||
147 | } | 164 | } |
148 | 165 | ||
149 | RBText* RBFont::renderText(QString text, QColor color, int viewWidth, | 166 | RBText* RBFont::renderText(QString text, QColor color, int viewWidth, |