Rev 24153 | Rev 24466 | 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 | |||
22599 | craig | 56 | FtFace(const QString& fam, const QString& sty, const QString& variant, const QString& scname, |
57 | const QString& psname, const QString& path, int face, const QStringList& features); |
||
19104 | jghali | 58 | |
24205 | craig | 59 | FT_Face ftFace() const override; |
5980 | avox | 60 | |
61 | virtual ~FtFace(); |
||
19104 | jghali | 62 | |
5980 | avox | 63 | // font metrics |
24205 | craig | 64 | qreal ascent(qreal sz=1.0) const override { return m_ascent * sz; } |
65 | qreal descent(qreal sz=1.0) const override { return m_descent * sz; } |
||
66 | qreal xHeight(qreal sz=1.0) const override { return m_xHeight * sz; } |
||
67 | qreal capHeight(qreal sz=1.0) const override { return m_capHeight * sz; } |
||
68 | qreal height(qreal sz=1.0) const override { return m_height * sz; } |
||
69 | qreal strikeoutPos(qreal sz=1.0) const override { return m_strikeoutPos * sz; } |
||
70 | qreal underlinePos(qreal sz=1.0) const override { return m_underlinePos * sz; } |
||
71 | qreal strokeWidth(qreal /*sz*/) const override { return m_strokeWidth; } |
||
72 | qreal maxAdvanceWidth(qreal sz=1.0) const override { return m_maxAdvanceWidth * sz; } |
||
73 | QString pdfAscentAsString() const override { return m_pdfAscent; } |
||
74 | QString pdfDescentAsString() const override { return m_pdfDescender; } |
||
75 | QString pdfCapHeightAsString() const override { return m_pdfCapHeight; } |
||
76 | QString pdfFontBBoxAsString() const override { return m_pdfFontBBox; } |
||
77 | QString italicAngleAsString() const override { return m_italicAngle; } |
||
19104 | jghali | 78 | |
24153 | jghali | 79 | bool isItalic() const override { return m_isItalic; } |
80 | bool isBold() const override { return m_isBold; } |
||
19104 | jghali | 81 | |
23653 | craig | 82 | //FIXME QMap<QString,QString> fontDictionary(qreal sz=1.0) const; |
19104 | jghali | 83 | |
24205 | craig | 84 | ScFace::gid_type char2CMap(uint ch) const override; |
5980 | avox | 85 | |
23653 | craig | 86 | // GlyphMetrics glyphBBox (gid_type gl, qreal sz) const; |
5980 | avox | 87 | |
24153 | jghali | 88 | void rawData(QByteArray & bb) const override; |
19396 | jghali | 89 | |
20001 | avox | 90 | static bool hasMicrosoftUnicodeCmap(FT_Face face); |
19396 | jghali | 91 | static QString adobeGlyphName(FT_ULong charcode); |
24205 | craig | 92 | bool glyphNames(ScFace::FaceEncoding& glyphList) const override; |
19396 | jghali | 93 | |
24153 | jghali | 94 | void load() const override; |
95 | void unload() const override; |
||
96 | void loadGlyph (ScFace::gid_type gl) const override; |
||
5980 | avox | 97 | |
98 | protected: |
||
99 | mutable FT_Face m_face; |
||
19104 | jghali | 100 | |
20691 | craig | 101 | static FT_Library m_library; |
5980 | avox | 102 | |
21563 | jghali | 103 | mutable bool m_isBold; |
104 | mutable bool m_isItalic; |
||
105 | |||
17778 | jghali | 106 | mutable QString m_pdfAscent; |
107 | mutable QString m_pdfCapHeight; |
||
108 | mutable QString m_pdfDescender; |
||
109 | mutable QString m_italicAngle; |
||
110 | mutable QString m_pdfFontBBox; |
||
5980 | avox | 111 | |
112 | mutable int m_encoding; |
||
19104 | jghali | 113 | |
13162 | malex | 114 | mutable qreal m_uniEM; |
115 | mutable qreal m_ascent; |
||
116 | mutable qreal m_descent; |
||
117 | mutable qreal m_height; |
||
118 | mutable qreal m_xHeight; |
||
119 | mutable qreal m_capHeight; |
||
120 | mutable qreal m_maxAdvanceWidth; |
||
121 | mutable qreal m_underlinePos; |
||
122 | mutable qreal m_strikeoutPos; |
||
123 | mutable qreal m_strokeWidth; |
||
19104 | jghali | 124 | |
22143 | jghali | 125 | QString uniGlyphNameToUnicode(const QString& glyphName) const; |
5980 | avox | 126 | }; |
127 | |||
128 | #endif |