From 4aed2c8219774f5d797760606b8489a92ddc5163 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- konsole/konsole/fontembedder.cpp | 119 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 konsole/konsole/fontembedder.cpp (limited to 'konsole/konsole/fontembedder.cpp') diff --git a/konsole/konsole/fontembedder.cpp b/konsole/konsole/fontembedder.cpp new file mode 100644 index 000000000..f2a189598 --- /dev/null +++ b/konsole/konsole/fontembedder.cpp @@ -0,0 +1,119 @@ +/* + This file is part of Konsole, an X terminal. + Copyright (C) 2005 by Maksim Orlovich + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. +*/ + +#include +#include +#include +#include +#include + +using namespace std; + +static Q_UINT32 charVal(QChar val) +{ + if (val == ' ') + return 0; + else + return 1; +} + +static Q_UINT32 readGlyphLine(QTextStream& input) +{ + QString line = input.readLine(); + while (line.length() < 5) + line += ' '; + + Q_UINT32 val = charVal(line[0]) | + (charVal(line[1]) << 1) | + (charVal(line[2]) << 2) | + (charVal(line[3]) << 3) | + (charVal(line[4]) << 4); + return val; +} + +static Q_UINT32 readGlyph(QTextStream& input) +{ + return readGlyphLine(input) | + (readGlyphLine(input) << 5) | + (readGlyphLine(input) << 10) | + (readGlyphLine(input) << 15) | + (readGlyphLine(input) << 20); +} + +int main(int argc, char **argv) +{ + if (argc < 1) + { + qWarning("usage: fontembedder font.src > font.h"); + exit(1); + } + QFile inFile(argv[1]); + if (!inFile.open(IO_ReadOnly)) + { + qFatal("Can not open %s", argv[1]); + } + + QTextStream input(&inFile); + + Q_UINT32 glyphStates[128]; + for (int i = 0; i < 128; ++i) + glyphStates[i] = 0; //nothing.. + + while (!input.atEnd()) + { + QString line = input.readLine(); + line = line.stripWhiteSpace(); + if (line.isEmpty()) + continue; //Skip empty lines + if (line[0] == '#') + continue; //Skip comments + + //Must be a glyph ID. + int glyph = line.toInt(0, 16); + if ((glyph < 0x2500) || (glyph > 0x257f)) + qFatal("Invalid glyph number"); + + glyph = glyph - 0x2500; + + glyphStates[glyph] = readGlyph(input); + } + + //Output. + cout<<"// WARNING: Autogenerated by \"fontembedder " << argv[1] << "\".\n"; + cout<<"// You probably do not want to hand-edit this!\n\n"; + cout<<"static const Q_UINT32 LineChars[] = {\n"; + + //Nicely formatted: 8 per line, 16 lines + for (int line = 0; line < 128; line += 8) + { + cout<<"\t"; + for (int col = line; col < line + 8; ++col) + { + cout<<"0x"<