Flutter Engine
The Flutter Engine
Functions
getpostextpath.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPoint.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTextBlob.h"
#include "include/core/SkTypeface.h"
#include "include/private/base/SkTemplates.h"
#include "src/base/SkRandom.h"
#include "src/core/SkFontPriv.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"
#include <string.h>

Go to the source code of this file.

Functions

static void strokePath (SkCanvas *canvas, const SkPath &path)
 
 DEF_SIMPLE_GM (getpostextpath, canvas, 480, 780)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( getpostextpath  ,
canvas  ,
480  ,
780   
)

Definition at line 36 of file getpostextpath.cpp.

36 {
37 // explicitly add spaces, to test a prev. bug
38 const char* text = "Ham bur ge fons";
39 size_t len = strlen(text);
41
43 font.setSize(48);
44
46 paint.setAntiAlias(true);
47
48 canvas->translate(SkIntToScalar(10), SkIntToScalar(64));
49
50 canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 0, 0, font, paint);
52 strokePath(canvas, path);
53 path.reset();
54
56 const int count = atg.count();
59 font.getWidths(atg.glyphs(), count, &widths[0]);
60
61 SkRandom rand;
64 for (int i = 0; i < count; ++i) {
65 pos[i].set(x, y + rand.nextSScalar1() * 24);
66 x += widths[i];
67 }
68
69 canvas->translate(0, SkIntToScalar(64));
70
71 canvas->drawTextBlob(SkTextBlob::MakeFromPosText(text, len, &pos[0], font), 0, 0, paint);
73 strokePath(canvas, path);
74}
int count
Definition: FontMgrTest.cpp:50
SkPoint pos
@ kUTF8
uses bytes to represent UTF-8 or ASCII
#define SkIntToScalar(x)
Definition: SkScalar.h:57
const SkScalar widths[]
Definition: StrokerTest.cpp:39
Definition: SkFont.h:35
Definition: SkPath.h:59
SkScalar nextSScalar1()
Definition: SkRandom.h:113
static sk_sp< SkTextBlob > MakeFromPosText(const void *text, size_t byteLength, const SkPoint pos[], const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition: SkTextBlob.cpp:803
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
static void strokePath(SkCanvas *canvas, const SkPath &path)
std::u16string text
double y
double x
SkFont DefaultPortableFont()
void get_text_path(const SkFont &font, const void *text, size_t length, SkTextEncoding encoding, SkPath *dst, const SkPoint pos[])
Definition: ToolUtils.cpp:236
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
font
Font Metadata and Metrics.
void set(float x, float y)
Definition: SkPoint_impl.h:200

◆ strokePath()

static void strokePath ( SkCanvas canvas,
const SkPath path 
)
static

Definition at line 29 of file getpostextpath.cpp.

29 {
31 paint.setAntiAlias(true);
32 paint.setColor(SK_ColorRED);
34 canvas->drawPath(path, paint);
35}
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194