Coverage Report

Created: 2025-07-07 10:01

/work/workdir/UnpackedTarball/graphite/src/Slot.cpp
Line
Count
Source (jump to first uncovered line)
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
#include "inc/Segment.h"
28
#include "inc/Slot.h"
29
#include "inc/Silf.h"
30
#include "inc/CharInfo.h"
31
#include "inc/Rule.h"
32
#include "inc/Collider.h"
33
34
35
using namespace graphite2;
36
37
Slot::Slot(int16 *user_attrs) :
38
    m_next(NULL), m_prev(NULL),
39
0
    m_glyphid(0), m_realglyphid(0), m_original(0), m_before(0), m_after(0),
40
0
    m_index(0), m_parent(NULL), m_child(NULL), m_sibling(NULL),
41
0
    m_position(0, 0), m_shift(0, 0), m_advance(0, 0),
42
0
    m_attach(0, 0), m_with(0, 0), m_just(0.),
43
0
    m_flags(0), m_attLevel(0), m_bidiCls(-1), m_bidiLevel(0),
44
0
    m_userAttr(user_attrs), m_justs(NULL)
45
0
{
46
0
}
47
48
// take care, this does not copy any of the GrSlot pointer fields
49
void Slot::set(const Slot & orig, int charOffset, size_t sizeAttr, size_t justLevels, size_t numChars)
50
0
{
51
    // leave m_next and m_prev unchanged
52
0
    m_glyphid = orig.m_glyphid;
53
0
    m_realglyphid = orig.m_realglyphid;
54
0
    m_original = orig.m_original + charOffset;
55
0
    if (charOffset + int(orig.m_before) < 0)
56
0
        m_before = 0;
57
0
    else
58
0
        m_before = orig.m_before + charOffset;
59
0
    if (charOffset <= 0 && orig.m_after + charOffset >= numChars)
60
0
        m_after = int(numChars) - 1;
61
0
    else
62
0
        m_after = orig.m_after + charOffset;
63
0
    m_parent = NULL;
64
0
    m_child = NULL;
65
0
    m_sibling = NULL;
66
0
    m_position = orig.m_position;
67
0
    m_shift = orig.m_shift;
68
0
    m_advance = orig.m_advance;
69
0
    m_attach = orig.m_attach;
70
0
    m_with = orig.m_with;
71
0
    m_flags = orig.m_flags;
72
0
    m_attLevel = orig.m_attLevel;
73
0
    m_bidiCls = orig.m_bidiCls;
74
0
    m_bidiLevel = orig.m_bidiLevel;
75
0
    if (m_userAttr && orig.m_userAttr)
76
0
        memcpy(m_userAttr, orig.m_userAttr, sizeAttr * sizeof(*m_userAttr));
77
0
    if (m_justs && orig.m_justs)
78
0
        memcpy(m_justs, orig.m_justs, SlotJustify::size_of(justLevels));
79
0
}
80
81
void Slot::update(int /*numGrSlots*/, int numCharInfo, Position &relpos)
82
0
{
83
0
    m_before += numCharInfo;
84
0
    m_after += numCharInfo;
85
0
    m_position = m_position + relpos;
86
0
}
87
88
Position Slot::finalise(const Segment *seg, const Font *font, Position & base, Rect & bbox, uint8 attrLevel, float & clusterMin, bool rtl, bool isFinal, int depth)
89
0
{
90
0
    SlotCollision *coll = NULL;
91
0
    if (depth > 100 || (attrLevel && m_attLevel > attrLevel)) return Position(0, 0);
92
0
    float scale = font ? font->scale() : 1.0f;
93
0
    Position shift(m_shift.x * (rtl * -2 + 1) + m_just, m_shift.y);
94
0
    float tAdvance = m_advance.x + m_just;
95
0
    if (isFinal && (coll = seg->collisionInfo(this)))
96
0
    {
97
0
        const Position &collshift = coll->offset();
98
0
        if (!(coll->flags() & SlotCollision::COLL_KERN) || rtl)
99
0
            shift = shift + collshift;
100
0
    }
101
0
    const GlyphFace * glyphFace = seg->getFace()->glyphs().glyphSafe(glyph());
102
0
    if (font)
103
0
    {
104
0
        scale = font->scale();
105
0
        shift *= scale;
106
0
        if (font->isHinted() && glyphFace)
107
0
            tAdvance = (m_advance.x - glyphFace->theAdvance().x + m_just) * scale + font->advance(glyph());
108
0
        else
109
0
            tAdvance *= scale;
110
0
    }
111
0
    Position res;
112
113
0
    m_position = base + shift;
114
0
    if (!m_parent)
115
0
    {
116
0
        res = base + Position(tAdvance, m_advance.y * scale);
117
0
        clusterMin = m_position.x;
118
0
    }
119
0
    else
120
0
    {
121
0
        float tAdv;
122
0
        m_position += (m_attach - m_with) * scale;
123
0
        tAdv = m_advance.x >= 0.5f ? m_position.x + tAdvance - shift.x : 0.f;
124
0
        res = Position(tAdv, 0);
125
0
        if ((m_advance.x >= 0.5f || m_position.x < 0) && m_position.x < clusterMin) clusterMin = m_position.x;
126
0
    }
127
128
0
    if (glyphFace)
129
0
    {
130
0
        Rect ourBbox = glyphFace->theBBox() * scale + m_position;
131
0
        bbox = bbox.widen(ourBbox);
132
0
    }
133
134
0
    if (m_child && m_child != this && m_child->attachedTo() == this)
135
0
    {
136
0
        Position tRes = m_child->finalise(seg, font, m_position, bbox, attrLevel, clusterMin, rtl, isFinal, depth + 1);
137
0
        if ((!m_parent || m_advance.x >= 0.5f) && tRes.x > res.x) res = tRes;
138
0
    }
139
140
0
    if (m_parent && m_sibling && m_sibling != this && m_sibling->attachedTo() == m_parent)
141
0
    {
142
0
        Position tRes = m_sibling->finalise(seg, font, base, bbox, attrLevel, clusterMin, rtl, isFinal, depth + 1);
143
0
        if (tRes.x > res.x) res = tRes;
144
0
    }
145
146
0
    if (!m_parent && clusterMin < base.x)
147
0
    {
148
0
        Position adj = Position(m_position.x - clusterMin, 0.);
149
0
        res += adj;
150
0
        m_position += adj;
151
0
        if (m_child) m_child->floodShift(adj);
152
0
    }
153
0
    return res;
154
0
}
155
156
int32 Slot::clusterMetric(const Segment *seg, uint8 metric, uint8 attrLevel, bool rtl)
157
0
{
158
0
    Position base;
159
0
    if (glyph() >= seg->getFace()->glyphs().numGlyphs())
160
0
        return 0;
161
0
    Rect bbox = seg->theGlyphBBoxTemporary(glyph());
162
0
    float clusterMin = 0.;
163
0
    Position res = finalise(seg, NULL, base, bbox, attrLevel, clusterMin, rtl, false);
164
165
0
    switch (metrics(metric))
166
0
    {
167
0
    case kgmetLsb :
168
0
        return int32(bbox.bl.x);
169
0
    case kgmetRsb :
170
0
        return int32(res.x - bbox.tr.x);
171
0
    case kgmetBbTop :
172
0
        return int32(bbox.tr.y);
173
0
    case kgmetBbBottom :
174
0
        return int32(bbox.bl.y);
175
0
    case kgmetBbLeft :
176
0
        return int32(bbox.bl.x);
177
0
    case kgmetBbRight :
178
0
        return int32(bbox.tr.x);
179
0
    case kgmetBbWidth :
180
0
        return int32(bbox.tr.x - bbox.bl.x);
181
0
    case kgmetBbHeight :
182
0
        return int32(bbox.tr.y - bbox.bl.y);
183
0
    case kgmetAdvWidth :
184
0
        return int32(res.x);
185
0
    case kgmetAdvHeight :
186
0
        return int32(res.y);
187
0
    default :
188
0
        return 0;
189
0
    }
190
0
}
191
192
0
#define SLOTGETCOLATTR(x) { SlotCollision *c = seg->collisionInfo(this); return c ? int(c-> x) : 0; }
193
194
int Slot::getAttr(const Segment *seg, attrCode ind, uint8 subindex) const
195
0
{
196
0
    if (ind >= gr_slatJStretch && ind < gr_slatJStretch + 20 && ind != gr_slatJWidth)
197
0
    {
198
0
        int indx = ind - gr_slatJStretch;
199
0
        return getJustify(seg, indx / 5, indx % 5);
200
0
    }
201
202
0
    switch (ind)
203
0
    {
204
0
    case gr_slatAdvX :      return int(m_advance.x);
205
0
    case gr_slatAdvY :      return int(m_advance.y);
206
0
    case gr_slatAttTo :     return m_parent ? 1 : 0;
207
0
    case gr_slatAttX :      return int(m_attach.x);
208
0
    case gr_slatAttY :      return int(m_attach.y);
209
0
    case gr_slatAttXOff :
210
0
    case gr_slatAttYOff :   return 0;
211
0
    case gr_slatAttWithX :  return int(m_with.x);
212
0
    case gr_slatAttWithY :  return int(m_with.y);
213
0
    case gr_slatAttWithXOff:
214
0
    case gr_slatAttWithYOff:return 0;
215
0
    case gr_slatAttLevel :  return m_attLevel;
216
0
    case gr_slatBreak :     return seg->charinfo(m_original)->breakWeight();
217
0
    case gr_slatCompRef :   return 0;
218
0
    case gr_slatDir :       return seg->dir() & 1;
219
0
    case gr_slatInsert :    return isInsertBefore();
220
0
    case gr_slatPosX :      return int(m_position.x); // but need to calculate it
221
0
    case gr_slatPosY :      return int(m_position.y);
222
0
    case gr_slatShiftX :    return int(m_shift.x);
223
0
    case gr_slatShiftY :    return int(m_shift.y);
224
0
    case gr_slatMeasureSol: return -1; // err what's this?
225
0
    case gr_slatMeasureEol: return -1;
226
0
    case gr_slatJWidth:     return int(m_just);
227
0
    case gr_slatUserDefnV1: subindex = 0; GR_FALLTHROUGH;
228
      // no break
229
0
    case gr_slatUserDefn :  return subindex < seg->numAttrs() ?  m_userAttr[subindex] : 0;
230
0
    case gr_slatSegSplit :  return seg->charinfo(m_original)->flags() & 3;
231
0
    case gr_slatBidiLevel:  return m_bidiLevel;
232
0
    case gr_slatColFlags :    { SlotCollision *c = seg->collisionInfo(this); return c ? c->flags() : 0; }
233
0
    case gr_slatColLimitblx:SLOTGETCOLATTR(limit().bl.x)
234
0
    case gr_slatColLimitbly:SLOTGETCOLATTR(limit().bl.y)
235
0
    case gr_slatColLimittrx:SLOTGETCOLATTR(limit().tr.x)
236
0
    case gr_slatColLimittry:SLOTGETCOLATTR(limit().tr.y)
237
0
    case gr_slatColShiftx : SLOTGETCOLATTR(offset().x)
238
0
    case gr_slatColShifty : SLOTGETCOLATTR(offset().y)
239
0
    case gr_slatColMargin : SLOTGETCOLATTR(margin())
240
0
    case gr_slatColMarginWt:SLOTGETCOLATTR(marginWt())
241
0
    case gr_slatColExclGlyph:SLOTGETCOLATTR(exclGlyph())
242
0
    case gr_slatColExclOffx:SLOTGETCOLATTR(exclOffset().x)
243
0
    case gr_slatColExclOffy:SLOTGETCOLATTR(exclOffset().y)
244
0
    case gr_slatSeqClass :  SLOTGETCOLATTR(seqClass())
245
0
    case gr_slatSeqProxClass:SLOTGETCOLATTR(seqProxClass())
246
0
    case gr_slatSeqOrder :  SLOTGETCOLATTR(seqOrder())
247
0
    case gr_slatSeqAboveXoff:SLOTGETCOLATTR(seqAboveXoff())
248
0
    case gr_slatSeqAboveWt: SLOTGETCOLATTR(seqAboveWt())
249
0
    case gr_slatSeqBelowXlim:SLOTGETCOLATTR(seqBelowXlim())
250
0
    case gr_slatSeqBelowWt: SLOTGETCOLATTR(seqBelowWt())
251
0
    case gr_slatSeqValignHt:SLOTGETCOLATTR(seqValignHt())
252
0
    case gr_slatSeqValignWt:SLOTGETCOLATTR(seqValignWt())
253
0
    default : return 0;
254
0
    }
255
0
}
256
257
0
#define SLOTCOLSETATTR(x) { \
258
0
        SlotCollision *c = seg->collisionInfo(this); \
259
0
        if (c) { c-> x ; c->setFlags(c->flags() & ~SlotCollision::COLL_KNOWN); } \
260
0
        break; }
261
0
#define SLOTCOLSETCOMPLEXATTR(t, y, x) { \
262
0
        SlotCollision *c = seg->collisionInfo(this); \
263
0
        if (c) { \
264
0
        const t &s = c-> y; \
265
0
        c-> x ; c->setFlags(c->flags() & ~SlotCollision::COLL_KNOWN); } \
266
0
        break; }
267
268
void Slot::setAttr(Segment *seg, attrCode ind, uint8 subindex, int16 value, const SlotMap & map)
269
0
{
270
0
    if (ind == gr_slatUserDefnV1)
271
0
    {
272
0
        ind = gr_slatUserDefn;
273
0
        subindex = 0;
274
0
        if (seg->numAttrs() == 0)
275
0
            return;
276
0
    }
277
0
    else if (ind >= gr_slatJStretch && ind < gr_slatJStretch + 20 && ind != gr_slatJWidth)
278
0
    {
279
0
        int indx = ind - gr_slatJStretch;
280
0
        return setJustify(seg, indx / 5, indx % 5, value);
281
0
    }
282
283
0
    switch (ind)
284
0
    {
285
0
    case gr_slatAdvX :  m_advance.x = value; break;
286
0
    case gr_slatAdvY :  m_advance.y = value; break;
287
0
    case gr_slatAttTo :
288
0
    {
289
0
        const uint16 idx = uint16(value);
290
0
        if (idx < map.size() && map[idx])
291
0
        {
292
0
            Slot *other = map[idx];
293
0
            if (other == this || other == m_parent || other->isCopied()) break;
294
0
            if (m_parent) { m_parent->removeChild(this); attachTo(NULL); }
295
0
            Slot *pOther = other;
296
0
            int count = 0;
297
0
            bool foundOther = false;
298
0
            while (pOther)
299
0
            {
300
0
                ++count;
301
0
                if (pOther == this) foundOther = true;
302
0
                pOther = pOther->attachedTo();
303
0
            }
304
0
            for (pOther = m_child; pOther; pOther = pOther->m_child)
305
0
                ++count;
306
0
            for (pOther = m_sibling; pOther; pOther = pOther->m_sibling)
307
0
                ++count;
308
0
            if (count < 100 && !foundOther && other->child(this))
309
0
            {
310
0
                attachTo(other);
311
0
                if ((map.dir() != 0) ^ (idx > subindex))
312
0
                    m_with = Position(advance(), 0);
313
0
                else        // normal match to previous root
314
0
                    m_attach = Position(other->advance(), 0);
315
0
            }
316
0
        }
317
0
        break;
318
0
    }
319
0
    case gr_slatAttX :          m_attach.x = value; break;
320
0
    case gr_slatAttY :          m_attach.y = value; break;
321
0
    case gr_slatAttXOff :
322
0
    case gr_slatAttYOff :       break;
323
0
    case gr_slatAttWithX :      m_with.x = value; break;
324
0
    case gr_slatAttWithY :      m_with.y = value; break;
325
0
    case gr_slatAttWithXOff :
326
0
    case gr_slatAttWithYOff :   break;
327
0
    case gr_slatAttLevel :
328
0
        m_attLevel = byte(value);
329
0
        break;
330
0
    case gr_slatBreak :
331
0
        seg->charinfo(m_original)->breakWeight(value);
332
0
        break;
333
0
    case gr_slatCompRef :   break;      // not sure what to do here
334
0
    case gr_slatDir : break;
335
0
    case gr_slatInsert :
336
0
        markInsertBefore(value? true : false);
337
0
        break;
338
0
    case gr_slatPosX :      break; // can't set these here
339
0
    case gr_slatPosY :      break;
340
0
    case gr_slatShiftX :    m_shift.x = value; break;
341
0
    case gr_slatShiftY :    m_shift.y = value; break;
342
0
    case gr_slatMeasureSol :    break;
343
0
    case gr_slatMeasureEol :    break;
344
0
    case gr_slatJWidth :    just(value); break;
345
0
    case gr_slatSegSplit :  seg->charinfo(m_original)->addflags(value & 3); break;
346
0
    case gr_slatUserDefn :  m_userAttr[subindex] = value; break;
347
0
    case gr_slatColFlags :  {
348
0
        SlotCollision *c = seg->collisionInfo(this);
349
0
        if (c)
350
0
            c->setFlags(value);
351
0
        break; }
352
0
    case gr_slatColLimitblx : SLOTCOLSETCOMPLEXATTR(Rect, limit(), setLimit(Rect(Position(value, s.bl.y), s.tr)))
353
0
    case gr_slatColLimitbly : SLOTCOLSETCOMPLEXATTR(Rect, limit(), setLimit(Rect(Position(s.bl.x, value), s.tr)))
354
0
    case gr_slatColLimittrx : SLOTCOLSETCOMPLEXATTR(Rect, limit(), setLimit(Rect(s.bl, Position(value, s.tr.y))))
355
0
    case gr_slatColLimittry : SLOTCOLSETCOMPLEXATTR(Rect, limit(), setLimit(Rect(s.bl, Position(s.tr.x, value))))
356
0
    case gr_slatColMargin :   SLOTCOLSETATTR(setMargin(value))
357
0
    case gr_slatColMarginWt : SLOTCOLSETATTR(setMarginWt(value))
358
0
    case gr_slatColExclGlyph :  SLOTCOLSETATTR(setExclGlyph(value))
359
0
    case gr_slatColExclOffx : SLOTCOLSETCOMPLEXATTR(Position, exclOffset(), setExclOffset(Position(value, s.y)))
360
0
    case gr_slatColExclOffy : SLOTCOLSETCOMPLEXATTR(Position, exclOffset(), setExclOffset(Position(s.x, value)))
361
0
    case gr_slatSeqClass :    SLOTCOLSETATTR(setSeqClass(value))
362
0
  case gr_slatSeqProxClass :  SLOTCOLSETATTR(setSeqProxClass(value))
363
0
    case gr_slatSeqOrder :    SLOTCOLSETATTR(setSeqOrder(value))
364
0
    case gr_slatSeqAboveXoff :  SLOTCOLSETATTR(setSeqAboveXoff(value))
365
0
    case gr_slatSeqAboveWt :  SLOTCOLSETATTR(setSeqAboveWt(value))
366
0
    case gr_slatSeqBelowXlim :  SLOTCOLSETATTR(setSeqBelowXlim(value))
367
0
    case gr_slatSeqBelowWt :  SLOTCOLSETATTR(setSeqBelowWt(value))
368
0
    case gr_slatSeqValignHt : SLOTCOLSETATTR(setSeqValignHt(value))
369
0
    case gr_slatSeqValignWt : SLOTCOLSETATTR(setSeqValignWt(value))
370
0
    default :
371
0
        break;
372
0
    }
373
0
}
374
375
int Slot::getJustify(const Segment *seg, uint8 level, uint8 subindex) const
376
0
{
377
0
    if (level && level >= seg->silf()->numJustLevels()) return 0;
378
379
0
    if (m_justs)
380
0
        return m_justs->values[level * SlotJustify::NUMJUSTPARAMS + subindex];
381
382
0
    if (level >= seg->silf()->numJustLevels()) return 0;
383
0
    Justinfo *jAttrs = seg->silf()->justAttrs() + level;
384
385
0
    switch (subindex) {
386
0
        case 0 : return seg->glyphAttr(gid(), jAttrs->attrStretch());
387
0
        case 1 : return seg->glyphAttr(gid(), jAttrs->attrShrink());
388
0
        case 2 : return seg->glyphAttr(gid(), jAttrs->attrStep());
389
0
        case 3 : return seg->glyphAttr(gid(), jAttrs->attrWeight());
390
0
        case 4 : return 0;      // not been set yet, so clearly 0
391
0
        default: return 0;
392
0
    }
393
0
}
394
395
void Slot::setJustify(Segment *seg, uint8 level, uint8 subindex, int16 value)
396
0
{
397
0
    if (level && level >= seg->silf()->numJustLevels()) return;
398
0
    if (!m_justs)
399
0
    {
400
0
        SlotJustify *j = seg->newJustify();
401
0
        if (!j) return;
402
0
        j->LoadSlot(this, seg);
403
0
        m_justs = j;
404
0
    }
405
0
    m_justs->values[level * SlotJustify::NUMJUSTPARAMS + subindex] = value;
406
0
}
407
408
bool Slot::child(Slot *ap)
409
0
{
410
0
    if (this == ap) return false;
411
0
    else if (ap == m_child) return true;
412
0
    else if (!m_child)
413
0
        m_child = ap;
414
0
    else
415
0
        return m_child->sibling(ap);
416
0
    return true;
417
0
}
418
419
bool Slot::sibling(Slot *ap)
420
0
{
421
0
    if (this == ap) return false;
422
0
    else if (ap == m_sibling) return true;
423
0
    else if (!m_sibling || !ap)
424
0
        m_sibling = ap;
425
0
    else
426
0
        return m_sibling->sibling(ap);
427
0
    return true;
428
0
}
429
430
bool Slot::removeChild(Slot *ap)
431
0
{
432
0
    if (this == ap || !m_child || !ap) return false;
433
0
    else if (ap == m_child)
434
0
    {
435
0
        Slot *nSibling = m_child->nextSibling();
436
0
        m_child->nextSibling(NULL);
437
0
        m_child = nSibling;
438
0
        return true;
439
0
    }
440
0
    for (Slot *p = m_child; p; p = p->m_sibling)
441
0
    {
442
0
        if (p->m_sibling && p->m_sibling == ap)
443
0
        {
444
0
            p->m_sibling = p->m_sibling->m_sibling;
445
0
            ap->nextSibling(NULL);
446
0
            return true;
447
0
        }
448
0
    }
449
0
    return false;
450
0
}
451
452
void Slot::setGlyph(Segment *seg, uint16 glyphid, const GlyphFace * theGlyph)
453
0
{
454
0
    m_glyphid = glyphid;
455
0
    m_bidiCls = -1;
456
0
    if (!theGlyph)
457
0
    {
458
0
        theGlyph = seg->getFace()->glyphs().glyphSafe(glyphid);
459
0
        if (!theGlyph)
460
0
        {
461
0
            m_realglyphid = 0;
462
0
            m_advance = Position(0.,0.);
463
0
            return;
464
0
        }
465
0
    }
466
0
    m_realglyphid = theGlyph->attrs()[seg->silf()->aPseudo()];
467
0
    if (m_realglyphid > seg->getFace()->glyphs().numGlyphs())
468
0
        m_realglyphid = 0;
469
0
    const GlyphFace *aGlyph = theGlyph;
470
0
    if (m_realglyphid)
471
0
    {
472
0
        aGlyph = seg->getFace()->glyphs().glyphSafe(m_realglyphid);
473
0
        if (!aGlyph) aGlyph = theGlyph;
474
0
    }
475
0
    m_advance = Position(aGlyph->theAdvance().x, 0.);
476
0
    if (seg->silf()->aPassBits())
477
0
    {
478
0
        seg->mergePassBits(uint8(theGlyph->attrs()[seg->silf()->aPassBits()]));
479
0
        if (seg->silf()->numPasses() > 16)
480
0
            seg->mergePassBits(theGlyph->attrs()[seg->silf()->aPassBits()+1] << 16);
481
0
    }
482
0
}
483
484
void Slot::floodShift(Position adj, int depth)
485
0
{
486
0
    if (depth > 100)
487
0
        return;
488
0
    m_position += adj;
489
0
    if (m_child) m_child->floodShift(adj, depth + 1);
490
0
    if (m_sibling) m_sibling->floodShift(adj, depth + 1);
491
0
}
492
493
void SlotJustify::LoadSlot(const Slot *s, const Segment *seg)
494
0
{
495
0
    for (int i = seg->silf()->numJustLevels() - 1; i >= 0; --i)
496
0
    {
497
0
        Justinfo *justs = seg->silf()->justAttrs() + i;
498
0
        int16 *v = values + i * NUMJUSTPARAMS;
499
0
        v[0] = seg->glyphAttr(s->gid(), justs->attrStretch());
500
0
        v[1] = seg->glyphAttr(s->gid(), justs->attrShrink());
501
0
        v[2] = seg->glyphAttr(s->gid(), justs->attrStep());
502
0
        v[3] = seg->glyphAttr(s->gid(), justs->attrWeight());
503
0
    }
504
0
}
505
506
Slot * Slot::nextInCluster(const Slot *s) const
507
0
{
508
0
    Slot *base;
509
0
    if (s->firstChild())
510
0
        return s->firstChild();
511
0
    else if (s->nextSibling())
512
0
        return s->nextSibling();
513
0
    while ((base = s->attachedTo()))
514
0
    {
515
        // if (base->firstChild() == s && base->nextSibling())
516
0
        if (base->nextSibling())
517
0
            return base->nextSibling();
518
0
        s = base;
519
0
    }
520
0
    return NULL;
521
0
}
522
523
bool Slot::isChildOf(const Slot *base) const
524
0
{
525
0
    for (Slot *p = m_parent; p; p = p->m_parent)
526
0
        if (p == base)
527
0
            return true;
528
0
    return false;
529
0
}