Scribus
Open source desktop publishing at your fingertips
sfnt.h
1 //
2 // sfnt.h
3 // Scribus
4 //
5 // Created by Andreas Vox on 18.04.15.
6 //
7 //
8 
9 #ifndef Scribus_sfnt_h
10 #define Scribus_sfnt_h
11 
12 #include "scribusapi.h"
13 
14 #include <QByteArray>
15 #include <QList>
16 #include <QMap>
17 #include <QString>
18 
19 #include <ft2build.h>
20 #include FT_FREETYPE_H
21 
22 
23 
24 namespace sfnt {
25 
26  uchar byte(QByteArray const & bb, uint pos);
27  quint32 word(QByteArray const & bb, uint pos);
28  void putWord(QByteArray & bb, uint pos, quint32 val);
29  void appendWord(QByteArray& bb, quint32 val);
30  quint16 word16(QByteArray const & bb, uint pos);
31  void putWord16(QByteArray & bb, uint pos, quint16 val);
32  void appendWord16(QByteArray& bb, quint16 val);
33  bool copy(QByteArray & dst, uint to, const QByteArray & src, uint from, uint len);
34  const QByteArray tag(QByteArray const & bb, uint pos);
35  const QByteArray getTable(const QByteArray& ttf, const QByteArray& ttfTag);
36 
37 
38  QByteArray subsetFace(const QByteArray& ttf, QList<uint>& glyphs);
39  QByteArray extractFace(const QByteArray& ttfColl, int faceIndex);
40 
44 class SCRIBUS_API PostTable {
45 public:
46  bool usable;
47  QString errorMsg;
48  uint numberOfGlyphs() const;
49  QString nameFor(uint glyphId) const;
50  void readFrom(FT_Face face);
51 private:
52  QList<QString> names;
53 };
54 
55 } //namespace
56 
57 
62 class SCRIBUS_API KernFeature
63 {
64  typedef QMap<quint16, QList<quint16> > ClassDefTable; // <Class index (0 to N) , list of glyphs >
65 
66 public:
71  KernFeature ( FT_Face face );
72  KernFeature ( const KernFeature& kf );
73  ~KernFeature();
74 
81  double getPairValue ( unsigned int glyph1, unsigned int glyph2 ) const;
82 
87  bool isValid() const {return m_valid;}
88 
89 private:
90  bool m_valid;
91  QByteArray GPOSTableRaw;
92  QMap<quint16,QList<quint16> > coverages;
93  mutable QMap<quint16, QMap<quint16, double> > pairs;
94  QMap< quint16, QMap<quint16, ClassDefTable> > classGlyphFirst; // < subtable offset, map<offset, class definition table> > for first glyph
95  QMap< quint16, QMap<quint16, ClassDefTable> > classGlyphSecond; // < subtable offset, map<offset, class definition table> > for second glyph
96  QMap< quint16, QMap<int, QMap<int, double> > > classValue; // < subtable offset, map<class1, map<class2, value> > >
97 
98  void makeCoverage();
99  void makePairs ( quint16 subtableOffset );
100 
101  ClassDefTable getClass (bool leftGlyph, quint16 classDefOffset, quint16 coverageId );
102  inline quint16 toUint16 ( quint16 index );
103  inline qint16 toInt16 ( quint16 index );
104 
105  QString FontName;// for debugging purpose
106 };
107 
108 
109 #endif
110 
Definition: sfnt.h:62
Definition: sfnt.cpp:18
bool isValid() const
Definition: sfnt.h:87
Definition: sfnt.h:44