Subversion Repositories Scribus

Rev

Rev 6213 | Rev 8495 | 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; }
6213 fschmid 69
        QString ascentAsString()    const { return Ascent; }
70
        QString descentAsString()    const { return Descender; }
71
        QString capHeightAsString()    const { return CapHeight; }
72
        QString FontBBoxAsString()    const { return FontBBox; }
73
        QString ItalicAngleAsString()    const { return ItalicAngle; }
5980 avox 74
 
75
 
76
//FIXME QMap<QString,QString> fontDictionary(double sz=1.0)      const;
77
 
78
        uint         char2CMap(QChar ch)                         const;
79
 
80
        double       glyphKerning (uint gl1, uint gl2, double sz) const;
81
        GlyphMetrics glyphBBox (uint gl,               double sz) const;
82
 
83
        void RawData   (QByteArray & bb)            const;
6163 avox 84
        bool glyphNames(QMap<uint, std::pair<QChar, QString> >& GList) const;
5980 avox 85
        void load      ()                           const;
86
        void unload    ()                           const;
87
        void loadGlyph (uint ch)                    const;
88
 
89
protected:
90
        mutable FT_Face m_face;
91
 
92
        static FT_Library library;
93
 
6213 fschmid 94
        mutable QString Ascent;
95
        mutable QString CapHeight;
96
        mutable QString Descender;
97
        mutable QString ItalicAngle;
98
        mutable QString StdVW;
5980 avox 99
        QString FontEnc;
6213 fschmid 100
        mutable QString FontBBox;
5980 avox 101
 
102
        mutable int m_encoding;
103
 
104
        mutable double m_uniEM;
105
        mutable double m_ascent;
106
        mutable double m_descent;
107
        mutable double m_height;
108
        mutable double m_xHeight;
109
        mutable double m_capHeight;
110
        mutable double m_maxAdvanceWidth;
111
        mutable double m_underlinePos;
112
        mutable double m_strikeoutPos;
113
        mutable double m_strokeWidth;
114
 
115
};
116
 
117
#endif