summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMartin Hosken <martin_hosken@sil.org>2012-04-04 14:44:33 +0700
committerMartin Hosken <martin_hosken@sil.org>2012-04-04 14:44:33 +0700
commit9b6b1558a3654625ce9a5bef2bee5245db81ff88 (patch)
tree6b18398f39f0900fb5159554b2d66f6c3f5a02a7 /vcl
parentd3e518738973fdad6d5426f2a9318aa54e224a2c (diff)
Fix cursor movement in graphite fonts
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/graphite_layout.hxx4
-rw-r--r--vcl/source/glyphs/graphite_layout.cxx46
2 files changed, 27 insertions, 23 deletions
diff --git a/vcl/inc/graphite_layout.hxx b/vcl/inc/graphite_layout.hxx
index c6c711d94dc7..838c32d658e5 100644
--- a/vcl/inc/graphite_layout.hxx
+++ b/vcl/inc/graphite_layout.hxx
@@ -163,9 +163,9 @@ private:
void expandOrCondense(ImplLayoutArgs &rArgs);
void fillFrom(gr_segment * rSeg, ImplLayoutArgs & rArgs, float fScaling);
- void append(gr_segment * pSeg,
+ float append(gr_segment * pSeg,
ImplLayoutArgs & rArgs,
- const gr_slot * pSlot,
+ const gr_slot * pSlot, float gOrigin,
float nextGlyphOrigin, float fScaling,
long & rDXOffset, bool bIsBase, int baseChar);
};
diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx
index 93c1bc559857..4edeb9af731e 100644
--- a/vcl/source/glyphs/graphite_layout.cxx
+++ b/vcl/source/glyphs/graphite_layout.cxx
@@ -40,6 +40,8 @@
#undef NDEBUG
#endif
+// #define GRLAYOUT_DEBUG 1
+
// Header files
//
// Standard Library
@@ -274,7 +276,7 @@ GraphiteLayout::fillFrom(gr_segment * pSegment, ImplLayoutArgs &rArgs, float fSc
}
mvChar2BaseGlyph[mnSegCharOffset + nFirstCharInCluster - mnMinCharPos] = nBaseGlyphIndex;
}
- append(pSegment, rArgs, baseSlot, rightBoundary, fScaling,
+ append(pSegment, rArgs, baseSlot, gr_slot_origin_X(baseSlot), rightBoundary, fScaling,
nDxOffset, bCluster, mnSegCharOffset + firstChar);
}
if (mnSegCharOffset + nLastCharInCluster < mnMinCharPos)
@@ -353,7 +355,7 @@ GraphiteLayout::fillFrom(gr_segment * pSegment, ImplLayoutArgs &rArgs, float fSc
// only set mvChar2BaseGlyph for first character of cluster
mvChar2BaseGlyph[mnSegCharOffset + bFirstChar - mnMinCharPos] = nBaseGlyphIndex;
}
- append(pSegment, rArgs, baseSlot, rightBoundary, fScaling,
+ append(pSegment, rArgs, baseSlot, gr_slot_origin_X(baseSlot), rightBoundary, fScaling,
nDxOffset, true, mnSegCharOffset + firstChar);
}
if (mnSegCharOffset + bFirstChar >= mnEndCharPos)
@@ -409,13 +411,13 @@ GraphiteLayout::fillFrom(gr_segment * pSegment, ImplLayoutArgs &rArgs, float fSc
// append walks an attachment tree, flattening it, and converting it into a
// sequence of GlyphItem objects which we can later manipulate.
-void
+float
GraphiteLayout::append(gr_segment *pSeg, ImplLayoutArgs &rArgs,
- const gr_slot * gi, float nextGlyphOrigin, float scaling, long & rDXOffset,
+ const gr_slot * gi, float gOrigin, float nextGlyphOrigin, float scaling, long & rDXOffset,
bool bIsBase, int baseChar)
{
bool bRtl = (rArgs.mnFlags & SAL_LAYOUT_BIDI_RTL);
- float nextOrigin = nextGlyphOrigin;
+ float nextOrigin;
assert(gi);
assert(gr_slot_before(gi) <= gr_slot_after(gi));
int firstChar = gr_slot_before(gi) + mnSegCharOffset;
@@ -424,16 +426,22 @@ GraphiteLayout::append(gr_segment *pSeg, ImplLayoutArgs &rArgs,
// is the next glyph attached or in the next cluster?
//glyph_set_range_t iAttached = gi.attachedClusterGlyphs();
const gr_slot * pFirstAttached = gr_slot_first_attachment(gi);
+ const gr_slot * pNextSibling = gr_slot_next_sibling_attachment(gi);
if (pFirstAttached)
- {
nextOrigin = gr_slot_origin_X(pFirstAttached);
- }
+ else if (!bIsBase && pNextSibling)
+ nextOrigin = gr_slot_origin_X(pNextSibling);
+ else
+ nextOrigin = nextGlyphOrigin;
long glyphId = gr_slot_gid(gi);
long deltaOffset = 0;
int scaledGlyphPos = round(gr_slot_origin_X(gi) * scaling);
- int glyphWidth = round(nextOrigin * scaling) - scaledGlyphPos;
- if (glyphWidth < 0)
- glyphWidth = 0;
+ int glyphWidth = round((nextOrigin - gOrigin) * scaling);
+// if (glyphWidth < 0)
+// {
+// nextOrigin = gOrigin;
+// glyphWidth = 0;
+// }
#ifdef GRLAYOUT_DEBUG
fprintf(grLog(),"c%d g%ld,X%d W%d nX%f ", firstChar, glyphId,
(int)(gr_slot_origin_X(gi) * scaling), glyphWidth, nextOrigin * scaling);
@@ -481,16 +489,11 @@ GraphiteLayout::append(gr_segment *pSeg, ImplLayoutArgs &rArgs,
rDXOffset += deltaOffset;
// Recursively append all the attached glyphs.
- for (const gr_slot * agi = gr_slot_first_attachment(gi); agi != NULL;
- agi = gr_slot_next_sibling_attachment(agi))
- {
- if (gr_slot_next_sibling_attachment(agi) == NULL)
- append(pSeg, rArgs, agi, nextGlyphOrigin, scaling, rDXOffset,
- false, baseChar);
- else
- append(pSeg, rArgs, agi, gr_slot_origin_X(gr_slot_next_sibling_attachment(agi)),
- scaling, rDXOffset, false, baseChar);
- }
+ float cOrigin = nextOrigin;
+ for (const gr_slot * agi = gr_slot_first_attachment(gi); agi != NULL; agi = gr_slot_next_sibling_attachment(agi))
+ cOrigin = append(pSeg, rArgs, agi, cOrigin, nextGlyphOrigin, scaling, rDXOffset, false, baseChar);
+
+ return cOrigin;
}
//
@@ -600,7 +603,8 @@ gr_segment * GraphiteLayout::CreateSegment(ImplLayoutArgs& rArgs)
nSegCharLimit - rArgs.mnEndCharPos, bRtl);
}
}
- size_t numchars = gr_count_unicode_characters(gr_utf16, rArgs.mpStr + mnSegCharOffset, rArgs.mpStr + limit, NULL);
+ size_t numchars = gr_count_unicode_characters(gr_utf16, rArgs.mpStr + mnSegCharOffset,
+ rArgs.mpStr + (rArgs.mnLength > limit + 64 ? limit + 64 : rArgs.mnLength), NULL);
if (mpFeatures)
pSegment = gr_make_seg(mpFont, mpFace, 0, mpFeatures->values(), gr_utf16,
rArgs.mpStr + mnSegCharOffset, numchars, bRtl);