50 RunBuilderTest(
reporter, builder,
nullptr, 0,
nullptr, 0);
55 RunBuilderTest(
reporter, builder, set1, std::size(set1), set1, std::size(set1));
60 RunBuilderTest(
reporter, builder, set2, std::size(set2), set2, std::size(set2));
65 RunBuilderTest(
reporter, builder, set3, std::size(set3), set3, std::size(set3));
72 RunBuilderTest(
reporter, builder, set4, std::size(set4), set4, std::size(set4));
79 RunDef mergedSet5[] = {
83 RunBuilderTest(
reporter, builder, set5, std::size(set5), mergedSet5,
84 std::size(mergedSet5));
91 RunDef mergedSet6[] = {
94 RunBuilderTest(
reporter, builder, set6, std::size(set6), mergedSet6,
95 std::size(mergedSet6));
111 RunDef mergedSet7[] = {
122 RunBuilderTest(
reporter, builder, set7, std::size(set7), mergedSet7,
123 std::size(mergedSet7));
139 builder.allocRun(font, 16, 0, 0, &r1);
146 builder.allocRunPosH(font, 16, 0, &r1);
153 builder.allocRunPos(font, 16, &r1);
163 builder.allocRun(font, 16, 0, 0, &r1);
164 builder.allocRunPosH(font, 16, 0, &r2);
165 builder.allocRunPos(font, 16, &r3);
183 const char*
txt =
"BOOO";
184 const size_t txtLen = strlen(
txt);
201 font.setScaleX(4.2f);
203 font.setSkewX(0.42f);
206 font.setEmbolden(
true);
207 font.setLinearMetrics(
true);
208 font.setSubpixel(
true);
209 font.setEmbeddedBitmaps(
true);
210 font.setForceAutoHinting(
true);
250 const RunDef in[],
unsigned inCount,
251 const RunDef out[],
unsigned outCount) {
254 for (
unsigned i = 0; i < inCount; ++i) {
265 for (
unsigned i = 0; i < outCount; ++i) {
276 for (
unsigned k = 0; k < it.glyphCount(); ++k) {
294 const SkRect* bounds =
nullptr) {
299 for (
int i = 0; i <
count; ++i) {
306 for (
int i = 0; i <
count; ++i) {
313 for (
int i = 0; i <
count; ++i) {
320 SK_ABORT(
"unhandled positioning value");
337 const char text1[] =
"Foo";
338 const char text2[] =
"Bar";
345 memcpy(
run.glyphs,
glyphs.get(),
sizeof(uint16_t) * glyphCount);
346 memcpy(
run.utf8text, text2, strlen(text2));
347 for (
int i = 0; i < glyphCount; ++i) {
355 for (uint32_t i = 0; i < it.glyphCount(); ++i) {
362 for (uint32_t i = 0; i < it.glyphCount(); ++i) {
374 font.setSubpixel(
true);
376 font.setTypeface(tf);
395 return surf->makeImageSnapshot();
404 const size_t idx = array->
size();
412 if (
length !=
sizeof(
size_t)) {
420 std::memcpy(&idx, data,
sizeof(
size_t));
425 return (*array)[idx];
441 add_run(&builder,
"Hello", 10, 20,
nullptr);
442 add_run(&builder,
"World", 10, 40, tf);
443 return builder.make();
452 "Did not serialize exactly one non-empty font, instead %d", array.
size());
468 const char text[] =
"Hello";
485 add_run(&builder,
"Hello", 10, 20, tf);
486 add_run(&builder,
"World!", 10, 40, tf);
487 auto blob = builder.make();
490 { tf.
get(), 5,
nullptr },
491 { tf.
get(), 6,
nullptr },
496 for (
auto exp : expected) {
500 for (
int i = 0; i <
run.fGlyphCount; ++i) {
502 "Glyph Index %d is unexpectedly 0", i);
#define SkDEBUGFAIL(message)
#define SK_ABORT(message,...)
constexpr SkColor SK_ColorWHITE
@ kFull
modifies glyph outlines for maximum constrast
@ kUTF8
uses bytes to represent UTF-8 or ASCII
sk_sp< T > sk_ref_sp(T *obj)
#define SkScalarRoundToInt(x)
constexpr size_t SkToSizeT(S x)
constexpr int SkToInt(S x)
static constexpr bool SkToBool(const T &x)
constexpr uint32_t SkToU32(S x)
#define DEF_TEST(name, reporter)
#define REPORTER_ASSERT(r, cond,...)
static sk_sp< SkTypeface > DeserializeTypeface(const void *data, size_t length, void *ctx)
static sk_sp< SkImage > render(const SkTextBlob *blob)
static sk_sp< SkData > SerializeTypeface(SkTypeface *tf, void *ctx)
static void add_run(SkTextBlobBuilder *builder, const char text[], SkScalar x, SkScalar y, sk_sp< SkTypeface > tf)
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
static constexpr SkFontStyle BoldItalic()
static constexpr SkFontStyle Bold()
SkTypeface * getTypeface() const
SkFontHinting getHinting() const
bool isForceAutoHinting() const
bool isLinearMetrics() const
bool isEmbeddedBitmaps() const
SkScalar getScaleX() const
SkScalar getSkewX() const
@ kAntiAlias
may have transparent pixels on glyph edges
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
const RunBuffer & allocRunText(const SkFont &font, int count, SkScalar x, SkScalar y, int textByteCount, const SkRect *bounds=nullptr)
sk_sp< SkTextBlob > make()
@ kHorizontal_Positioning
const SkFont & font() const
const SkRect & bounds() const
static sk_sp< SkTextBlob > MakeFromPosText(const void *text, size_t byteLength, const SkPoint pos[], const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
static sk_sp< SkTextBlob > Deserialize(const void *data, size_t size, const SkDeserialProcs &procs)
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
static void TestPaintProps(skiatest::Reporter *reporter)
static void TestBounds(skiatest::Reporter *reporter)
static void TestBuilder(skiatest::Reporter *reporter)
static const uint8_t buffer[]
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
font
Font Metadata and Metrics.
SkDeserialTypefaceProc fTypefaceProc
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkPoint Make(float x, float y)
constexpr float left() const
constexpr float top() const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
constexpr float height() const
constexpr float width() const
SkSerialTypefaceProc fTypefaceProc
SkScalar * pos
storage for glyph positions in run
SkGlyphID * glyphs
storage for glyph indexes in run