Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
include
utils
SkCustomTypeface.h
Go to the documentation of this file.
1
/*
2
* Copyright 2020 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 SkCustomTypeface_DEFINED
9
#define SkCustomTypeface_DEFINED
10
11
#include "
include/core/SkDrawable.h
"
12
#include "
include/core/SkFontMetrics.h
"
13
#include "
include/core/SkFontStyle.h
"
14
#include "
include/core/SkPath.h
"
15
#include "
include/core/SkRect.h
"
16
#include "
include/core/SkRefCnt.h
"
17
#include "
include/core/SkTypeface.h
"
18
#include "
include/core/SkTypes.h
"
19
20
#include <memory>
21
#include <vector>
22
23
class
SkStream
;
24
class
SkStreamAsset
;
25
struct
SkFontArguments
;
26
27
class
SK_API
SkCustomTypefaceBuilder
{
28
public
:
29
SkCustomTypefaceBuilder
();
30
31
void
setGlyph(
SkGlyphID
,
float
advance,
const
SkPath
&);
32
void
setGlyph(
SkGlyphID
,
float
advance,
sk_sp<SkDrawable>
,
const
SkRect
& bounds);
33
34
void
setMetrics(
const
SkFontMetrics
& fm,
float
scale
= 1);
35
void
setFontStyle(
SkFontStyle
);
36
37
sk_sp<SkTypeface>
detach();
38
39
static
constexpr
SkTypeface::FactoryId
FactoryId =
SkSetFourByteTag
(
'u'
,
's'
,
'e'
,
'r'
);
40
static
sk_sp<SkTypeface>
MakeFromStream(std::unique_ptr<SkStreamAsset>,
const
SkFontArguments
&);
41
42
private
:
43
struct
GlyphRec {
44
// logical union
45
SkPath
fPath
;
46
sk_sp<SkDrawable>
fDrawable;
47
48
SkRect
fBounds
= {0,0,0,0};
// only used for drawable glyphs atm
49
float
fAdvance = 0;
50
51
bool
isDrawable()
const
{
52
SkASSERT
(!fDrawable ||
fPath
.
isEmpty
());
53
return
fDrawable !=
nullptr
;
54
}
55
};
56
57
std::vector<GlyphRec> fGlyphRecs;
58
SkFontMetrics
fMetrics;
59
SkFontStyle
fStyle
;
60
61
GlyphRec& ensureStorage(
SkGlyphID
);
62
63
static
sk_sp<SkTypeface>
Deserialize(
SkStream
*);
64
65
friend
class
SkTypeface
;
66
friend
class
SkUserTypeface
;
67
};
68
69
#endif
fPath
SkPath fPath
Definition
AAConvexPathRenderer.cpp:886
fStyle
SkStrokeRec::Style fStyle
Definition
AALinearizingConvexPathRenderer.cpp:327
fBounds
const SkRect fBounds
Definition
ParsePathTest.cpp:38
SK_API
#define SK_API
Definition
SkAPI.h:35
SkASSERT
#define SkASSERT(cond)
Definition
SkAssert.h:116
SkDrawable.h
SkFontMetrics.h
SkFontStyle.h
SkPath.h
SkRect.h
SkRefCnt.h
SkTypeface.h
SkTypes.h
SkGlyphID
uint16_t SkGlyphID
Definition
SkTypes.h:179
SkSetFourByteTag
static constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d)
Definition
SkTypes.h:167
SkCustomTypefaceBuilder
Definition
SkCustomTypeface.h:27
SkFontStyle
Definition
SkFontStyle.h:16
SkPath
Definition
SkPath.h:59
SkPath::isEmpty
bool isEmpty() const
Definition
SkPath.cpp:406
SkStreamAsset
Definition
SkStream.h:186
SkStream
Definition
SkStream.h:29
SkTypeface
Definition
SkTypeface.h:52
SkTypeface::FactoryId
SkFourByteTag FactoryId
Definition
SkTypeface.h:335
SkUserTypeface
Definition
SkCustomTypeface.cpp:83
sk_sp
Definition
SkRefCnt.h:220
scale
const Scalar scale
Definition
stroke_path_geometry.cc:253
SkFontArguments
Definition
SkFontArguments.h:16
SkFontMetrics
Definition
SkFontMetrics.h:18
SkRect
Definition
extension.cpp:13
Generated on Fri Apr 26 2024 06:16:15 for Flutter Engine by
1.9.8