2 This file is part of Konsole, an X terminal.
3 Copyright 2005 by Maksim Orlovich <maksim@kde.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include <QtCore/QFile>
22 #include <QtCore/QTextStream>
29 static quint32
charVal(QChar val
)
37 static quint32
readGlyphLine(QTextStream
& input
)
39 QString line
= input
.readLine();
40 while (line
.length() < 5)
43 quint32 val
= charVal(line
[0]) |
44 (charVal(line
[1]) << 1) |
45 (charVal(line
[2]) << 2) |
46 (charVal(line
[3]) << 3) |
47 (charVal(line
[4]) << 4);
51 static quint32
readGlyph(QTextStream
& input
)
53 return readGlyphLine(input
) |
54 (readGlyphLine(input
) << 5) |
55 (readGlyphLine(input
) << 10) |
56 (readGlyphLine(input
) << 15) |
57 (readGlyphLine(input
) << 20);
60 int main(int argc
, char **argv
)
64 qWarning("usage: fontembedder font.src > font.h");
67 QFile
inFile(argv
[1]);
68 if (!inFile
.open(QIODevice::ReadOnly
))
70 qFatal("Can not open %s", argv
[1]);
73 QTextStream
input(&inFile
);
75 quint32 glyphStates
[128];
76 for (int i
= 0; i
< 128; ++i
)
77 glyphStates
[i
] = 0; //nothing..
79 while (!input
.atEnd())
81 QString line
= input
.readLine();
82 line
= line
.trimmed();
84 continue; //Skip empty lines
86 continue; //Skip comments
89 int glyph
= line
.toInt(0, 16);
90 if ((glyph
< 0x2500) || (glyph
> 0x257f))
91 qFatal("Invalid glyph number");
93 glyph
= glyph
- 0x2500;
95 glyphStates
[glyph
] = readGlyph(input
);
99 cout
<<"// WARNING: Autogenerated by \"fontembedder " << argv
[1] << "\".\n";
100 cout
<<"// You probably do not want to hand-edit this!\n\n";
101 cout
<<"static const quint32 LineChars[] = {\n";
103 //Nicely formatted: 8 per line, 16 lines
104 for (int line
= 0; line
< 128; line
+= 8)
107 for (int col
= line
; col
< line
+ 8; ++col
)
109 cout
<<"0x"<<hex
<<setw(8)<<setfill('0')<<glyphStates
[col
];
119 //kate: indent-width 4; tab-width 4; space-indent on;