116 {
117 if (argc != 3) {
118 printf(
"Usage: %s <font.ttf> <name.png>",
argv[0]);
119 return 1;
120 }
121
123 if (!input.isValid()) {
124 printf(
"Cannot open input file %s\n",
argv[1]);
125 return 1;
126 }
130 if (!face) {
131 printf(
"input font %s was not parsable by Freetype\n",
argv[1]);
132 return 1;
133 }
134
137 printf(
"Cannot open output file %s\n",
argv[2]);
138 return 1;
139 }
140
141 auto fontCollection = sk_make_sp<skia::textlayout::FontCollection>();
143 fontCollection->setDefaultFontManager(one_mgr);
144
145 constexpr int width = 200;
150
152 paint.setAntiAlias(
true);
154
162
165 printf(
"Could not load unicode data\n");
166 return 1;
167 }
169 std::unique_ptr<ParagraphBuilder>
builder =
172
173 std::unique_ptr<skia::textlayout::Paragraph> paragraph =
builder->Build();
174 paragraph->layout(
width - 20);
175 paragraph->paint(canvas, 10, 10);
176
178 if (
surface->peekPixels(&pixmap)) {
180 printf(
"Cannot write output\n");
181 return 1;
182 }
183 } else {
184 printf(
"Cannot readback on surface\n");
185 return 1;
186 }
187
188 return 0;
189}
@ kOpaque_SkAlphaType
pixel is opaque
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Custom_Empty()
void clear(SkColor color)
static sk_sp< SkData > MakeFromStream(SkStream *, size_t size)
sk_sp< SkTypeface > makeFromData(sk_sp< SkData >, int ttcIndex=0) const
void setFontFamilies(std::vector< SkString > families)
void setFontSize(SkScalar size)
void setForegroundColor(SkPaint paint)
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SKUNICODE_API sk_sp< SkUnicode > Make()
static void make(SkBitmap *bitmap, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace)
constexpr const char * story
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
void setTextStyle(const TextStyle &textStyle)
void setTextAlign(TextAlign align)