forked from len0rd/rockbox
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
This commit is contained in:
parent
88145656fb
commit
6f06793f58
6 changed files with 124 additions and 22 deletions
|
@ -20,6 +20,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "rbfont.h"
|
||||
#include "rbfontcache.h"
|
||||
|
||||
#include <QFont>
|
||||
#include <QBrush>
|
||||
|
@ -29,6 +30,8 @@
|
|||
#include <QImage>
|
||||
#include <QSettings>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue