diff options
Diffstat (limited to 'utils/themeeditor/graphics')
-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 71c6ff3fc1..3988fbc64f 100644 --- a/utils/themeeditor/graphics/rbfont.cpp +++ b/utils/themeeditor/graphics/rbfont.cpp | |||
@@ -23,9 +23,75 @@ | |||
23 | 23 | ||
24 | #include <QFont> | 24 | #include <QFont> |
25 | #include <QBrush> | 25 | #include <QBrush> |
26 | #include <QFile> | ||
26 | 27 | ||
27 | RBFont::RBFont(QString file): filename(file) | 28 | #include <QDebug> |
29 | |||
30 | RBFont::RBFont(QString file) | ||
28 | { | 31 | { |
32 | |||
33 | /* Attempting to locate the correct file name */ | ||
34 | if(!QFile::exists(file)) | ||
35 | file = ":/fonts/08-Schumacher-Clean.fnt"; | ||
36 | header.insert("filename", file); | ||
37 | |||
38 | /* Opening the file */ | ||
39 | QFile fin(file); | ||
40 | fin.open(QFile::ReadOnly); | ||
41 | |||
42 | /* Loading the header info */ | ||
43 | quint16 word; | ||
44 | quint32 dword; | ||
45 | |||
46 | QDataStream data(&fin); | ||
47 | data.setByteOrder(QDataStream::LittleEndian); | ||
48 | |||
49 | /* Grabbing the magic number and version */ | ||
50 | data >> dword; | ||
51 | header.insert("version", dword); | ||
52 | |||
53 | /* Max font width */ | ||
54 | data >> word; | ||
55 | header.insert("maxwidth", word); | ||
56 | |||
57 | /* Font height */ | ||
58 | data >> word; | ||
59 | header.insert("height", word); | ||
60 | |||
61 | /* Ascent */ | ||
62 | data >> word; | ||
63 | header.insert("ascent", word); | ||
64 | |||
65 | /* Padding */ | ||
66 | data >> word; | ||
67 | |||
68 | /* First character code */ | ||
69 | data >> dword; | ||
70 | header.insert("firstchar", dword); | ||
71 | |||
72 | /* Default character code */ | ||
73 | data >> dword; | ||
74 | header.insert("defaultchar", dword); | ||
75 | |||
76 | /* Number of characters */ | ||
77 | data >> dword; | ||
78 | header.insert("size", dword); | ||
79 | |||
80 | /* Bytes of imagebits in file */ | ||
81 | data >> dword; | ||
82 | header.insert("nbits", dword); | ||
83 | |||
84 | /* Longs (dword) of offset data in file */ | ||
85 | data >> dword; | ||
86 | header.insert("noffset", dword); | ||
87 | |||
88 | /* Bytes of width data in file */ | ||
89 | data >> dword; | ||
90 | header.insert("nwidth", dword); | ||
91 | |||
92 | fin.close(); | ||
93 | |||
94 | qDebug() << header ; | ||
29 | } | 95 | } |
30 | 96 | ||
31 | RBFont::~RBFont() | 97 | 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 @@ | |||
25 | #include <QString> | 25 | #include <QString> |
26 | #include <QFile> | 26 | #include <QFile> |
27 | #include <QGraphicsSimpleTextItem> | 27 | #include <QGraphicsSimpleTextItem> |
28 | #include <QHash> | ||
28 | 29 | ||
29 | class RBFont | 30 | class RBFont |
30 | { | 31 | { |
@@ -37,7 +38,7 @@ public: | |||
37 | int lineHeight(){ return 8; } | 38 | int lineHeight(){ return 8; } |
38 | 39 | ||
39 | private: | 40 | private: |
40 | QString filename; | 41 | QHash<QString, QVariant> header; |
41 | }; | 42 | }; |
42 | 43 | ||
43 | #endif // RBFONT_H | 44 | #endif // RBFONT_H |