Coverage Report

Created: 2026-06-30 11:14

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