From 6f06793f58f520ec7d44683f6447c0b540a265b3 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Wed, 7 Jul 2010 08:41:36 +0000 Subject: Theme Editor: Fixed rendering bug that caused text in sublines not to appear, implemented a global font cache git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27331 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/graphics/rbfont.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'utils/themeeditor/graphics/rbfont.cpp') 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 @@ ****************************************************************************/ #include "rbfont.h" +#include "rbfontcache.h" #include #include @@ -29,6 +30,8 @@ #include #include +#include + quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB; RBFont::RBFont(QString file) @@ -52,6 +55,18 @@ RBFont::RBFont(QString file) } header.insert("filename", file); + /* Checking for a cache entry */ + RBFontCache::CacheInfo* cache = RBFontCache::lookup(file); + if(cache) + { + imageData = cache->imageData; + offsetData = cache->offsetData; + widthData = cache->widthData; + header = cache->header; + + return; + } + /* Opening the file */ QFile fin(file); fin.open(QFile::ReadOnly); @@ -134,16 +149,18 @@ RBFont::RBFont(QString file) fin.close(); + /* Caching the font data */ + cache = new RBFontCache::CacheInfo; + cache->imageData = imageData; + cache->offsetData = offsetData; + cache->widthData = widthData; + cache->header = header; + RBFontCache::insert(file, cache); + } RBFont::~RBFont() { - if(imageData) - delete[] imageData; - if(offsetData) - delete[] offsetData; - if(widthData) - delete[] widthData; } RBText* RBFont::renderText(QString text, QColor color, int viewWidth, -- cgit v1.2.3