summaryrefslogtreecommitdiff
path: root/utils/themeeditor/graphics/rbfont.cpp
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-05 22:15:17 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-05 22:15:17 +0000
commit6a04479d63dd4d7dfc54849e4c925d360d55fa9c (patch)
tree581a953843da7537f89dfda67e06633b19719398 /utils/themeeditor/graphics/rbfont.cpp
parent8a23b8eb1e5e9add6dcf8ab60067d9cf45aba8d0 (diff)
Theme Editor: Began working on font loading. Font header info is now read and spewed out onto the debug console
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27301 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/graphics/rbfont.cpp')
-rw-r--r--utils/themeeditor/graphics/rbfont.cpp68
1 files changed, 67 insertions, 1 deletions
diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp
index 71c6ff3fc1..3988fbc64f 100644
--- a/utils/themeeditor/graphics/rbfont.cpp
+++ b/utils/themeeditor/graphics/rbfont.cpp
@@ -23,9 +23,75 @@
#include <QFont>
#include <QBrush>
+#include <QFile>
-RBFont::RBFont(QString file): filename(file)
+#include <QDebug>
+
+RBFont::RBFont(QString file)
{
+
+ /* Attempting to locate the correct file name */
+ if(!QFile::exists(file))
+ file = ":/fonts/08-Schumacher-Clean.fnt";
+ header.insert("filename", file);
+
+ /* Opening the file */
+ QFile fin(file);
+ fin.open(QFile::ReadOnly);
+
+ /* Loading the header info */
+ quint16 word;
+ quint32 dword;
+
+ QDataStream data(&fin);
+ data.setByteOrder(QDataStream::LittleEndian);
+
+ /* Grabbing the magic number and version */
+ data >> dword;
+ header.insert("version", dword);
+
+ /* Max font width */
+ data >> word;
+ header.insert("maxwidth", word);
+
+ /* Font height */
+ data >> word;
+ header.insert("height", word);
+
+ /* Ascent */
+ data >> word;
+ header.insert("ascent", word);
+
+ /* Padding */
+ data >> word;
+
+ /* First character code */
+ data >> dword;
+ header.insert("firstchar", dword);
+
+ /* Default character code */
+ data >> dword;
+ header.insert("defaultchar", dword);
+
+ /* Number of characters */
+ data >> dword;
+ header.insert("size", dword);
+
+ /* Bytes of imagebits in file */
+ data >> dword;
+ header.insert("nbits", dword);
+
+ /* Longs (dword) of offset data in file */
+ data >> dword;
+ header.insert("noffset", dword);
+
+ /* Bytes of width data in file */
+ data >> dword;
+ header.insert("nwidth", dword);
+
+ fin.close();
+
+ qDebug() << header ;
}
RBFont::~RBFont()