Subversion Repositories Scribus

Rev

Rev 10223 | Rev 15250 | 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
 
10223 cbradney 5
#include <QString>
6
//#include <QVector>
7
#include <QMap>
8
//#include <QArray>
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
13162 malex 60
        qreal ascent(qreal sz=1.0)    const { return m_ascent * sz; }
61
        qreal descent(qreal sz=1.0)   const { return m_descent * sz; }
62
        qreal xHeight(qreal sz=1.0)   const { return m_xHeight * sz; }
63
        qreal capHeight(qreal sz=1.0) const { return m_capHeight * sz; }
64
        qreal height(qreal sz=1.0)    const { return m_height * sz; }
65
        qreal strikeoutPos(qreal sz=1.0)    const { return m_strikeoutPos * sz; }
66
        qreal underlinePos(qreal sz=1.0)    const { return m_underlinePos * sz; }
67
        qreal strokeWidth(qreal /*sz*/)     const { return m_strokeWidth; }
68
        qreal maxAdvanceWidth(qreal 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
 
13162 malex 76
//FIXME QMap<QString,QString> fontDictionary(qreal sz=1.0)      const;
5980 avox 77
 
78
        uint         char2CMap(QChar ch)                         const;
79
 
13162 malex 80
        qreal       glyphKerning (uint gl1, uint gl2, qreal sz) const;
81
//      GlyphMetrics glyphBBox (uint gl,               qreal sz) const;
5980 avox 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
 
13162 malex 104
        mutable qreal m_uniEM;
105
        mutable qreal m_ascent;
106
        mutable qreal m_descent;
107
        mutable qreal m_height;
108
        mutable qreal m_xHeight;
109
        mutable qreal m_capHeight;
110
        mutable qreal m_maxAdvanceWidth;
111
        mutable qreal m_underlinePos;
112
        mutable qreal m_strikeoutPos;
113
        mutable qreal m_strokeWidth;
5980 avox 114
 
115
};
116
 
117
#endif