[HarfBuzz] harfbuzz: Branch 'master' - 2 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Dec 7 01:44:21 PST 2015


 src/hb-ot-shape-complex-arabic.cc |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit dee0fbf9e2eac8b61730efc4978bc10c552b5227
Merge: 255df68 a7ffe35
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Dec 7 10:44:08 2015 +0100

    Merge pull request #192 from behdad/jfkthame-stch
    
    [issue 191] Make apply_stch() give a more precise fit

commit a7ffe3535836032dba5559080dffeec79473197b
Author: jfkthame <jfkthame at gmail.com>
Date:   Sat Dec 5 17:47:37 2015 +0000

    Make apply_stch() give a more precise fit
    
    This aims to make Syriac Abbr Mark sizing more accurate when repeating segments are used, by adding an extra repeat and tightening up the spacing slightly rather than leaving a shortfall corresponding to a partial repeat-width.

diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index 5075477..6d9d093 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -542,7 +542,18 @@ apply_stch (const hb_ot_shape_plan_t *plan,
 
       hb_position_t w_remaining = w_total - w_fixed - overlap;
       if (sign * w_remaining > sign * w_repeating && sign * w_repeating > 0)
-	n_copies = (sign * w_remaining + sign * w_repeating / 4) / (sign * w_repeating) - 1;
+	n_copies = (sign * w_remaining) / (sign * w_repeating) - 1;
+
+      /* See if we can improve the fit by adding an extra repeat and squeezing them together a bit. */
+      hb_position_t extra_repeat_overlap = 0;
+      hb_position_t shortfall = sign * w_remaining - sign * w_repeating * (n_copies + 1);
+      if (shortfall > 0)
+      {
+        ++n_copies;
+        hb_position_t excess = (n_copies + 1) * sign * w_repeating - sign * w_remaining;
+        if (excess > 0)
+          extra_repeat_overlap = excess / (n_copies * n_repeating);
+      }
 
       if (step == MEASURE)
       {
@@ -568,6 +579,8 @@ apply_stch (const hb_ot_shape_plan_t *plan,
 	  for (unsigned int n = 0; n < repeat; n++)
 	  {
 	    x_offset -= extents.width;
+	    if (n > 0)
+	      x_offset += extra_repeat_overlap;
 	    pos[k - 1].x_offset = x_offset;
 	    /* Append copy. */
 	    --j;


More information about the HarfBuzz mailing list