summaryrefslogtreecommitdiff
path: root/Build/source/libs/graphite2/graphite2-src/src/Collider.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/graphite2/graphite2-src/src/Collider.cpp')
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/Collider.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/Build/source/libs/graphite2/graphite2-src/src/Collider.cpp b/Build/source/libs/graphite2/graphite2-src/src/Collider.cpp
index 035bb9a3125..d82163aadc2 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/Collider.cpp
+++ b/Build/source/libs/graphite2/graphite2-src/src/Collider.cpp
@@ -306,7 +306,7 @@ bool ShiftCollider::mergeSlot(Segment *seg, Slot *slot, const SlotCollision *csl
float seq_above_wt = cslot->seqAboveWt();
float seq_below_wt = cslot->seqBelowWt();
float seq_valign_wt = cslot->seqValignWt();
- float lmargin = _margin;
+ float lmargin;
// if isAfter, invert orderFlags for diagonal orders.
if (isAfter)
{
@@ -558,6 +558,8 @@ bool ShiftCollider::mergeSlot(Segment *seg, Slot *slot, const SlotCollision *csl
{
// Set up the bogus slot representing the exclusion glyph.
Slot *exclSlot = seg->newSlot();
+ if (!exclSlot)
+ return res;
exclSlot->setGlyph(seg, cslot->exclGlyph());
Position exclOrigin(slot->origin() + cslot->exclOffset());
exclSlot->origin(exclOrigin);
@@ -805,6 +807,8 @@ static float get_edge(Segment *seg, const Slot *s, const Position &shift, float
{
const BBox &bb = gc.getBoundingBBox(gid);
const SlantBox &sb = gc.getBoundingSlantBox(gid);
+ if (sy + bb.yi - margin > y + width / 2 || sy + bb.ya + margin < y - width / 2)
+ return res;
float td = sx - sy + y;
float ts = sx + sy - y;
if (isRight)
@@ -924,7 +928,7 @@ bool KernCollider::initSlot(Segment *seg, Slot *aSlot, const Rect &limit, float
}
}
done:
- _mingap = (float)1e38;
+ _mingap = (float)1e37; // less than 1e38 s.t. 1e38-_mingap is really big
_target = aSlot;
_margin = margin;
_currShift = currShift;
@@ -945,7 +949,7 @@ bool KernCollider::mergeSlot(Segment *seg, Slot *slot, const Position &currShift
const float sx = slot->origin().x + currShift.x;
float x = (sx + (rtl > 0 ? bb.tr.x : bb.bl.x)) * rtl;
// this isn't going to reduce _mingap so skip
- if (x < rtl * (_xbound - _mingap - currSpace))
+ if (_hit && x < rtl * (_xbound - _mingap - currSpace))
return false;
const float sy = slot->origin().y + currShift.y;
@@ -954,19 +958,24 @@ bool KernCollider::mergeSlot(Segment *seg, Slot *slot, const Position &currShift
if (smin > smax)
return false;
bool collides = false;
+ bool nooverlap = true;
for (int i = smin; i <= smax; ++i)
{
- float t;
float here = _edges[i] * rtl;
- float y = (float)(_miny - 1 + (i + .5f) * _sliceWidth); // vertical center of slice
- if ( (x > here - _mingap - currSpace) )
+ if (here > (float)9e37)
+ continue;
+ if (!_hit || x > here - _mingap - currSpace)
{
+ float y = (float)(_miny - 1 + (i + .5f) * _sliceWidth); // vertical center of slice
// 2 * currSpace to account for the space that is already separating them and the space we want to add
float m = get_edge(seg, slot, currShift, y, _sliceWidth, 0., rtl > 0) * rtl + 2 * currSpace;
- t = here - m;
+ if (m < (float)-8e37) // only true if the glyph has a gap in it
+ continue;
+ nooverlap = false;
+ float t = here - m;
// _mingap is positive to shrink
- if (t < _mingap)
+ if (t < _mingap || (!_hit && !collides))
{
_mingap = t;
collides = true;
@@ -980,8 +989,14 @@ bool KernCollider::mergeSlot(Segment *seg, Slot *slot, const Position &currShift
}
#endif
}
+ else
+ nooverlap = false;
}
- return collides; // note that true is not a necessarily reliable value
+ if (nooverlap)
+ _mingap = max(_mingap, _xbound + currSpace + _margin - x);
+ if (collides && !nooverlap)
+ _hit = true;
+ return collides | nooverlap; // note that true is not a necessarily reliable value
} // end of KernCollider::mergeSlot