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 "inc/Main.h"
30 :
31 : #include "inc/Pass.h"
32 :
33 : namespace graphite2 {
34 :
35 : class Face;
36 : class Segment;
37 : class FeatureVal;
38 : class VMScratch;
39 :
40 : class Pseudo
41 : {
42 : public:
43 : uint32 uid;
44 : uint32 gid;
45 0 : CLASS_NEW_DELETE
46 : };
47 :
48 : class Justinfo
49 : {
50 : public:
51 0 : Justinfo(uint8 stretch, uint8 shrink, uint8 step, uint8 weight) :
52 : m_astretch(stretch), m_ashrink(shrink), m_astep(step),
53 0 : m_aweight(weight) {};
54 : private:
55 : uint8 m_astretch;
56 : uint8 m_ashrink;
57 : uint8 m_astep;
58 : uint8 m_aweight;
59 : };
60 :
61 : class Silf
62 : {
63 : public:
64 : Silf() throw();
65 : ~Silf() throw();
66 :
67 : bool readGraphite(const void *pSilf, size_t lSilf, const Face &face, uint32 version);
68 : bool runGraphite(Segment *seg, uint8 firstPass=0, uint8 lastPass=0) const;
69 : uint16 findClassIndex(uint16 cid, uint16 gid) const;
70 : uint16 getClassGlyph(uint16 cid, unsigned int index) const;
71 : uint16 findPseudo(uint32 uid) const;
72 0 : uint8 numUser() const { return m_aUser; }
73 0 : uint8 aPseudo() const { return m_aPseudo; }
74 0 : uint8 aBreak() const { return m_aBreak; }
75 : uint8 aMirror() const {return m_aMirror; }
76 : uint8 substitutionPass() const { return m_sPass; }
77 : uint8 positionPass() const { return m_pPass; }
78 : uint8 justificationPass() const { return m_jPass; }
79 : uint8 bidiPass() const { return m_bPass; }
80 0 : uint8 numPasses() const { return m_numPasses; }
81 : uint8 maxCompPerLig() const { return m_iMaxComp; }
82 0 : uint16 numClasses() const { return m_nClass; }
83 :
84 0 : CLASS_NEW_DELETE
85 :
86 : private:
87 : size_t readClassMap(const byte *p, size_t data_len, uint32 version);
88 : template<typename T> inline uint32 readClassOffsets(const byte *&p, size_t data_len);
89 :
90 : Pass * m_passes;
91 : Pseudo * m_pseudos;
92 : uint32 * m_classOffsets;
93 : uint16 * m_classData;
94 : Justinfo * m_justs;
95 : uint8 m_numPasses;
96 : uint8 m_numJusts;
97 : uint8 m_sPass, m_pPass, m_jPass, m_bPass,
98 : m_flags;
99 :
100 : uint8 m_aPseudo, m_aBreak, m_aUser, m_aBidi, m_aMirror,
101 : m_iMaxComp;
102 : uint16 m_aLig,
103 : m_numPseudo,
104 : m_nClass,
105 : m_nLinear;
106 :
107 : void releaseBuffers() throw();
108 :
109 : Silf(const Silf&);
110 : Silf& operator=(const Silf&);
111 : };
112 :
113 : } // namespace graphite2
|