Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FontToolUtils.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef FontToolUtils_DEFINED
9#define FontToolUtils_DEFINED
10
16
17class SkBitmap;
18class SkImage;
19class SkFont;
20class SkFontMgr;
21
22namespace ToolUtils {
23/**
24 * Returns a font that has a non-empty typeface. This could change, so don't depend on things like
25 * how it looks, font metrics, etc.
26 */
28
30
31/**
32 * Returns a platform-independent text renderer.
33 */
35
36/* Return a color emoji typeface with planets to scale if available. */
38
39enum class EmojiFontFormat {
40 Cbdt,
41 Sbix,
42 ColrV0,
43 Test,
44 Svg
45};
46
49 const char* sampleText = "";
50};
51
52/** Return a color emoji typeface if available. */
54
55/** Return a color emoji typeface of a specific color font format if available. */
57
58/** Return a string representation of the requeste format. Useful for suffixing test names. */
60
61/** A simple SkUserTypeface for testing. */
63
64SkBitmap CreateStringBitmap(int w, int h, SkColor c, int x, int y, int textSize, const char* str);
65sk_sp<SkImage> CreateStringImage(int w, int h, SkColor c, int x, int y, int textSize, const char* str);
66
67// This returns the SkFontMgr that has been compiled in and configured (e.g. via CLI flag)
69
70// Must be called before the first call to TestFontMgr to have any effect.
72
73// Returns true if this platform is Windows and this binary is being configured to run
74// with the GDI font manager.
75bool FontMgrIsGDI();
76
77// This returns the default SkTypeface returned by the TestFontMgr(). If there was no default
78// Typeface, DefaultPortableTypeface() is returned instead.
80
81// Returns a Typeface matching the given criteria as returned by TestFontMgr(). This may be different
82// on different platforms.
84
85// Load the resource with the provided name as a Typeface using TestFontMgr().
86sk_sp<SkTypeface> CreateTypefaceFromResource(const char* resource, int ttcIndex = 0);
87
88// This returns a font using DefaultTypeface()
90
91} // namespace ToolUtils
92
93#endif
uint32_t SkColor
Definition SkColor.h:37
uint32_t uint32_t * format
const char * name
Definition fuchsia.cc:50
double y
double x
sk_sp< SkTypeface > DefaultPortableTypeface()
SkFont DefaultPortableFont()
bool FontMgrIsGDI()
void UsePortableFontMgr()
SkString NameForFontFormat(EmojiFontFormat format)
sk_sp< SkTypeface > CreatePortableTypeface(const char *name, SkFontStyle style)
SkFont DefaultFont()
SkBitmap CreateStringBitmap(int w, int h, SkColor c, int x, int y, int textSize, const char *str)
sk_sp< SkTypeface > PlanetTypeface()
sk_sp< SkTypeface > SampleUserTypeface()
sk_sp< SkTypeface > CreateTypefaceFromResource(const char *resource, int ttcIndex)
EmojiTestSample EmojiSample()
sk_sp< SkTypeface > DefaultTypeface()
sk_sp< SkTypeface > CreateTestTypeface(const char *name, SkFontStyle style)
sk_sp< SkImage > CreateStringImage(int w, int h, SkColor c, int x, int y, int textSize, const char *str)
sk_sp< SkFontMgr > TestFontMgr()
SkScalar w
SkScalar h
sk_sp< SkTypeface > typeface