Flutter Engine
The Flutter Engine
third_party
skia
tools
fonts
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
11
#include "
include/core/SkColor.h
"
12
#include "
include/core/SkFontStyle.h
"
13
#include "
include/core/SkRefCnt.h
"
14
#include "
include/core/SkString.h
"
15
#include "
include/core/SkTypeface.h
"
16
17
class
SkBitmap
;
18
class
SkImage
;
19
class
SkFont
;
20
class
SkFontMgr
;
21
22
namespace
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
*/
27
SkFont
DefaultPortableFont
();
28
29
sk_sp<SkTypeface>
DefaultPortableTypeface
();
30
31
/**
32
* Returns a platform-independent text renderer.
33
*/
34
sk_sp<SkTypeface>
CreatePortableTypeface
(
const
char
*
name
,
SkFontStyle
style);
35
36
/* Return a color emoji typeface with planets to scale if available. */
37
sk_sp<SkTypeface>
PlanetTypeface
();
38
39
enum class
EmojiFontFormat
{
40
Cbdt
,
41
Sbix
,
42
ColrV0
,
43
Test
,
44
Svg
45
};
46
47
struct
EmojiTestSample
{
48
sk_sp<SkTypeface>
typeface
=
nullptr
;
49
const
char
*
sampleText
=
""
;
50
};
51
52
/** Return a color emoji typeface if available. */
53
EmojiTestSample
EmojiSample
();
54
55
/** Return a color emoji typeface of a specific color font format if available. */
56
EmojiTestSample
EmojiSample
(
EmojiFontFormat
format
);
57
58
/** Return a string representation of the requeste format. Useful for suffixing test names. */
59
SkString
NameForFontFormat
(
EmojiFontFormat
format
);
60
61
/** A simple SkUserTypeface for testing. */
62
sk_sp<SkTypeface>
SampleUserTypeface
();
63
64
SkBitmap
CreateStringBitmap
(
int
w
,
int
h
,
SkColor
c,
int
x
,
int
y
,
int
textSize,
const
char
* str);
65
sk_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)
68
sk_sp<SkFontMgr>
TestFontMgr
();
69
70
// Must be called before the first call to TestFontMgr to have any effect.
71
void
UsePortableFontMgr
();
72
73
// Returns true if this platform is Windows and this binary is being configured to run
74
// with the GDI font manager.
75
bool
FontMgrIsGDI
();
76
77
// This returns the default SkTypeface returned by the TestFontMgr(). If there was no default
78
// Typeface, DefaultPortableTypeface() is returned instead.
79
sk_sp<SkTypeface>
DefaultTypeface
();
80
81
// Returns a Typeface matching the given criteria as returned by TestFontMgr(). This may be different
82
// on different platforms.
83
sk_sp<SkTypeface>
CreateTestTypeface
(
const
char
*
name
,
SkFontStyle
style);
84
85
// Load the resource with the provided name as a Typeface using TestFontMgr().
86
sk_sp<SkTypeface>
CreateTypefaceFromResource
(
const
char
*
resource
,
int
ttcIndex = 0);
87
88
// This returns a font using DefaultTypeface()
89
SkFont
DefaultFont
();
90
91
}
// namespace ToolUtils
92
93
#endif
SkColor.h
SkColor
uint32_t SkColor
Definition:
SkColor.h:37
SkFontStyle.h
resource
static SkString resource(SkPDFResourceType type, int index)
Definition:
SkPDFResourceDict.cpp:62
SkRefCnt.h
SkString.h
SkTypeface.h
SkBitmap
Definition:
SkBitmap.h:59
SkFontMgr
Definition:
SkFontMgr.h:36
SkFontStyle
Definition:
SkFontStyle.h:16
SkFont
Definition:
SkFont.h:35
SkImage
Definition:
SkImage.h:272
SkString
Definition:
SkString.h:118
sk_sp< SkTypeface >
format
uint32_t uint32_t * format
Definition:
fl_texture_registrar_test.cc:41
y
double y
Definition:
mouse-input-test.cc:83
x
double x
Definition:
mouse-input-test.cc:82
ToolUtils
Definition:
DecodeUtils.cpp:20
ToolUtils::DefaultPortableTypeface
sk_sp< SkTypeface > DefaultPortableTypeface()
Definition:
FontToolUtils.cpp:195
ToolUtils::DefaultPortableFont
SkFont DefaultPortableFont()
Definition:
FontToolUtils.cpp:202
ToolUtils::FontMgrIsGDI
bool FontMgrIsGDI()
Definition:
FontToolUtils.cpp:289
ToolUtils::UsePortableFontMgr
void UsePortableFontMgr()
Definition:
FontToolUtils.cpp:301
ToolUtils::NameForFontFormat
SkString NameForFontFormat(EmojiFontFormat format)
Definition:
FontToolUtils.cpp:133
ToolUtils::CreatePortableTypeface
sk_sp< SkTypeface > CreatePortableTypeface(const char *name, SkFontStyle style)
Definition:
FontToolUtils.cpp:187
ToolUtils::DefaultFont
SkFont DefaultFont()
Definition:
FontToolUtils.cpp:323
ToolUtils::CreateStringBitmap
SkBitmap CreateStringBitmap(int w, int h, SkColor c, int x, int y, int textSize, const char *str)
Definition:
FontToolUtils.cpp:206
ToolUtils::PlanetTypeface
sk_sp< SkTypeface > PlanetTypeface()
Definition:
FontToolUtils.cpp:73
ToolUtils::SampleUserTypeface
sk_sp< SkTypeface > SampleUserTypeface()
Definition:
FontToolUtils.cpp:149
ToolUtils::CreateTypefaceFromResource
sk_sp< SkTypeface > CreateTypefaceFromResource(const char *resource, int ttcIndex)
Definition:
FontToolUtils.cpp:317
ToolUtils::EmojiSample
EmojiTestSample EmojiSample()
Definition:
FontToolUtils.cpp:92
ToolUtils::DefaultTypeface
sk_sp< SkTypeface > DefaultTypeface()
Definition:
FontToolUtils.cpp:303
ToolUtils::CreateTestTypeface
sk_sp< SkTypeface > CreateTestTypeface(const char *name, SkFontStyle style)
Definition:
FontToolUtils.cpp:307
ToolUtils::CreateStringImage
sk_sp< SkImage > CreateStringImage(int w, int h, SkColor c, int x, int y, int textSize, const char *str)
Definition:
FontToolUtils.cpp:234
ToolUtils::EmojiFontFormat
EmojiFontFormat
Definition:
FontToolUtils.h:39
ToolUtils::EmojiFontFormat::Test
@ Test
ToolUtils::EmojiFontFormat::Svg
@ Svg
ToolUtils::EmojiFontFormat::Sbix
@ Sbix
ToolUtils::EmojiFontFormat::ColrV0
@ ColrV0
ToolUtils::EmojiFontFormat::Cbdt
@ Cbdt
ToolUtils::TestFontMgr
sk_sp< SkFontMgr > TestFontMgr()
Definition:
FontToolUtils.cpp:247
flutter::name
DEF_SWITCHES_START aot vmservice shared library name
Definition:
switches.h:32
w
SkScalar w
Definition:
pictureshadertile.cpp:30
h
SkScalar h
Definition:
pictureshadertile.cpp:30
ToolUtils::EmojiTestSample
Definition:
FontToolUtils.h:47
ToolUtils::EmojiTestSample::sampleText
const char * sampleText
Definition:
FontToolUtils.h:49
ToolUtils::EmojiTestSample::typeface
sk_sp< SkTypeface > typeface
Definition:
FontToolUtils.h:48
Generated on Sun Jun 23 2024 21:56:49 for Flutter Engine by
1.9.4