Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
5979 avox 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
#ifndef SCFACE_TTF_H
8
#define SCFACE_TTF_H
9
 
10
#include "scribusapi.h"
11
#include "fonts/ftface.h"
12
 
16365 mrdocs 13
 
14
#include FT_TRUETYPE_TABLES_H
15
#include FT_TRUETYPE_TAGS_H
16
 
17
 
18
/**
19
        An object holding a table of kerning pairs extracted from
20
        a kern feature such as found in a GPOS table
21
 */
22
class SCRIBUS_API KernFeature
23
{
24
        public:
25
                /**
26
                * Build a ready-to-use kerning pairs table
27
                * @param face a valid FT_Face, It won’t be store by KernFeature
28
                 */
29
                KernFeature ( FT_Face face );
30
                KernFeature ( const KernFeature& kf );
31
                ~KernFeature();
32
 
33
                /**
34
                 * Get the kerning value for a pair of glyph indexes.
35
                 * @param glyph1 Index of the left glyph in logical order
36
                 * @param glyph2 Index of the right glyph in logical order
37
                 * @return the unscaled delta to apply to xadvance of the first glyph
38
                 */
39
                double getPairValue ( unsigned int glyph1, unsigned int glyph2 ) const;
40
 
41
                /**
42
                 * The table can have been invalidated if something went wrong at any moment.
43
                 * @return True if valid, False otherwise.
44
                 */
45
                bool isValid() const {return m_valid;}
46
 
47
        private:
48
                bool m_valid;
49
                QByteArray GPOSTableRaw;
50
                QMap<quint16,QList<quint16> > coverages;
51
                QMap<quint16, QMap<quint16, double> > pairs;
52
 
53
                void makeCoverage();
54
                void makePairs ( quint16 subtableOffset );
55
 
56
                typedef QMap<quint16, QList<quint16> > ClassDefTable; // <Class , list<GLyph> >
57
                ClassDefTable getClass ( quint16 classDefOffset, quint16 coverageId );
58
                inline quint16 toUint16 ( quint16 index );
59
                inline qint16 toInt16 ( quint16 index );
60
 
61
                enum ValueFormat
62
                {
63
                        XPlacement = 0x0001,
64
                        YPlacement = 0x0002,
65
                        XAdvance = 0x0004,
66
                        YAdvance = 0x0008,
67
                        XPlaDevice =0x0010,
68
                        YPlaDevice =0x0020,
69
                        XAdvDevice =0x0040,
70
                        YAdvDevice =0x0080
71
                };
72
                QString FontName;// for debugging purpose
73
};
74
 
75
 
76
 
5979 avox 77
/*
78
        Class ScFace_ttf
79
        Subclass of ScFace, specifically for TrueType fonts.
80
        Implements: RealName() and EmbedFont().
81
*/
82
 
83
class SCRIBUS_API ScFace_ttf : public FtFace
84
{
13345 pierre 85
public:
16365 mrdocs 86
        ScFace_ttf ( QString fam, QString sty, QString alt, QString scname, QString psname, QString path, int face );
87
        ~ScFace_ttf();
88
 
89
        void load () const;
90
        void unload () const;
91
 
13345 pierre 92
        bool EmbedFont(QString &str) const;
93
        void RawData(QByteArray & bb) const;
16365 mrdocs 94
 
95
        qreal glyphKerning ( uint gl1, uint gl2, qreal sz ) const;
96
 
97
private:
98
        mutable KernFeature * kernFeature;
5979 avox 99
};
100
 
101
#endif