Line data Source code
1 : /* GRAPHITE2 LICENSING
2 :
3 : Copyright 2010, SIL International
4 : All rights reserved.
5 :
6 : This library is free software; you can redistribute it and/or modify
7 : it under the terms of the GNU Lesser General Public License as published
8 : by the Free Software Foundation; either version 2.1 of License, or
9 : (at your option) any later version.
10 :
11 : This program is distributed in the hope that it will be useful,
12 : but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : Lesser General Public License for more details.
15 :
16 : You should also have received a copy of the GNU Lesser General Public
17 : License along with this library in the file named "LICENSE".
18 : If not, write to the Free Software Foundation, 51 Franklin Street,
19 : Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
20 : internet at http://www.fsf.org/licenses/lgpl.html.
21 :
22 : Alternatively, the contents of this file may be used under the terms of the
23 : Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
24 : License, as published by the Free Software Foundation, either version 2
25 : of the License or (at your option) any later version.
26 : */
27 : #pragma once
28 :
29 : #include "graphite2/Font.h"
30 : #include "inc/Main.h"
31 : #include "inc/Pass.h"
32 :
33 : namespace graphite2 {
34 :
35 : class Face;
36 : class Segment;
37 : class FeatureVal;
38 : class VMScratch;
39 : class Error;
40 :
41 : class Pseudo
42 : {
43 : public:
44 : uint32 uid;
45 : uint32 gid;
46 0 : CLASS_NEW_DELETE;
47 : };
48 :
49 : class Justinfo
50 : {
51 : public:
52 0 : Justinfo(uint8 stretch, uint8 shrink, uint8 step, uint8 weight) :
53 : m_astretch(stretch), m_ashrink(shrink), m_astep(step),
54 0 : m_aweight(weight) {};
55 0 : uint8 attrStretch() const { return m_astretch; }
56 0 : uint8 attrShrink() const { return m_ashrink; }
57 0 : uint8 attrStep() const { return m_astep; }
58 0 : uint8 attrWeight() const { return m_aweight; }
59 :
60 : private:
61 : uint8 m_astretch;
62 : uint8 m_ashrink;
63 : uint8 m_astep;
64 : uint8 m_aweight;
65 : };
66 :
67 : class Silf
68 : {
69 : // Prevent copying
70 : Silf(const Silf&);
71 : Silf& operator=(const Silf&);
72 :
73 : public:
74 : Silf() throw();
75 : ~Silf() throw();
76 :
77 : bool readGraphite(const byte * const pSilf, size_t lSilf, Face &face, uint32 version);
78 : bool runGraphite(Segment *seg, uint8 firstPass=0, uint8 lastPass=0, int dobidi = 0) const;
79 : uint16 findClassIndex(uint16 cid, uint16 gid) const;
80 : uint16 getClassGlyph(uint16 cid, unsigned int index) const;
81 : uint16 findPseudo(uint32 uid) const;
82 0 : uint8 numUser() const { return m_aUser; }
83 0 : uint8 aPseudo() const { return m_aPseudo; }
84 0 : uint8 aBreak() const { return m_aBreak; }
85 0 : uint8 aMirror() const {return m_aMirror; }
86 0 : uint8 aPassBits() const { return m_aPassBits; }
87 0 : uint8 aBidi() const { return m_aBidi; }
88 0 : uint8 aCollision() const { return m_aCollision; }
89 : uint8 substitutionPass() const { return m_sPass; }
90 0 : uint8 positionPass() const { return m_pPass; }
91 0 : uint8 justificationPass() const { return m_jPass; }
92 0 : uint8 bidiPass() const { return m_bPass; }
93 0 : uint8 numPasses() const { return m_numPasses; }
94 : uint8 maxCompPerLig() const { return m_iMaxComp; }
95 0 : uint16 numClasses() const { return m_nClass; }
96 0 : byte flags() const { return m_flags; }
97 0 : byte dir() const { return m_dir; }
98 0 : uint8 numJustLevels() const { return m_numJusts; }
99 0 : Justinfo *justAttrs() const { return m_justs; }
100 0 : uint16 endLineGlyphid() const { return m_gEndLine; }
101 0 : const gr_faceinfo *silfInfo() const { return &m_silfinfo; }
102 :
103 0 : CLASS_NEW_DELETE;
104 :
105 : private:
106 : size_t readClassMap(const byte *p, size_t data_len, uint32 version, Error &e);
107 : template<typename T> inline uint32 readClassOffsets(const byte *&p, size_t data_len, Error &e);
108 :
109 : Pass * m_passes;
110 : Pseudo * m_pseudos;
111 : uint32 * m_classOffsets;
112 : uint16 * m_classData;
113 : Justinfo * m_justs;
114 : uint8 m_numPasses;
115 : uint8 m_numJusts;
116 : uint8 m_sPass, m_pPass, m_jPass, m_bPass,
117 : m_flags, m_dir;
118 :
119 : uint8 m_aPseudo, m_aBreak, m_aUser, m_aBidi, m_aMirror, m_aPassBits,
120 : m_iMaxComp, m_aCollision;
121 : uint16 m_aLig, m_numPseudo, m_nClass, m_nLinear,
122 : m_gEndLine;
123 : gr_faceinfo m_silfinfo;
124 :
125 : void releaseBuffers() throw();
126 : };
127 :
128 : } // namespace graphite2
|