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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9
10 // https://bugs.skia.org/5321
11 // two strings should draw the same. PDF did not.
12 DEF_SIMPLE_GM(skbug_5321, canvas, 128, 128) {
13 SkPaint paint;
14 paint.setStyle(SkPaint::kFill_Style);
15 paint.setTextSize(30);
16
17 paint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
18 const char text[] = "x\314\200y"; // utf8(u"x\u0300y")
19 SkScalar x = 20, y = 45;
20 size_t byteLength = strlen(text);
21 canvas->drawText(text, byteLength, x, y, paint);
22
23 int glyph_count = paint.countText(text, byteLength);
24 SkAutoTMalloc<SkScalar> widths(glyph_count);
25 (void)paint.getTextWidths(text, byteLength, &widths[0]);
26 for (int i = 0; i < glyph_count; ++i) {
27 SkScalar w = widths[i];
28 widths[i] = x;
29 x += w;
30 }
31 y += paint.getFontMetrics(nullptr);
32 canvas->drawPosTextH(text, byteLength, &widths[0], y, paint);
33 }
OLDNEW
« 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