2 * Copyright 2016 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkFont.h"
11 #include "include/core/SkFontTypes.h"
12 #include "include/core/SkPaint.h"
13 #include "include/core/SkScalar.h"
14 #include "include/core/SkTextBlob.h"
18 // https://bugs.skia.org/5321
19 // two strings should draw the same. PDF did not.
20 DEF_SIMPLE_GM(skbug_5321, canvas, 128, 128) {
22 font.setEdging(SkFont::Edging::kAlias);
25 const char text[] = "x\314\200y"; // utf8(u"x\u0300y")
26 SkScalar x = 20, y = 45;
28 size_t byteLength = strlen(text);
29 canvas->drawSimpleText(text, byteLength, SkTextEncoding::kUTF8, x, y, font, SkPaint());
31 y += font.getMetrics(nullptr);
32 int glyph_count = font.countText(text, byteLength, SkTextEncoding::kUTF8);
33 SkTextBlobBuilder builder;
35 auto rec = builder.allocRunPosH(font, glyph_count, y);
36 font.textToGlyphs(text, byteLength, SkTextEncoding::kUTF8, rec.glyphs, glyph_count);
38 font.getWidths(rec.glyphs, glyph_count, rec.pos);
39 for (int i = 0; i < glyph_count; ++i) {
40 SkScalar w = rec.pos[i];
45 canvas->drawTextBlob(builder.make(), 0, 0, SkPaint());