add more spacing
[personal-kdebase.git] / workspace / kcontrol / kfontinst / strigi-analyzer / FontEngine.h
blobe80099dafaf1685f850d9f292ad2117f9909b673
1 #ifndef __FONT_ENGINE_H__
2 #define __FONT_ENGINE_H__
4 /*
5 * KFontInst - KDE Font Installer
7 * Copyright 2003-2007 Craig Drummond <craig@kde.org>
9 * ----
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; see the file COPYING. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
27 #include <config-workspace.h>
28 #include <fontconfig/fontconfig.h>
30 #if (FC_VERSION>=20402)
31 #define HAVE_FcFreeTypeQueryFace
32 #include <fontconfig/fcfreetype.h>
33 #endif
35 #include <ft2build.h>
36 #include FT_FREETYPE_H
37 #include <QtCore/QString>
38 #include <strigi/streambase.h>
40 class QByteArray;
42 namespace KFI
45 class CFontEngine
47 public:
49 enum EType
51 TYPE_OTF,
52 TYPE_TTF,
53 TYPE_TTC,
54 TYPE_TYPE1,
55 TYPE_PCF,
56 TYPE_BDF,
57 TYPE_AFM,
59 TYPE_UNKNOWN
62 private:
64 struct TFtData
66 TFtData();
67 ~TFtData();
69 FT_Library library;
70 FT_Face face;
71 bool open;
74 public:
76 static EType getType(const char *fileName, Strigi::InputStream *in);
77 static EType getType(const char *fileName);
78 static EType getType(const char *fileName, const unsigned char *header);
79 static double decodeFixed(long v) { return (v>>16)+(((double)(v&0xFFFF))/0xFFFF); }
80 static QString & fixFoundry(QString &foundry);
82 CFontEngine() { }
83 ~CFontEngine() { closeFont(); }
86 // General functions - these should be used instead of specific ones below...
88 bool openFont(EType type, QByteArray &in, const char *fileName, int face=0);
89 void closeFont();
92 // These are only for non-bitmap fonts...
93 const QString & getFamilyName() { return itsFamily; }
94 int getWeight() { return itsWeight; }
95 int getWidth() { return itsWidth; }
96 int getItalic() { return itsItalic; }
97 int getSpacing() { return itsSpacing; }
98 const QString & getFoundry() { return itsFoundry; }
99 const QString & getVersion() { return itsVersion; }
100 int getNumFaces() { return itsFt.open ? itsFt.face->num_faces : 1; }
102 private:
104 bool openFontFt(QByteArray &in, const char *fileName, int face, bool type1);
105 bool openFontAfm(QByteArray &in);
106 #ifndef HAVE_FcFreeTypeQueryFace
107 void parseXlfdBmp(const QString &lfd);
108 bool openFontBdf(QByteArray &in);
109 bool openFontPcf(QByteArray &in);
110 #endif
112 private:
114 int itsWeight,
115 itsWidth,
116 itsItalic,
117 itsSpacing;
118 QString itsFamily,
119 itsFoundry,
120 itsVersion;
121 TFtData itsFt;
126 #endif