w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

otfgpos.hh
Go to the documentation of this file.
1 // -*- related-file-name: "../../libefont/otfgpos.cc" -*-
2 #ifndef EFONT_OTFGPOS_HH
3 #define EFONT_OTFGPOS_HH
4 #include <efont/otf.hh>
5 #include <efont/otfdata.hh>
6 namespace Efont { namespace OpenType {
7 class GposLookup;
8 class Positioning;
9 
10 class Gpos { public:
11 
12  Gpos(const Data &, ErrorHandler * = 0);
13  // default destructor
14 
15  const ScriptList &script_list() const { return _script_list; }
16  const FeatureList &feature_list() const { return _feature_list; }
17 
18  int nlookups() const;
19  GposLookup lookup(unsigned) const;
20 
21  enum { HEADERSIZE = 10 };
22 
23  private:
24 
28 
29 };
30 
31 class GposLookup { public:
32  GposLookup(const Data &);
33  int type() const { return _type; }
34  uint16_t flags() const { return _d.u16(2); }
36  enum {
37  HEADERSIZE = 6, RECSIZE = 2,
38  L_SINGLE = 1, L_PAIR = 2, L_CURSIVE = 3, L_MARKTOBASE = 4,
41  };
42  private:
44  int _type;
45  Data subtable(int i) const;
46 };
47 
48 class GposValue { public:
49  static inline int size(uint16_t format);
50  static inline int16_t xplacement(uint16_t format, const Data &);
51  static inline int16_t yplacement(uint16_t format, const Data &);
52  static inline int16_t xadvance(uint16_t format, const Data &);
53  static inline int16_t yadvance(uint16_t format, const Data &);
54  enum {
55  F_XPLACEMENT = 0x0001,
56  F_YPLACEMENT = 0x0002,
57  F_XADVANCE = 0x0004,
58  F_YADVANCE = 0x0008,
62  F_YADVANCE_DEVICE = 0x0080
63  };
64  private:
65  static const int nibble_bitcount_x2[];
66 };
67 
68 class GposSingle { public:
69  GposSingle(const Data &);
70  // default destructor
71  Coverage coverage() const noexcept;
72  void unparse(Vector<Positioning> &) const;
73  enum { F2_HEADERSIZE = 8 };
74  private:
76 };
77 
78 class GposPair { public:
79  GposPair(const Data &);
80  // default destructor
81  Coverage coverage() const noexcept;
82  void unparse(Vector<Positioning> &) const;
83  enum { F1_HEADERSIZE = 10, F1_RECSIZE = 2,
85  F2_HEADERSIZE = 16 };
86  private:
88 };
89 
90 struct Position {
92  int pdx, pdy; // placement
93  int adx, ady; // advance
94  inline Position();
95  inline Position(Glyph, uint16_t format, const Data &);
96  inline Position(uint16_t format, const Data &);
97  inline Position(Glyph, const Position &);
98  inline Position(Glyph g, int pdx, int pdy, int adx, int ady);
99  bool empty() const { return pdx == 0 && pdy == 0 && adx == 0 && ady == 0; }
100  operator bool() const { return !empty(); }
101  bool h_empty() const { return pdx == 0 && pdy == 0 && adx == 0; }
102  bool placed() const { return pdx != 0 || pdy != 0; }
103  void unparse(StringAccum &, const Vector<PermString> * = 0) const;
104  String unparse(const Vector<PermString> * = 0) const;
105 };
106 
107 class Positioning { public:
108 
110 
111  // single positioning
112  inline Positioning(const Position &);
113 
114  // pair positioning
115  inline Positioning(const Position &, const Position &);
116 
117  bool context_in(const Coverage &) const;
118  bool context_in(const GlyphSet &) const;
119 
120  // types
121  inline operator bool() const;
122  inline bool is_single() const;
123  inline bool is_pair() const;
124  inline bool is_pairkern() const;
125 
126  // extract data
127  const Position &left() const { return _left; }
128  Glyph left_glyph() const { return _left.g; }
129  const Position &right() const { return _right; }
130  Glyph right_glyph() const { return _right.g; }
131  inline void all_in_glyphs(Vector<Glyph> &gs) const;
132 
133  void unparse(StringAccum &, const Vector<PermString> * = 0) const;
134  String unparse(const Vector<PermString> * = 0) const;
135 
136  private:
137 
140 
141 };
142 
144 {
145  return (nibble_bitcount_x2[format & 15] + nibble_bitcount_x2[(format>>4) & 15]);
146 }
147 
149 {
150  if (format & F_XPLACEMENT)
151  return d.s16(0);
152  else
153  return 0;
154 }
155 
157 {
158  if (format & F_YPLACEMENT)
159  return d.s16((format & F_XPLACEMENT ? 2 : 0));
160  else
161  return 0;
162 }
163 
165 {
166  if (format & F_XADVANCE)
167  return d.s16(nibble_bitcount_x2[format & (F_XADVANCE - 1)]);
168  else
169  return 0;
170 }
171 
173 {
174  if (format & F_YADVANCE)
175  return d.s16(nibble_bitcount_x2[format & (F_YADVANCE - 1)]);
176  else
177  return 0;
178 }
179 
181  : g(0)
182 {
183 }
184 
186  : g(g_),
187  pdx(GposValue::xplacement(format, value)), pdy(GposValue::yplacement(format, value)),
188  adx(GposValue::xadvance(format, value)), ady(GposValue::yadvance(format, value))
189 {
190 }
191 
193  : g(0),
194  pdx(GposValue::xplacement(format, value)), pdy(GposValue::yplacement(format, value)),
195  adx(GposValue::xadvance(format, value)), ady(GposValue::yadvance(format, value))
196 {
197 }
198 
199 inline Position::Position(Glyph g_, const Position &p)
200  : g(g_), pdx(p.pdx), pdy(p.pdy), adx(p.adx), ady(p.ady)
201 {
202 }
203 
204 inline Position::Position(Glyph g_, int pdx_, int pdy_, int adx_, int ady_)
205  : g(g_), pdx(pdx_), pdy(pdy_), adx(adx_), ady(ady_)
206 {
207 }
208 
210  : _left(left)
211 {
212 }
213 
215  : _left(left), _right(right)
216 {
217 }
218 
219 inline Positioning::operator bool() const
220 {
221  return _left.g != 0;
222 }
223 
224 inline bool Positioning::is_single() const
225 {
226  return _left.g != 0 && _right.g == 0;
227 }
228 
229 inline bool Positioning::is_pair() const
230 {
231  return _left.g != 0 && _right.g != 0;
232 }
233 
234 inline bool Positioning::is_pairkern() const
235 {
236  return _left.g != 0 && !_left.placed() && _right.g != 0 && _right.h_empty();
237 }
238 
240 {
241  gs.clear();
242  if (_left.g != 0)
243  gs.push_back(_left.g);
244  if (_right.g != 0)
245  gs.push_back(_right.g);
246 }
247 
248 }}
249 #endif
#define bool
Definition: autosp.c:101
static uint16_t u16(const unsigned char *s)
Definition: otfdata.hh:116
uint16_t flags() const
Definition: otfgpos.hh:34
Data subtable(int i) const
Definition: otfgpos.cc:97
bool unparse_automatics(Vector< Positioning > &, ErrorHandler *=0) const
Definition: otfgpos.cc:109
GposLookup(const Data &)
Definition: otfgpos.cc:82
GposPair(const Data &)
Definition: otfgpos.cc:186
Coverage coverage() const noexcept
Definition: otfgpos.cc:199
void unparse(Vector< Positioning > &) const
Definition: otfgpos.cc:205
GposSingle(const Data &)
Definition: otfgpos.cc:146
void unparse(Vector< Positioning > &) const
Definition: otfgpos.cc:165
Coverage coverage() const noexcept
Definition: otfgpos.cc:159
static int16_t xadvance(uint16_t format, const Data &)
Definition: otfgpos.hh:164
static int size(uint16_t format)
Definition: otfgpos.hh:143
static int16_t xplacement(uint16_t format, const Data &)
Definition: otfgpos.hh:148
static int16_t yplacement(uint16_t format, const Data &)
Definition: otfgpos.hh:156
static int16_t yadvance(uint16_t format, const Data &)
Definition: otfgpos.hh:172
static const int nibble_bitcount_x2[]
Definition: otfgpos.hh:65
const ScriptList & script_list() const
Definition: otfgpos.hh:15
Gpos(const Data &, ErrorHandler *=0)
Definition: otfgpos.cc:35
FeatureList _feature_list
Definition: otfgpos.hh:26
GposLookup lookup(unsigned) const
Definition: otfgpos.cc:59
int nlookups() const
Definition: otfgpos.cc:53
const FeatureList & feature_list() const
Definition: otfgpos.hh:16
ScriptList _script_list
Definition: otfgpos.hh:25
void unparse(StringAccum &, const Vector< PermString > *=0) const
Definition: otfgpos.cc:294
bool context_in(const Coverage &) const
Definition: otfgpos.cc:282
void all_in_glyphs(Vector< Glyph > &gs) const
Definition: otfgpos.hh:239
Glyph left_glyph() const
Definition: otfgpos.hh:128
const Position & left() const
Definition: otfgpos.hh:127
Glyph right_glyph() const
Definition: otfgpos.hh:130
const Position & right() const
Definition: otfgpos.hh:129
Error reporting class.
Definition: error.hh:86
Efficiently build up Strings from pieces.
Definition: straccum.hh:21
Definition: vector.hh:17
void clear()
Definition: vector.hh:87
void push_back(const T &x)
Definition: vector.hh:102
#define d(n)
Definition: gpos-common.c:151
small capitals from c petite p
Definition: afcover.h:72
small capitals from c petite p scientific i
Definition: afcover.h:80
@ right
Definition: annotate.c:15
signed short int16_t
Definition: stdint.h:76
unsigned short uint16_t
Definition: stdint.h:79
int Glyph
Definition: otf.hh:9
static int format
Definition: pbmclean.c:15
int g
Definition: ppmqvga.c:68
void unparse(StringAccum &, const Vector< PermString > *=0) const
Definition: otfgpos.cc:263
bool empty() const
Definition: otfgpos.hh:99
bool h_empty() const
Definition: otfgpos.hh:101
A string of characters.
Definition: t1part.c:49
Definition: obx.h:51