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)  

Slot.h
Go to the documentation of this file.
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/Types.h"
30 #include "graphite2/Segment.h"
31 #include "inc/Main.h"
32 #include "inc/Font.h"
33 #include "inc/Position.h"
34 
35 namespace graphite2 {
36 
37 typedef gr_attrCode attrCode;
38 
39 class GlyphFace;
40 class Segment;
41 
42 struct SlotJustify
43 {
44  static const int NUMJUSTPARAMS = 5;
45 
48 
49 public:
50  static size_t size_of(size_t levels) { return sizeof(SlotJustify) + ((levels > 1 ? levels : 1)*NUMJUSTPARAMS - 1)*sizeof(int16); }
51 
52  void LoadSlot(const Slot *s, const Segment *seg);
53 
55  int16 values[1];
56 };
57 
58 class Slot
59 {
60  enum Flag
61  {
62  DELETED = 1,
63  INSERTED = 2,
64  COPIED = 4,
65  POSITIONED = 8,
66  ATTACHED = 16
67  };
68 
69 public:
70  struct iterator;
71 
72  unsigned short gid() const { return m_glyphid; }
73  Position origin() const { return m_position; }
74  float advance() const { return m_advance.x; }
76  Position advancePos() const { return m_advance; }
77  int before() const { return m_before; }
78  int after() const { return m_after; }
79  uint32 index() const { return m_index; }
80  void index(uint32 val) { m_index = val; }
81 
83  void set(const Slot & slot, int charOffset, size_t numUserAttr, size_t justLevels, size_t numChars);
84  Slot *next() const { return m_next; }
85  void next(Slot *s) { m_next = s; }
86  Slot *prev() const { return m_prev; }
87  void prev(Slot *s) { m_prev = s; }
89  void setGlyph(Segment *seg, uint16 glyphid, const GlyphFace * theGlyph = NULL);
90  void setRealGid(uint16 realGid) { m_realglyphid = realGid; }
92  void origin(const Position &pos) { m_position = pos + m_shift; }
93  void originate(int ind) { m_original = ind; }
94  int original() const { return m_original; }
95  void before(int ind) { m_before = ind; }
96  void after(int ind) { m_after = ind; }
97  bool isBase() const { return (!m_parent); }
98  void update(int numSlots, int numCharInfo, Position &relpos);
99  Position finalise(const Segment* seg, const Font* font, Position & base, Rect & bbox, uint8 attrLevel, float & clusterMin, bool rtl, bool isFinal, int depth = 0);
100  bool isDeleted() const { return (m_flags & DELETED) ? true : false; }
101  void markDeleted(bool state) { if (state) m_flags |= DELETED; else m_flags &= ~~DELETED; }
102  bool isCopied() const { return (m_flags & COPIED) ? true : false; }
103  void markCopied(bool state) { if (state) m_flags |= COPIED; else m_flags &= ~~COPIED; }
104  bool isPositioned() const { return (m_flags & POSITIONED) ? true : false; }
105  void markPositioned(bool state) { if (state) m_flags |= POSITIONED; else m_flags &= ~~POSITIONED; }
106  bool isInsertBefore() const { return !(m_flags & INSERTED); }
107  uint8 getBidiLevel() const { return m_bidiLevel; }
110  int8 getBidiClass() const { return m_bidiCls; }
111  void setBidiClass(int8 cls) { m_bidiCls = cls; }
112  int16 *userAttrs() const { return m_userAttr; }
113  void userAttrs(int16 *p) { m_userAttr = p; }
114  void markInsertBefore(bool state) { if (!state) m_flags |= INSERTED; else m_flags &= ~~INSERTED; }
115  void setAttr(Segment* seg, attrCode ind, uint8 subindex, int16 val, const SlotMap & map);
116  int getAttr(const Segment *seg, attrCode ind, uint8 subindex) const;
117  int getJustify(const Segment *seg, uint8 level, uint8 subindex) const;
119  bool isLocalJustify() const { return m_justs != NULL; };
120  void attachTo(Slot *ap) { m_parent = ap; }
121  Slot *attachedTo() const { return m_parent; }
122  Position attachOffset() const { return m_attach - m_with; }
123  Slot* firstChild() const { return m_child; }
124  void firstChild(Slot *ap) { m_child = ap; }
125  bool child(Slot *ap);
126  Slot* nextSibling() const { return m_sibling; }
128  bool sibling(Slot *ap);
130  int32 clusterMetric(const Segment* seg, uint8 metric, uint8 attrLevel, bool rtl);
132  void floodShift(Position adj, int depth = 0);
133  float just() const { return m_just; }
134  void just(float j) { m_just = j; }
135  Slot *nextInCluster(const Slot *s) const;
136  bool isChildOf(const Slot *base) const;
137 
139 
140 private:
141  Slot *m_next; // linked list of slots
142  Slot *m_prev;
143  unsigned short m_glyphid; // glyph id
145  uint32 m_original; // charinfo that originated this slot (e.g. for feature values)
146  uint32 m_before; // charinfo index of before association
147  uint32 m_after; // charinfo index of after association
148  uint32 m_index; // slot index given to this slot during finalising
149  Slot *m_parent; // index to parent we are attached to
150  Slot *m_child; // index to first child slot that attaches to us
151  Slot *m_sibling; // index to next child that attaches to our parent
152  Position m_position; // absolute position of glyph
153  Position m_shift; // .shift slot attribute
154  Position m_advance; // .advance slot attribute
155  Position m_attach; // attachment point on us
156  Position m_with; // attachment point position on parent
157  float m_just; // Justification inserted space
158  uint8 m_flags; // holds bit flags
159  byte m_attLevel; // attachment level
160  int8 m_bidiCls; // bidirectional class
161  byte m_bidiLevel; // bidirectional level
162  int16 *m_userAttr; // pointer to user attributes
163  SlotJustify *m_justs; // pointer to justification parameters
164 
165  friend class Segment;
166 };
167 
168 } // namespace graphite2
169 
170 struct gr_slot : public graphite2::Slot {};
int level
Definition: afm2pl.c:1694
#define depth(a)
Definition: aptex-macros.h:199
void floodShift(Position adj, int depth=0)
void markPositioned(bool state)
Definition: Slot.h:105
Slot * prev() const
Definition: Slot.h:86
int original() const
Definition: Slot.h:94
Position m_with
Definition: Slot.h:156
uint8 getBidiLevel() const
Definition: Slot.h:107
Slot * nextSibling() const
Definition: Slot.h:126
void adjKern(const Position &pos)
Definition: Slot.h:91
bool isChildOf(const Slot *base) const
bool isPositioned() const
Definition: Slot.h:104
bool child(Slot *ap)
void markDeleted(bool state)
Definition: Slot.h:101
bool isLocalJustify() const
Definition: Slot.h:119
unsigned short gid() const
Definition: Slot.h:72
uint32 m_after
Definition: Slot.h:147
uint8 m_flags
Definition: Slot.h:158
Slot * firstChild() const
Definition: Slot.h:123
bool isDeleted() const
Definition: Slot.h:100
void index(uint32 val)
Definition: Slot.h:80
void nextSibling(Slot *ap)
Definition: Slot.h:127
void just(float j)
Definition: Slot.h:134
int8 getBidiClass() const
Definition: Slot.h:110
Slot * m_sibling
Definition: Slot.h:151
int getAttr(const Segment *seg, attrCode ind, uint8 subindex) const
float advance() const
Definition: Slot.h:74
void next(Slot *s)
Definition: Slot.h:85
int32 clusterMetric(const Segment *seg, uint8 metric, uint8 attrLevel, bool rtl)
bool isInsertBefore() const
Definition: Slot.h:106
uint32 m_original
Definition: Slot.h:145
bool sibling(Slot *ap)
void setGlyph(Segment *seg, uint16 glyphid, const GlyphFace *theGlyph=NULL)
void setRealGid(uint16 realGid)
Definition: Slot.h:90
void positionShift(Position a)
Definition: Slot.h:131
Slot * next() const
Definition: Slot.h:84
unsigned short m_glyphid
Definition: Slot.h:143
int16 * m_userAttr
Definition: Slot.h:162
Position attachOffset() const
Definition: Slot.h:122
uint32 index() const
Definition: Slot.h:79
bool isBase() const
Definition: Slot.h:97
void originate(int ind)
Definition: Slot.h:93
uint16 glyph() const
Definition: Slot.h:88
void firstChild(Slot *ap)
Definition: Slot.h:124
int before() const
Definition: Slot.h:77
Position finalise(const Segment *seg, const Font *font, Position &base, Rect &bbox, uint8 attrLevel, float &clusterMin, bool rtl, bool isFinal, int depth=0)
Slot * m_prev
Definition: Slot.h:142
bool removeChild(Slot *ap)
Slot * m_parent
Definition: Slot.h:149
void origin(const Position &pos)
Definition: Slot.h:92
float m_just
Definition: Slot.h:157
Position advancePos() const
Definition: Slot.h:76
Slot * m_child
Definition: Slot.h:150
Position m_attach
Definition: Slot.h:155
int16 * userAttrs() const
Definition: Slot.h:112
int8 m_bidiCls
Definition: Slot.h:160
uint32 m_index
Definition: Slot.h:148
Position m_shift
Definition: Slot.h:153
void set(const Slot &slot, int charOffset, size_t numUserAttr, size_t justLevels, size_t numChars)
int after() const
Definition: Slot.h:78
Slot * attachedTo() const
Definition: Slot.h:121
Position m_advance
Definition: Slot.h:154
float just() const
Definition: Slot.h:133
void setJustify(Segment *seg, uint8 level, uint8 subindex, int16 value)
byte m_bidiLevel
Definition: Slot.h:161
bool isCopied() const
Definition: Slot.h:102
Position m_position
Definition: Slot.h:152
uint32 m_before
Definition: Slot.h:146
Slot * nextInCluster(const Slot *s) const
void advance(Position &val)
Definition: Slot.h:75
void update(int numSlots, int numCharInfo, Position &relpos)
void attachTo(Slot *ap)
Definition: Slot.h:120
byte m_attLevel
Definition: Slot.h:159
int getJustify(const Segment *seg, uint8 level, uint8 subindex) const
void after(int ind)
Definition: Slot.h:96
void setAttr(Segment *seg, attrCode ind, uint8 subindex, int16 val, const SlotMap &map)
SlotJustify * m_justs
Definition: Slot.h:163
uint16 m_realglyphid
Definition: Slot.h:144
void markCopied(bool state)
Definition: Slot.h:103
int8 getBidiClass(const Segment *seg)
void markInsertBefore(bool state)
Definition: Slot.h:114
void setBidiClass(int8 cls)
Definition: Slot.h:111
Slot(int16 *m_userAttr=NULL)
@ POSITIONED
Definition: Slot.h:65
void before(int ind)
Definition: Slot.h:95
Position origin() const
Definition: Slot.h:73
Slot * m_next
Definition: Slot.h:141
void userAttrs(int16 *p)
Definition: Slot.h:113
void prev(Slot *s)
Definition: Slot.h:87
void setBidiLevel(uint8 level)
Definition: Slot.h:108
#define ap
#define s
Definition: afcover.h:80
#define a(n)
Definition: gpos-common.c:148
int base
Definition: gsftopk.c:1502
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
#define true
Definition: ftrandom.c:51
const int * pos
Definition: combiners.h:905
char ind[999]
Definition: mkind.c:58
Definition: bits.h:30
gr_int16 int16
Definition: Main.h:43
gr_int8 int8
Definition: Main.h:42
gr_uint8 uint8
Definition: Main.h:38
gr_attrCode attrCode
Definition: Slot.h:37
gr_uint16 uint16
Definition: Main.h:40
gr_uint32 uint32
Definition: Main.h:41
gr_int32 int32
Definition: Main.h:44
gr_attrCode
Definition: Segment.h:63
#define map
#define CLASS_NEW_DELETE
Definition: Main.h:159
slotref slot
Definition: opcodes.h:237
Definition: nsfix.c:44
Definition: pbmfont.h:11
Definition: Slot.h:170
void LoadSlot(const Slot *s, const Segment *seg)
static size_t size_of(size_t levels)
Definition: Slot.h:50
static const int NUMJUSTPARAMS
Definition: Slot.h:44
SlotJustify * next
Definition: Slot.h:54
SlotJustify(const SlotJustify &)
int16 values[1]
Definition: Slot.h:55
SlotJustify & operator=(const SlotJustify &)
Definition: gd.c:2418
Definition: strexpr.c:21
int j
Definition: t4ht.c:1589
val
Definition: tex4ht.c:3227
Definition: obx.h:51