• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Konsole

fontembedder.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of Konsole, an X terminal.
00003     Copyright 2005 by Maksim Orlovich <maksim@kde.org>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018     02110-1301  USA.
00019 */
00020 
00021 #include <QtCore/QFile>
00022 #include <QtCore/QTextStream>
00023 #include <stdlib.h>
00024 #include <iostream>
00025 #include <iomanip>
00026 
00027 using namespace std;
00028 
00029 static quint32 charVal(QChar val)
00030 {
00031     if (val == ' ')
00032         return 0;
00033     else
00034         return 1;
00035 }
00036 
00037 static quint32 readGlyphLine(QTextStream& input)
00038 {
00039     QString line = input.readLine();
00040     while (line.length() < 5)
00041         line += ' ';
00042 
00043     quint32 val =  charVal(line[0]) |
00044             (charVal(line[1]) << 1)  |
00045             (charVal(line[2]) << 2)  |
00046             (charVal(line[3]) << 3)  |
00047             (charVal(line[4]) << 4);
00048     return val;
00049 }
00050 
00051 static quint32 readGlyph(QTextStream& input)
00052 {
00053     return readGlyphLine(input) |
00054             (readGlyphLine(input) << 5) |
00055             (readGlyphLine(input) << 10) |
00056             (readGlyphLine(input) << 15) |
00057             (readGlyphLine(input) << 20);
00058 }
00059 
00060 int main(int argc, char **argv)
00061 {
00062     if (argc < 1)
00063     {
00064         qWarning("usage: fontembedder font.src > font.h");
00065         exit(1);
00066     }
00067     QFile inFile(argv[1]);
00068     if (!inFile.open(QIODevice::ReadOnly))
00069     {
00070         qFatal("Can not open %s", argv[1]);
00071     }
00072 
00073     QTextStream input(&inFile);
00074 
00075     quint32 glyphStates[128];
00076     for (int i = 0; i < 128; ++i)
00077         glyphStates[i] = 0; //nothing..
00078 
00079     while (!input.atEnd())
00080     {
00081         QString line = input.readLine();
00082         line = line.trimmed();
00083         if (line.isEmpty())
00084             continue; //Skip empty lines
00085         if (line[0] == '#')
00086             continue; //Skip comments
00087 
00088         //Must be a glyph ID.
00089         int glyph = line.toInt(0, 16);
00090         if ((glyph < 0x2500) || (glyph > 0x257f))
00091             qFatal("Invalid glyph number");
00092 
00093         glyph = glyph - 0x2500;
00094 
00095         glyphStates[glyph] = readGlyph(input);
00096     }
00097 
00098     //Output.
00099     cout<<"// WARNING: Autogenerated by \"fontembedder " << argv[1] << "\".\n";
00100     cout<<"// You probably do not want to hand-edit this!\n\n";
00101     cout<<"static const quint32 LineChars[] = {\n";
00102 
00103     //Nicely formatted: 8 per line, 16 lines
00104     for (int line = 0; line < 128; line += 8)
00105     {
00106         cout<<"\t";
00107         for (int col = line; col < line + 8; ++col)
00108         {
00109             cout<<"0x"<<hex<<setw(8)<<setfill('0')<<glyphStates[col];
00110             if (col != 127)
00111                 cout<<", ";
00112         }
00113         cout<<"\n";
00114     }
00115     cout<<"};\n";
00116     return 0;
00117 }
00118 
00119 //kate: indent-width 4; tab-width 4; space-indent on;

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • Konsole
  • Libraries
  •   libkonq
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal