Subversion Repositories Scribus

Rev

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

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