• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Konsole

  • sources
  • kde-4.12
  • applications
  • konsole
  • src
fontembedder.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Konsole, an X terminal.
3  Copyright 2005 by Maksim Orlovich <maksim@kde.org>
4 
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.
9 
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.
14 
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
18  02110-1301 USA.
19 */
20 
21 // Standard
22 #include <stdlib.h>
23 #include <iostream>
24 #include <iomanip>
25 
26 // Qt
27 #include <QtCore/QFile>
28 #include <QtCore/QTextStream>
29 
30 #include <KDebug>
31 
32 using namespace std;
33 
34 static quint32 charVal(QChar val)
35 {
36  if (val == ' ')
37  return 0;
38  else
39  return 1;
40 }
41 
42 static quint32 readGlyphLine(QTextStream& input)
43 {
44  QString line = input.readLine();
45  while (line.length() < 5)
46  line += ' ';
47 
48  quint32 val = charVal(line[0]) |
49  (charVal(line[1]) << 1) |
50  (charVal(line[2]) << 2) |
51  (charVal(line[3]) << 3) |
52  (charVal(line[4]) << 4);
53  return val;
54 }
55 
56 static quint32 readGlyph(QTextStream& input)
57 {
58  return readGlyphLine(input) |
59  (readGlyphLine(input) << 5) |
60  (readGlyphLine(input) << 10) |
61  (readGlyphLine(input) << 15) |
62  (readGlyphLine(input) << 20);
63 }
64 
65 int main(int argc, char **argv)
66 {
67  if (argc != 2) {
68  qWarning("usage: fontembedder LineFont.src > LineFont.h");
69  exit(1);
70  }
71  QFile inFile(argv[1]);
72  if (!inFile.open(QIODevice::ReadOnly)) {
73  qWarning("Can not open %s", argv[1]);
74  exit(1);
75  }
76 
77  QTextStream input(&inFile);
78 
79  quint32 glyphStates[128];
80  QMap<quint32, int> glyphMap;
81 
82  for (int i = 0; i < 128; ++i)
83  glyphStates[i] = 0; //nothing..
84 
85  while (!input.atEnd()) {
86  QString line = input.readLine();
87  line = line.trimmed();
88  if (line.isEmpty())
89  continue; //Skip empty lines
90  if (line[0] == '#')
91  continue; //Skip comments
92 
93  //Must be a glyph ID.
94  int glyph = line.toInt(0, 16);
95  if ((glyph < 0x2500) || (glyph > 0x257f))
96  qFatal("Invalid glyph number");
97 
98  glyph = glyph - 0x2500;
99 
100  glyphStates[glyph] = readGlyph(input);
101  // kWarning()<<glyph<<";"<<glyphStates[glyph];
102 
103  if (glyphMap.contains(glyphStates[glyph])) {
104  kWarning()<<"Code "<<glyph<<" and "<<glyphMap.value(glyphStates[glyph])<<"have the same glyph state"<<glyphStates[glyph];
105  }
106  glyphMap[glyphStates[glyph]] = glyph;
107 
108  }
109 
110  //Output.
111  cout << "// WARNING: Autogenerated by \"fontembedder " << argv[1] << "\".\n";
112  cout << "// You probably do not want to hand-edit this!\n\n";
113  cout << "static const quint32 LineChars[] = {\n";
114 
115  //Nicely formatted: 8 per line, 16 lines
116  for (int line = 0; line < 128; line += 8) {
117  cout << "\t";
118  for (int col = line; col < line + 8; ++col) {
119  cout << "0x" << hex << setw(8) << setfill('0') << glyphStates[col];
120  if (col != 127)
121  cout << ", ";
122  }
123  cout << "\n";
124  }
125  cout << "};\n";
126  return 0;
127 }
128 
main
int main(int argc, char **argv)
Definition: fontembedder.cpp:65
readGlyph
static quint32 readGlyph(QTextStream &input)
Definition: fontembedder.cpp:56
charVal
static quint32 charVal(QChar val)
Definition: fontembedder.cpp:34
readGlyphLine
static quint32 readGlyphLine(QTextStream &input)
Definition: fontembedder.cpp:42
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:24 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Konsole

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

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Applications
  •   Libraries
  •     libkonq
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal