Flutter Engine
The Flutter Engine
Functions
pdf_never_embed.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/SkScalar.h"
#include "include/core/SkString.h"
#include "include/core/SkTextBlob.h"
#include "include/core/SkTypeface.h"
#include "src/core/SkFontPriv.h"
#include "tools/Resources.h"
#include "tools/fonts/FontToolUtils.h"
#include <string.h>

Go to the source code of this file.

Functions

static void excercise_draw_pos_text (SkCanvas *canvas, const char *text, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
 
 DEF_SIMPLE_GM_CAN_FAIL (pdf_never_embed, canvas, errorMsg, 512, 512)
 
 DEF_SIMPLE_GM (pdf_crbug_772685, canvas, 612, 792)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( pdf_crbug_772685  ,
canvas  ,
612  ,
792   
)

Definition at line 73 of file pdf_never_embed.cpp.

73 {
74 canvas->clipRect({-1, -1, 613, 793}, false);
75 canvas->translate(-571, 0);
76 canvas->scale(0.75, 0.75);
77 canvas->clipRect({-1, -1, 613, 793}, false);
78 canvas->translate(0, -816);
79 canvas->drawRect({0, 0, 1224, 1500}, SkPaint());
80}

◆ DEF_SIMPLE_GM_CAN_FAIL()

DEF_SIMPLE_GM_CAN_FAIL ( pdf_never_embed  ,
canvas  ,
errorMsg  ,
512  ,
512   
)

Definition at line 37 of file pdf_never_embed.cpp.

37 {
38 SkPaint p;
39
41 ToolUtils::CreateTypefaceFromResource("fonts/Roboto2-Regular_NoEmbed.ttf");
42 if (!tf) {
44 }
45 SkASSERT(tf);
46 SkFont font(tf, 60);
47
48 const char text[] = "HELLO, WORLD!";
49
50 canvas->drawColor(SK_ColorWHITE);
51 excercise_draw_pos_text(canvas, text, 30, 90, font, p);
52
53 canvas->save();
54 canvas->rotate(45.0f);
55 p.setColor(0xF0800000);
56 excercise_draw_pos_text(canvas, text, 30, 45, font, p);
57 canvas->restore();
58
59 canvas->save();
60 canvas->scale(1, 4.0);
61 p.setColor(0xF0008000);
62 excercise_draw_pos_text(canvas, text, 15, 70, font, p);
63 canvas->restore();
64
65 canvas->scale(1.0, 0.5);
66 p.setColor(0xF0000080);
67 canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, 30, 700, font, p);
69}
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
@ kUTF8
uses bytes to represent UTF-8 or ASCII
Definition: SkFont.h:35
std::u16string text
sk_sp< SkTypeface > DefaultPortableTypeface()
sk_sp< SkTypeface > CreateTypefaceFromResource(const char *resource, int ttcIndex)
font
Font Metadata and Metrics.
static void excercise_draw_pos_text(SkCanvas *canvas, const char *text, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)

◆ excercise_draw_pos_text()

static void excercise_draw_pos_text ( SkCanvas canvas,
const char *  text,
SkScalar  x,
SkScalar  y,
const SkFont font,
const SkPaint paint 
)
static

Definition at line 24 of file pdf_never_embed.cpp.

28 {
29 const int count = font.countText(text, strlen(text), SkTextEncoding::kUTF8);
31 auto rec = builder.allocRunPos(font, count);
32 font.textToGlyphs(text, strlen(text), SkTextEncoding::kUTF8, rec.glyphs, count);
33 font.getPos(rec.glyphs, count, rec.points());
34 canvas->drawTextBlob(builder.make(), x, y, paint);
35}
int count
Definition: FontMgrTest.cpp:50
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
const Paint & paint
Definition: color_source.cc:38
double y
double x