From 6a04479d63dd4d7dfc54849e4c925d360d55fa9c Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Mon, 5 Jul 2010 22:15:17 +0000 Subject: 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 --- utils/themeeditor/graphics/rbfont.cpp | 68 ++++++++++++++++++++++++++++++++++- utils/themeeditor/graphics/rbfont.h | 3 +- 2 files changed, 69 insertions(+), 2 deletions(-) (limited to 'utils') 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 #include +#include -RBFont::RBFont(QString file): filename(file) +#include + +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() diff --git a/utils/themeeditor/graphics/rbfont.h b/utils/themeeditor/graphics/rbfont.h index 61a171e081..2c1f8a9dce 100644 --- a/utils/themeeditor/graphics/rbfont.h +++ b/utils/themeeditor/graphics/rbfont.h @@ -25,6 +25,7 @@ #include #include #include +#include class RBFont { @@ -37,7 +38,7 @@ public: int lineHeight(){ return 8; } private: - QString filename; + QHash header; }; #endif // RBFONT_H -- cgit v1.2.3