if the y-max has neighbors (prev and next) with the same Y values, then the
cross will be 0, but we can still know the direction by looking at the change
in X
Fixes the hypen in #7 of this bug http://code.google.com/p/chromium/issues/detail?id=109370
git-svn-id: http://skia.googlecode.com/svn/trunk@3049 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/strokefill.cpp b/gm/strokefill.cpp
index a37af80..75fa008 100644
--- a/gm/strokefill.cpp
+++ b/gm/strokefill.cpp
@@ -27,24 +27,35 @@
return make_isize(640, 480);
}
+ static void show_bold(SkCanvas* canvas, const char text[], SkScalar x,
+ SkScalar y, const SkPaint& paint) {
+ size_t len = strlen(text);
+ SkPaint p(paint);
+ canvas->drawText(text, len, x, y, p);
+ p.setFakeBoldText(true);
+ canvas->drawText(text, len, x, y + SkIntToScalar(120), p);
+ }
+
virtual void onDraw(SkCanvas* canvas) {
+ SkScalar x = SkIntToScalar(100);
+ SkScalar y = SkIntToScalar(88);
+
SkPaint paint;
- const char text[] = "Hello"; // "Hello";
- const size_t len = sizeof(text) - 1;
paint.setAntiAlias(true);
paint.setTextSize(SkIntToScalar(100));
-// SkTypeface* hira = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro", SkTypeface::kNormal);
- SkTypeface* hira = SkTypeface::CreateFromName("Papyrus", SkTypeface::kNormal);
- paint.setTypeface(hira);
- SkScalar x = SkIntToScalar(180);
- SkScalar y = SkIntToScalar(88);
-
- canvas->drawText(text, len, x, y, paint);
- paint.setFakeBoldText(true);
- canvas->drawText(text, len, x, y + SkIntToScalar(100), paint);
- paint.setStyle(SkPaint::kStrokeAndFill_Style);
paint.setStrokeWidth(SkIntToScalar(5));
+ SkTypeface* face = SkTypeface::CreateFromName("Papyrus", SkTypeface::kNormal);
+ SkSafeUnref(paint.setTypeface(face));
+ show_bold(canvas, "Hello", x, y, paint);
+
+ face = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro", SkTypeface::kNormal);
+ SkSafeUnref(paint.setTypeface(face));
+ const char hyphen[] = { 0xE3, 0x83, 0xBC, 0 };
+ show_bold(canvas, hyphen, x + SkIntToScalar(300), y, paint);
+
+ paint.setStyle(SkPaint::kStrokeAndFill_Style);
+
SkPath path;
path.setFillType(SkPath::kWinding_FillType);
path.addCircle(x, y + SkIntToScalar(200), SkIntToScalar(50), SkPath::kCW_Direction);
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 11e0079..189caa5 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -2010,6 +2010,12 @@
int next = find_diff_pt(pts, index, n, 1);
SkASSERT(next != index);
cross = cross_prod(pts[prev], pts[index], pts[next]);
+ // if we get a zero, but the pts aren't on top of each other, then
+ // we can just look at the direction
+ if (0 == cross) {
+ // construct the subtract so we get the correct Direction below
+ cross = pts[index].fX - pts[next].fX;
+ }
}
if (cross) {
if (dir) {