1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
diff -r 5369cdd12120 CMakeLists.txt
--- misc/build/graphite2-0.9.2/CMakeLists.txt Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/CMakeLists.txt Fri Feb 18 16:05:40 2011 +0700
@@ -61,7 +61,7 @@
add_subdirectory(gr2fonttest)
add_subdirectory(tests)
add_subdirectory(doc)
-set(version 0.0.0)
+set(version 2.0.0)
set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
diff -r 5369cdd12120 gr2fonttest/gr2FontTest.cpp
--- misc/build/graphite2-0.9.2/gr2fonttest/gr2FontTest.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/gr2fonttest/gr2FontTest.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -758,13 +758,11 @@
float advanceWidth = gr_seg_advance_X(pSeg);
fprintf(log, "Advance width = %6.1f\n", advanceWidth);
unsigned int numchar = gr_seg_n_cinfo(pSeg);
- gr_uint32 *firsts = (gr_uint32 *)malloc(numchar * sizeof(gr_uint32));
- gr_uint32 *lasts = (gr_uint32 *)malloc(numchar * sizeof(gr_uint32));
- gr_seg_char_slots(pSeg, firsts, lasts, 0, 0);
fprintf(log, "\nChar\tUnicode\tBefore\tAfter\n");
for (unsigned int j = 0; j < numchar; j++)
{
- fprintf(log, "%d\t%04X\t%d\t%d\n", j, gr_cinfo_unicode_char(gr_seg_cinfo(pSeg, j)), firsts[j], lasts[j]);
+ const gr_char_info *c = gr_seg_cinfo(pSeg, j);
+ fprintf(log, "%d\t%04X\t%d\t%d\n", j, gr_cinfo_unicode_char(c), gr_cinfo_before(c), gr_cinfo_after(c));
}
free(map);
gr_seg_destroy(pSeg);
diff -r 5369cdd12120 include/graphite2/Segment.h
--- misc/build/graphite2-0.9.2/include/graphite2/Segment.h Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/include/graphite2/Segment.h Fri Feb 18 16:05:40 2011 +0700
@@ -135,6 +135,20 @@
*/
GR2_API int gr_cinfo_break_weight(const gr_char_info* p/*not NULL*/);
+/** Returns the slot index that after this character is after in the slot stream
+ *
+ * @return after slot index between 0 and gr_seg_n_slots()
+ * @param p Pointer to charinfo to return information on.
+ */
+GR2_API int gr_cinfo_after(const gr_char_info* p/*not NULL*/);
+
+/** Returns the slot index that before this character is before in the slot stream
+ *
+ * @return before slot index between 0 and gr_seg_n_slots()
+ * @param p Pointer to charinfo to return information on.
+ */
+GR2_API int gr_cinfo_before(const gr_char_info* p/*not NULL*/);
+
/** Returns the number of unicode characters in a string.
*
* @return number of characters in the string
@@ -205,22 +219,6 @@
*/
GR2_API const gr_slot* gr_seg_last_slot(gr_segment* pSeg/*not NULL*/); //may give a base slot or a slot which is attached to another
-/** Calculates the underlying character to glyph associations.
- *
- * @param pSeg Pointer to the segment we want information on.
- * @param begins An array of gr_seg_n_cinfo integers giving slot index for each
- * charinfo. The value corresponds to which slot a cursor would be before
- * if an underlying cursor were before the charinfo at this index.
- * @param ends An array of gr_seg_n_cinfo integers giving the slot index for each
- * charinfo. The value at an index corresponds to which slot a cursor would
- * be after if an underlying cursor were after the charinfo at the index.
- * @param sbegins An array of gr_seg_n_cinfo gr_slot * corresponding to the gr_slot at
- * index given by begins. The pointer to the array may be NULL.
- * @param sends An array of gr_seg_n_cinfo gr_slot * corresponding to the gr_slot at the
- * index given by ends. The pointer to the array may be NULL.
- */
-GR2_API void gr_seg_char_slots(const gr_segment *pSeg, gr_uint32 *begins, gr_uint32 *ends, gr_slot **sbegins, gr_slot **sends);
-
/** Returns the next slot along in the segment.
*
* Slots are held in a linked list. This returns the next in the linked list. The slot
@@ -306,6 +304,13 @@
*/
GR2_API int gr_slot_after(const gr_slot* p/*not NULL*/);
+/** Returns the index of this slot in the segment
+ *
+ * Returns the index given to this slot during final positioning. This corresponds to the value returned br gr_cinfo_before()
+ * and gr_cinfo_after()
+ */
+GR2_API unsigned int gr_slot_index(const gr_slot* p/*not NULL*/);
+
/** Return a slot attribute value
*
* Given a slot and an attribute along with a possible subattribute, return the
diff -r 5369cdd12120 src/CMakeLists.txt
--- misc/build/graphite2-0.9.2/src/CMakeLists.txt Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/CMakeLists.txt Fri Feb 18 16:05:40 2011 +0700
@@ -25,7 +25,7 @@
INCLUDE(CheckTypeSize)
INCLUDE(CheckCXXSourceCompiles)
-set(GRAPHITE_API_MAJOR 1)
+set(GRAPHITE_API_MAJOR 2)
set(GRAPHITE_API_MINOR 0)
set(GRAPHITE_API_AGE 0)
set(GRAPHITE_SO_VERSION ${GRAPHITE_API_MAJOR}.${GRAPHITE_API_MINOR}.${GRAPHITE_API_AGE})
diff -r 5369cdd12120 src/CharInfo.h
--- misc/build/graphite2-0.9.2/src/CharInfo.h Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/CharInfo.h Fri Feb 18 16:05:40 2011 +0700
@@ -29,16 +29,23 @@
{
public:
+ CharInfo() : m_before(-1), m_after(0) {}
void init(int cid) { m_char = cid; }
unsigned int unicodeChar() const { return m_char; }
void feats(int offset) { m_featureid = offset; }
int fid() const { return m_featureid; }
int breakWeight() const { return m_break; }
void breakWeight(int val) { m_break = val; }
+ int after() const { return m_after; }
+ void after(int val) { m_after = val; }
+ int before() const { return m_before; }
+ void before(int val) { m_before = val; }
CLASS_NEW_DELETE
private:
int m_char; // Unicode character from character stream
+ int m_before; // slot index before us, comes before
+ int m_after; // slot index after us, comes after
uint8 m_featureid; // index into features list in the segment
int8 m_break; // breakweight coming from lb table
};
diff -r 5369cdd12120 src/Segment.cpp
--- misc/build/graphite2-0.9.2/src/Segment.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/Segment.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -283,6 +283,7 @@
{
Position currpos;
Slot *s, *ls = NULL;
+ int iSlot = 0;
float cMin = 0.;
float clusterMin = 0.;
Rect bbox;
@@ -292,8 +293,16 @@
if (m_dir & 1)
{
- for (s = iEnd; s && s != iStart->prev(); s = s->prev())
+ for (s = iEnd, iSlot = m_numGlyphs - 1; s && s != iStart->prev(); s = s->prev(), --iSlot)
{
+ for (int j = s->before(); j <= s->after(); j++)
+ {
+ CharInfo *c = charinfo(j);
+ if (c->before() == -1 || iSlot < c->before()) c->before(iSlot);
+ if (c->after() < iSlot) c->after(iSlot);
+ }
+ s->index(iSlot);
+
if (s->isBase())
{
clusterMin = currpos.x;
@@ -306,8 +315,16 @@
}
else
{
- for (s = iStart; s && s != iEnd->next(); s = s->next())
+ for (s = iStart, iSlot = 0; s && s != iEnd->next(); s = s->next(), ++iSlot)
{
+ for (int j = s->before(); j <= s->after(); j++)
+ {
+ CharInfo *c = charinfo(j);
+ if (c->before() == -1 || iSlot < c->before()) c->before(iSlot);
+ if (c->after() < iSlot) c->after(iSlot);
+ }
+ s->index(iSlot);
+
if (s->isBase())
{
clusterMin = currpos.x;
@@ -321,35 +338,6 @@
if (iStart == m_first && iEnd == m_last) m_advance = currpos;
}
-
-void Segment::getCharSlots(uint32 *begins, uint32 *ends, Slot **sbegins, Slot **sends) const
-{
- Slot *s;
- uint32 i;
- if (!begins || !ends) return;
- memset(begins, 0xFF, m_numCharinfo * sizeof(uint32));
- memset(ends, 0, m_numCharinfo * sizeof(uint32));
-
- for (s = m_first, i = 0; s; s = s->next(), i++)
- {
- for (int j = s->before(); j <= s->after(); j++)
- {
- assert(j >= 0);
- assert(j < static_cast<int>(m_numCharinfo));
- if (i < begins[j])
- {
- begins[j] = i;
- if (sbegins) sbegins[j] = s;
- }
- if (i > ends[j])
- {
- ends[j] = i;
- if (sends) sends[j] = s;
- }
- }
- }
-}
-
#ifndef DISABLE_TRACING
void Segment::logSegment(gr_encform enc, const void* pStart, size_t nChars) const
{
diff -r 5369cdd12120 src/Segment.h
--- misc/build/graphite2-0.9.2/src/Segment.h Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/Segment.h Fri Feb 18 16:05:40 2011 +0700
@@ -118,7 +118,6 @@
int defaultOriginal() const { return m_defaultOriginal; }
const Face * getFace() const { return m_face; }
const Features & getFeatures(unsigned int /*charIndex*/) { assert(m_feats.size() == 1); return m_feats[0]; }
- void getCharSlots(uint32 *begins, uint32 *ends, Slot **sbegins, Slot **sends) const;
CLASS_NEW_DELETE
diff -r 5369cdd12120 src/Slot.cpp
--- misc/build/graphite2-0.9.2/src/Slot.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/Slot.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -188,15 +188,15 @@
}
}
-int Slot::getAttr(const Segment *seg, attrCode index, uint8 subindex) const
+int Slot::getAttr(const Segment *seg, attrCode ind, uint8 subindex) const
{
if (!this) return 0;
- if (index == gr_slatUserDefnV1)
+ if (ind == gr_slatUserDefnV1)
{
- index = gr_slatUserDefn;
+ ind = gr_slatUserDefn;
subindex = 0;
}
- switch (index)
+ switch (ind)
{
case gr_slatAdvX :
return static_cast<int>(m_advance.x);
@@ -259,15 +259,15 @@
}
}
-void Slot::setAttr(Segment *seg, attrCode index, uint8 subindex, int16 value, const SlotMap & map)
+void Slot::setAttr(Segment *seg, attrCode ind, uint8 subindex, int16 value, const SlotMap & map)
{
if (!this) return;
- if (index == gr_slatUserDefnV1)
+ if (ind == gr_slatUserDefnV1)
{
- index = gr_slatUserDefn;
+ ind = gr_slatUserDefn;
subindex = 0;
}
- switch (index)
+ switch (ind)
{
case gr_slatAdvX :
m_advance = Position(value, m_advance.y);
diff -r 5369cdd12120 src/Slot.h
--- misc/build/graphite2-0.9.2/src/Slot.h Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/Slot.h Fri Feb 18 16:05:40 2011 +0700
@@ -47,6 +47,8 @@
Position advancePos() const { return m_advance; }
int before() const { return m_before; }
int after() const { return m_after; }
+ uint32 index() const { return m_index; }
+ void index(uint32 val) { m_index = val; }
Slot();
void set(const Slot & slot, int charOffset, uint8 numUserAttr);
@@ -58,10 +60,10 @@
void setGlyph(Segment *seg, uint16 glyphid, const GlyphFace * theGlyph = NULL);
void setRealGid(uint16 realGid) { m_realglyphid = realGid; }
void origin(const Position &pos) { m_position = pos + m_shift; }
- void originate(int index) { m_original = index; }
+ void originate(int ind) { m_original = ind; }
int original() const { return m_original; }
- void before(int index) { m_before = index; }
- void after(int index) { m_after = index; }
+ void before(int ind) { m_before = ind; }
+ void after(int ind) { m_after = ind; }
bool isBase() const { return (!m_parent); }
void update(int numSlots, int numCharInfo, Position &relpos);
Position finalise(const Segment* seg, const Font* font, Position* base, Rect* bbox, float* cMin, uint8 attrLevel, float *clusterMin);
@@ -75,8 +77,8 @@
uint16 *userAttrs() { return m_userAttr; }
void userAttrs(uint16 *p) { m_userAttr = p; }
void markInsertBefore(bool state) { if (!state) m_flags |= SLOT_INSERT; else m_flags &= ~SLOT_INSERT; }
- void setAttr(Segment* seg, attrCode index, uint8 subindex, int16 val, const SlotMap & map);
- int getAttr(const Segment *seg, attrCode index, uint8 subindex) const;
+ void setAttr(Segment* seg, attrCode ind, uint8 subindex, int16 val, const SlotMap & map);
+ int getAttr(const Segment *seg, attrCode ind, uint8 subindex) const;
void attachTo(Slot *ap) { m_parent = ap; }
Slot *attachedTo() const { return m_parent; }
Slot* firstChild() const { return m_child; }
@@ -96,8 +98,9 @@
unsigned short m_glyphid; // glyph id
uint16 m_realglyphid;
uint32 m_original; // charinfo that originated this slot (e.g. for feature values)
- uint32 m_before; // charinfo index of before association
- uint32 m_after; // charinfo index of after association
+ uint32 m_before; // charinfo index of before association
+ uint32 m_after; // charinfo index of after association
+ uint32 m_index; // slot index given to this slot during finalising
Slot *m_parent; // index to parent we are attached to
Slot *m_child; // index to first child slot that attaches to us
Slot *m_sibling; // index to next child that attaches to our parent
diff -r 5369cdd12120 src/gr_char_info.cpp
--- misc/build/graphite2-0.9.2/src/gr_char_info.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/gr_char_info.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -39,4 +39,16 @@
return p->breakWeight();
}
-} // extern "C"
\ No newline at end of file
+int gr_cinfo_after(const gr_char_info *p/*not NULL*/)
+{
+ assert(p);
+ return p->after();
+}
+
+int gr_cinfo_before(const gr_char_info *p/*not NULL*/)
+{
+ assert(p);
+ return p->before();
+}
+
+} // extern "C"
diff -r 5369cdd12120 src/gr_segment.cpp
--- misc/build/graphite2-0.9.2/src/gr_segment.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/gr_segment.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -162,11 +162,5 @@
return static_cast<const gr_slot*>(pSeg->last());
}
-void gr_seg_char_slots(const gr_segment *pSeg, gr_uint32 *begins, gr_uint32 *ends, gr_slot **sbegins, gr_slot **sends)
-{
- assert(pSeg && begins && ends);
- pSeg->getCharSlots(begins, ends, reinterpret_cast<Slot**>(sbegins), reinterpret_cast<Slot**>(sends));
-}
-
} // extern "C"
diff -r 5369cdd12120 src/gr_slot.cpp
--- misc/build/graphite2-0.9.2/src/gr_slot.cpp Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/gr_slot.cpp Fri Feb 18 16:05:40 2011 +0700
@@ -121,6 +121,12 @@
return p->after();
}
+unsigned int gr_slot_index(const gr_slot *p/*not NULL*/)
+{
+ assert(p);
+ return p->index();
+}
+
int gr_slot_attr(const gr_slot* p/*not NULL*/, const gr_segment* pSeg/*not NULL*/, gr_attrCode index, gr_uint8 subindex)
{
assert(p);
diff current src/List.h
--- misc/build/graphite2-0.9.2/src/List.h Sat Feb 12 22:54:16 2011 +0700
+++ misc/build/graphite2-0.9.2/src/List.h Fri Feb 18 16:05:40 2011 +0700
@@ -51,6 +51,6 @@
template <typename I>
Vector(I first, const I last) : m_first(0), m_last(0), m_end(0) { insert(begin(), first, last); }
- ~Vector() { free(m_first); }
+ ~Vector() { clear(); free(m_first); }
iterator begin() { return m_first; }
const_iterator begin() const { return m_first; }
|