Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
skbug_5321.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkPaint.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTextBlob.h"
#include "tools/fonts/FontToolUtils.h"
#include <string.h>

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (skbug_5321, canvas, 128, 128)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( skbug_5321  ,
canvas  ,
128  ,
128   
)

Definition at line 21 of file skbug_5321.cpp.

21 {
24 font.setSize(30);
25
26 const char text[] = "x\314\200y"; // utf8(u"x\u0300y")
27 SkScalar x = 20, y = 45;
28
29 size_t byteLength = strlen(text);
30 canvas->drawSimpleText(text, byteLength, SkTextEncoding::kUTF8, x, y, font, SkPaint());
31
32 y += font.getMetrics(nullptr);
33 int glyph_count = font.countText(text, byteLength, SkTextEncoding::kUTF8);
35
36 auto rec = builder.allocRunPosH(font, glyph_count, y);
37 font.textToGlyphs(text, byteLength, SkTextEncoding::kUTF8, rec.glyphs, glyph_count);
38
39 font.getWidths(rec.glyphs, glyph_count, rec.pos);
40 for (int i = 0; i < glyph_count; ++i) {
41 SkScalar w = rec.pos[i];
42 rec.pos[i] = x;
43 x += w;
44 }
45
46 canvas->drawTextBlob(builder.make(), 0, 0, SkPaint());
47}
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kAlias
no transparent pixels on glyph edges
float SkScalar
Definition extension.cpp:12
std::u16string text
double y
double x
SkFont DefaultPortableFont()
font
Font Metadata and Metrics.
SkScalar w