From f65ed0d3bc4fd116f3fa6dfb059bb38d4c1262d1 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Sun, 11 Jul 2010 05:12:11 +0000 Subject: Theme Editor: Added support for larger fonts git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27379 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/graphics/rbfont.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp index 3b7397283c..23791497fd 100644 --- a/utils/themeeditor/graphics/rbfont.cpp +++ b/utils/themeeditor/graphics/rbfont.cpp @@ -135,9 +135,13 @@ RBFont::RBFont(QString file) /* Loading the offset table if necessary */ if(header.value("noffset").toInt() > 0) { - offsetData = new quint16[header.value("noffset").toInt()]; - data.readRawData(reinterpret_cast(offsetData), - header.value("noffset").toInt() * 2); + int bytesToRead; + if(header.value("nbits").toInt() > maxFontSizeFor16BitOffsets) + bytesToRead = 4 * header.value("noffset").toInt(); + else + bytesToRead = 2 * header.value("noffset").toInt(); + offsetData = new quint16[bytesToRead]; + data.readRawData(reinterpret_cast(offsetData), bytesToRead); } /* Loading the width table if necessary */ @@ -178,6 +182,9 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth, int height = header.value("height").toInt(); int maxWidth = header.value("maxwidth").toInt(); + bool extendedSet = header.value("nbits"). + toUInt() > maxFontSizeFor16BitOffsets; + /* First we determine the width of the combined text */ QList widths; for(int i = 0; i < text.length(); i++) @@ -203,9 +210,16 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth, { unsigned int offset; if(offsetData) - offset = offsetData[text[i].unicode() - firstChar]; + { + if(extendedSet) + offset = reinterpret_cast(offsetData)[text[i].unicode() - firstChar]; + else + offset = offsetData[text[i].unicode() - firstChar]; + } else + { offset = (text[i].unicode() - firstChar) * maxWidth; + } int bytesHigh = height / 8; if(height % 8 > 0) -- cgit v1.2.3