diff options
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/themeeditor/graphics/rbfont.cpp | 68 | ||||
| -rw-r--r-- | utils/themeeditor/graphics/rbfont.h | 3 |
2 files changed, 69 insertions, 2 deletions
diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp index 71c6ff3..3988fbc 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() diff --git a/utils/themeeditor/graphics/rbfont.h b/utils/themeeditor/graphics/rbfont.h index 61a171e..2c1f8a9 100644 --- a/utils/themeeditor/graphics/rbfont.h +++ b/utils/themeeditor/graphics/rbfont.h @@ -25,6 +25,7 @@ #include <QString> #include <QFile> #include <QGraphicsSimpleTextItem> +#include <QHash> class RBFont { @@ -37,7 +38,7 @@ public: int lineHeight(){ return 8; } private: - QString filename; + QHash<QString, QVariant> header; }; #endif // RBFONT_H |