summaryrefslogtreecommitdiffstats
path: root/kcontrol/kfontinst/kfontinst/FontEngine.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/kfontinst/kfontinst/FontEngine.h
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
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
Diffstat (limited to 'kcontrol/kfontinst/kfontinst/FontEngine.h')
-rw-r--r--kcontrol/kfontinst/kfontinst/FontEngine.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/kcontrol/kfontinst/kfontinst/FontEngine.h b/kcontrol/kfontinst/kfontinst/FontEngine.h
new file mode 100644
index 000000000..06218c0ae
--- /dev/null
+++ b/kcontrol/kfontinst/kfontinst/FontEngine.h
@@ -0,0 +1,142 @@
+#ifndef __FONT_ENGINE_H__
+#define __FONT_ENGINE_H__
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : KFI::CFontEngine
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 29/04/2001
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2001, 2002, 2003, 2004
+////////////////////////////////////////////////////////////////////////////////
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include <qstring.h>
+#include <qstringlist.h>
+
+namespace KFI
+{
+
+class CFontEngine
+{
+ public:
+
+ enum EType
+ {
+ // These have PS Info / support AFM stuff...
+ TRUE_TYPE,
+ TT_COLLECTION,
+ TYPE_1,
+ NONE
+ };
+
+ enum EWeight
+ {
+ WEIGHT_UNKNOWN=0,
+ WEIGHT_THIN,
+ WEIGHT_ULTRA_LIGHT,
+ WEIGHT_EXTRA_LIGHT,
+ WEIGHT_DEMI,
+ WEIGHT_LIGHT,
+ WEIGHT_BOOK,
+ WEIGHT_MEDIUM,
+ WEIGHT_REGULAR,
+ WEIGHT_SEMI_BOLD,
+ WEIGHT_DEMI_BOLD,
+ WEIGHT_BOLD,
+ WEIGHT_EXTRA_BOLD,
+ WEIGHT_ULTRA_BOLD,
+ WEIGHT_HEAVY,
+ WEIGHT_BLACK
+ };
+
+ enum EItalic
+ {
+ ITALIC_NONE,
+ ITALIC_ITALIC,
+ ITALIC_OBLIQUE
+ };
+
+ private:
+
+ struct TFtData
+ {
+ TFtData();
+ ~TFtData();
+
+ FT_Library library;
+ FT_Face face;
+ bool open;
+ };
+
+ public:
+
+ CFontEngine() : itsType(NONE) { }
+ ~CFontEngine() { closeFont(); }
+
+ static EType getType(const char *fname);
+ static QString weightStr(EWeight w);
+ static QString italicStr(EItalic i) { return ITALIC_NONE==i ? "r" : ITALIC_ITALIC==i ? "i" : "o"; }
+
+ //
+ // General functions - these should be used instead of specfic ones below...
+ //
+ bool openFont(const QString &file, int face=0);
+ void closeFont();
+
+ //
+ const QString & getFamilyName() { return itsFamily; }
+ const QString & getPsName() { return itsPsName; }
+ EWeight getWeight() { return itsWeight; }
+ EItalic getItalic() { return itsItalic; }
+ EType getType() { return itsType; }
+ int getNumFaces() { return itsFt.open ? itsFt.face->num_faces : 1; }
+ bool hasPsInfo() { return itsType!=NONE; }
+
+ static EWeight strToWeight(const char *str);
+
+ private:
+
+ bool openFontFt(const QString &file);
+ void closeFaceFt();
+
+ private:
+
+ EWeight itsWeight;
+ EType itsType;
+ EItalic itsItalic;
+ QString itsFamily,
+ itsPsName,
+ itsPath;
+ int itsNumFaces,
+ itsFaceIndex; // Only for TTC fonts - at the moment...
+ TFtData itsFt;
+};
+
+}
+
+#endif