~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to kcontrol/kfontinst/strigi-analyzer/FontEngine.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

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