Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Unified Diff: gm/skbug_5321.cpp

Issue 2146403005: SkPDF: Always give a default advance for glyphs. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/skbug_5321.cpp
diff --git a/gm/skbug_5321.cpp b/gm/skbug_5321.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0e39a685b2eda0c7e178037b1db3f4f3c6d91265
--- /dev/null
+++ b/gm/skbug_5321.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+
+// https://bugs.skia.org/5321
+// two strings should draw the same. PDF did not.
+DEF_SIMPLE_GM(skbug_5321, canvas, 128, 128) {
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setTextSize(30);
+
+ paint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
+ const char text[] = "x\314\200y"; // utf8(u"x\u0300y")
+ SkScalar x = 20, y = 45;
+ size_t byteLength = strlen(text);
+ canvas->drawText(text, byteLength, x, y, paint);
+
+ int glyph_count = paint.countText(text, byteLength);
+ SkAutoTMalloc<SkScalar> widths(glyph_count);
+ (void)paint.getTextWidths(text, byteLength, &widths[0]);
+ for (int i = 0; i < glyph_count; ++i) {
+ SkScalar w = widths[i];
+ widths[i] = x;
+ x += w;
+ }
+ y += paint.getFontMetrics(nullptr);
+ canvas->drawPosTextH(text, byteLength, &widths[0], y, paint);
+}
« no previous file with comments | « no previous file | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698