36 "The landing port at Titan had not changed much in five years.\n"
37 "The ship settled down on the scarred blast shield, beside the same trio "
38 "of squat square buildings, and quickly disgorged its scanty quota of "
39 "cargo and a lone passenger into the flexible tube that linked the loading "
40 "hatch with the main building.\n"
41 "As soon as the tube was disconnected, the ship screamed off through the "
42 "murky atmosphere, seemingly glad to get away from Titan and head back to "
43 "the more comfortable and settled parts of the Solar System.";
50 int count()
override {
return 1; }
69 *familyName =
SkString(
"the-only-font-I-have");
83 const char familyName[],
const SkFontStyle& style,
const char* bcp47[],
102 std::unique_ptr<SkStreamAsset>,
const SkFontArguments&)
const override {
118 printf(
"Usage: %s <font.ttf> <name.png>",
argv[0]);
124 printf(
"Cannot open input file %s\n",
argv[1]);
131 printf(
"input font %s was not parsable by Freetype\n",
argv[1]);
137 printf(
"Cannot open output file %s\n",
argv[2]);
141 auto fontCollection = sk_make_sp<skia::textlayout::FontCollection>();
143 fontCollection->setDefaultFontManager(one_mgr);
145 constexpr int width = 200;
152 paint.setAntiAlias(
true);
165 printf(
"Could not load unicode data\n");
169 std::unique_ptr<ParagraphBuilder>
builder =
173 std::unique_ptr<skia::textlayout::Paragraph> paragraph =
builder->Build();
174 paragraph->layout(
width - 20);
175 paragraph->paint(canvas, 10, 10);
178 if (
surface->peekPixels(&pixmap)) {
180 printf(
"Cannot write output\n");
184 printf(
"Cannot readback on surface\n");
@ kOpaque_SkAlphaType
pixel is opaque
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Custom_Empty()
sk_sp< T > sk_make_sp(Args &&... args)
sk_sp< SkTypeface > onMakeFromData(sk_sp< SkData >, int) const override
void onGetFamilyName(int index, SkString *familyName) const override
OneFontMgr(sk_sp< SkTypeface > face)
sk_sp< SkTypeface > onLegacyMakeTypeface(const char[], SkFontStyle) const override
sk_sp< SkFontStyleSet > onCreateStyleSet(int index) const override
sk_sp< SkFontStyleSet > onMatchFamily(const char[]) const override
sk_sp< SkTypeface > onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle &style, const char *bcp47[], int bcp47Count, SkUnichar character) const override
sk_sp< SkTypeface > onMatchFamilyStyle(const char[], const SkFontStyle &) const override
int onCountFamilies() const override
sk_sp< SkTypeface > onMakeFromStreamIndex(std::unique_ptr< SkStreamAsset >, int) const override
sk_sp< SkTypeface > onMakeFromFile(const char[], int) const override
sk_sp< SkTypeface > onMakeFromStreamArgs(std::unique_ptr< SkStreamAsset >, const SkFontArguments &) const override
OneFontStyleSet(sk_sp< SkTypeface > face)
sk_sp< SkTypeface > matchStyle(const SkFontStyle &) override
sk_sp< SkTypeface > createTypeface(int index) override
void getStyle(int, SkFontStyle *out_style, SkString *) override
void clear(SkColor color)
static sk_sp< SkData > MakeFromStream(SkStream *, size_t size)
size_t getLength() const override
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)
int main(int argc, char **argv)
constexpr const char * story
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
void setTextStyle(const TextStyle &textStyle)
void setTextAlign(TextAlign align)