On 05/13/2011 09:01 PM, Алексей Подтележников wrote:
Why do you even create and calculate temporary shoot_delta?
You can explicitly increment/decrement blue->shoot.fit the same way
you do blue->ref.fit.
Like this:
+ AF_CJKBlue blue;
+
+ if ( delta_t>= delta_b )
+ {
+ blue =&axis->blues[AF_CJK_BLUE_TOP];
+ blue->ref.fit += 64;
+ blue->shoot.fit += 64;
+ }
+ else
+ {
+ blue =&axis->blues[AF_CJK_BLUE_BOTTOM];
+ blue->ref.fit -= 64;
+ blue->shoot -= 64;
+ }
Actually, there was an bug. My intention was to only update shoot.fit
value if it is the same with the ref.fit. Otherwise, if shoot and ref
don't merge, we don't know if shoot should be compensate.
But in the code, it's somehow messed up and simply always update the
shoot value.
It should be:
+ if (shoot_delta == 0)
+ blue->shoot.fit = blue->ref.fit;
As for the redundancy of the test on delta_sum <= 64, you are also
right. I remove that too in the updated patch.
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index 513b0c0..00009d2 100644
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -607,7 +607,7 @@
delta2 = FT_MulFix( delta2, scale );
FT_TRACE5(( "delta: %d", delta1 ));
- if ( delta2 < 32 )
+ if ( delta2 <= 32 )
delta2 = 0;
/*
else if ( delta2 < 64 )
@@ -632,6 +632,75 @@
blue->flags |= AF_CJK_BLUE_ACTIVE;
}
}
+
+ /* Compensate glyph height from top and bottom blue zone offsets. */
+ /* There are 4 states for the sum of top and bottom fit offset:
+ *
+ * 1. top + bottom >= 1.5 px Round to 2 px
+ *
+ * 2. top + bottom >= 1.0 px Round to 1 px
+ * Bad Result: 0.5 + 0.5 => 1 + 1 = 2px > 1px
+ *
+ * 3. top + bottom >= 0.5 px Round to 1 px
+ * Bad Result: 0.4 + 0.4 => 0 + 0 = 0px < 1px
+ *
+ * 4. top + bottom < 0.5 px Round to 0 px
+ *
+ * For the 2 bad result,
+ *
+ * 1st bad is OK, since we are OK with a pixel increase in size at small
+ * font size.
+ *
+ * 2nd bad is not OK. It shrink our already limited space by 1px at small
+ * fonr size. So we should compensate 1px in that situation.
+ */
+ {
+ FT_Pos delta_t, delta_b;
+ AF_CJKBlue blue_t, blue_b;
+
+ blue_t = &axis->blues[AF_CJK_BLUE_TOP];
+ blue_b = &axis->blues[AF_CJK_BLUE_BOTTOM];
+
+
+ delta_t = blue_t->ref.cur - blue_t->ref.fit;
+ delta_b = -( blue_b->ref.cur - blue_b->ref.fit );
+
+ FT_TRACE6(( "COMPEN: ref.cur: %li, ref.fit: %li, %li\n",
+ blue_t->ref.cur, blue_t->ref.fit, delta_t ));
+ FT_TRACE6(( "COMPEN: ref.cur: %li, ref.fit: %li, %li, sum: %li\n",
+ blue_b->ref.cur, blue_b->ref.fit, delta_b, delta_t + delta_b ));
+
+ if ( delta_t > 0 && delta_b > 0 && /* rounded to floor. */
+ ( delta_t + delta_b ) >= 32 &&
+ delta_t <= 32 && delta_b <= 32 )
+ {
+ FT_Pos shoot_delta;
+ AF_CJKBlue blue;
+
+ if ( delta_t >= delta_b )
+ {
+ blue = &axis->blues[AF_CJK_BLUE_TOP];
+ shoot_delta = blue->shoot.fit - blue->ref.fit;
+ blue->ref.fit += 64;
+ }
+ else
+ {
+ blue = &axis->blues[AF_CJK_BLUE_BOTTOM];
+ shoot_delta = blue->shoot.fit - blue->ref.fit;
+ blue->ref.fit -= 64;
+ }
+
+ if (shoot_delta == 0)
+ blue->shoot.fit = blue->ref.fit;
+
+ FT_TRACE5(( ">> compensated cjk blue zone %c%d[%ld/%ld]: "
+ "ref: cur=%.2f fit=%.2f shoot: cur=%.2f fit=%.2f\n",
+ ( dim == AF_DIMENSION_HORZ ) ? 'H':'V',
+ nn, blue->ref.org, blue->shoot.org,
+ blue->ref.cur/64.0, blue->ref.fit/64.0,
+ blue->shoot.cur/64.0, blue->shoot.fit/64.0 ));
+ }
+ }
}
_______________________________________________
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel