Subversion Repositories Scribus

Rev

Rev 5980 | Rev 6163 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5980 avox 1
#ifndef FT_FACE_H
2
#define FT_FACE_H
3
 
4
 
5
#include <qstring.h>
6079 fschmid 6
//#include <qvector.h>
5980 avox 7
#include <qmap.h>
6079 fschmid 8
//#include <qarray.h>
5980 avox 9
 
10
#include "scribusapi.h"
11
 
12
#include "fonts/scface.h"
13
 
14
#include <ft2build.h>
15
#include FT_FREETYPE_H
16
 
17
#include "fpointarray.h"
18
 
19
FT_Error ftIOFunc( FT_Stream stream, unsigned long pos, unsigned char* buffer, unsigned long count);
20
 
21
 
22
/*! \brief Base Class FtFace provides an ScFace private implementation
23
     for Freetype based fonts. Subclasses are ScFace_ps and ScFace_ttf.
24
 
25
Below is the old docs for class Foi:
26
 
27
This is subclassed by a class to handle Type1 fonts, a class
28
to handle TrueType fonts, and potentially any other type that becomes appropriate in
29
the future.
30
Note the virtual destructor, needed to ensure that the correct destructor is called
31
for subclasses
32
 
33
The RealName field has been changed from a data member to a member function.
34
This is because the only place the PostScript real name of a font is required is
35
the printing code, so it's cheaper to extract this information only when it is
36
required, for just the used fonts, than for every one of potentially hundreds at
37
application startup!  This also allows for the fact that truetype fonts will require
38
a different method of extracting their names.
39
 
40
One implication of using a base class/subclass model for fonts:  It is no longer
41
possible to store the ScFace structures in a QMap.  This is because QMap allocates
42
its own structures, and copies the supplied data to them.  A QMap<QString,ScFace>
43
would demote all subclasses to ScFace classes, and hence break the polymorphism.
44
QDict can be used instead, with very little change to the rest of the code, since
45
it stores references to the data instead of copying the data.  With AutoDelete set
46
to true, it will automatically dispose of all data when its destructor is called,
47
so there are no extra cleaning-up chores to take care of.
48
*/
49
struct SCRIBUS_API FtFace : public ScFace::ScFaceData
50
{
51
 
52
        FtFace(QString fam, QString sty, QString variant, QString scname,
53
                   QString psname, QString path, int face);
54
 
55
        FT_Face ftFace() const;
56
 
57
        virtual ~FtFace();
58
 
59
        // font metrics
60
        double ascent(double sz=1.0)    const { return m_ascent * sz; }
61
        double descent(double sz=1.0)   const { return m_descent * sz; }
62
        double xHeight(double sz=1.0)   const { return m_xHeight * sz; }
63
        double capHeight(double sz=1.0) const { return m_capHeight * sz; }
64
        double height(double sz=1.0)    const { return m_height * sz; }
65
        double strikeoutPos(double sz=1.0)    const { return m_strikeoutPos * sz; }
66
        double underlinePos(double sz=1.0)    const { return m_underlinePos * sz; }
67
        double strokeWidth(double sz=1.0)     const { return m_strokeWidth; }
68
        double maxAdvanceWidth(double sz=1.0) const { return m_maxAdvanceWidth * sz; }
69
 
70
 
71
//FIXME QMap<QString,QString> fontDictionary(double sz=1.0)      const;
72
 
73
        uint         char2CMap(QChar ch)                         const;
74
 
75
        double       glyphKerning (uint gl1, uint gl2, double sz) const;
76
        GlyphMetrics glyphBBox (uint gl,               double sz) const;
77
 
78
        void RawData   (QByteArray & bb)            const;
79
        bool glyphNames(QMap<QChar, std::pair<uint, QString> >& GList) const;
80
        void load      ()                           const;
81
        void unload    ()                           const;
82
        void loadGlyph (uint ch)                    const;
83
 
84
protected:
85
        mutable FT_Face m_face;
86
 
87
        static FT_Library library;
88
 
89
        QString Ascent;
90
        QString CapHeight;
91
        QString Descender;
92
        QString ItalicAngle;
93
        QString StdVW;
94
        QString FontEnc;
95
        QString FontBBox;
96
 
97
        mutable int m_encoding;
98
 
99
        mutable double m_uniEM;
100
        mutable double m_ascent;
101
        mutable double m_descent;
102
        mutable double m_height;
103
        mutable double m_xHeight;
104
        mutable double m_capHeight;
105
        mutable double m_maxAdvanceWidth;
106
        mutable double m_underlinePos;
107
        mutable double m_strikeoutPos;
108
        mutable double m_strokeWidth;
109
 
110
};
111
 
112
#endif