Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkFontScanner_Fontations Class Reference

#include <SkFontScanner_fontations.h>

Inheritance diagram for SkFontScanner_Fontations:
SkFontScanner SkNoncopyable

Public Member Functions

 SkFontScanner_Fontations ()
 
 ~SkFontScanner_Fontations () override
 
bool scanFile (SkStreamAsset *stream, int *numFaces) const override
 
bool scanFace (SkStreamAsset *stream, int faceIndex, int *numInstances) const override
 
bool scanInstance (SkStreamAsset *stream, int faceIndex, int instanceIndex, SkString *name, SkFontStyle *style, bool *isFixedPitch, AxisDefinitions *axes) const override
 
- Public Member Functions inherited from SkFontScanner
virtual ~SkFontScanner ()=default
 
virtual bool scanFile (SkStreamAsset *stream, int *numFaces) const =0
 
virtual bool scanFace (SkStreamAsset *stream, int faceIndex, int *numInstances) const =0
 
virtual bool scanInstance (SkStreamAsset *stream, int faceIndex, int instanceIndex, SkString *name, SkFontStyle *style, bool *isFixedPitch, AxisDefinitions *axes) const =0
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Additional Inherited Members

- Public Types inherited from SkFontScanner
typedef skia_private::STArray< 4, AxisDefinition, trueAxisDefinitions
 

Detailed Description

Definition at line 26 of file SkFontScanner_fontations.h.

Constructor & Destructor Documentation

◆ SkFontScanner_Fontations()

SkFontScanner_Fontations::SkFontScanner_Fontations ( )

Definition at line 24 of file SkFontScanner_fontations.cpp.

24 {
25}

◆ ~SkFontScanner_Fontations()

SkFontScanner_Fontations::~SkFontScanner_Fontations ( )
override

Definition at line 27 of file SkFontScanner_fontations.cpp.

27 {
28}

Member Function Documentation

◆ scanFace()

bool SkFontScanner_Fontations::scanFace ( SkStreamAsset stream,
int  faceIndex,
int numInstances 
) const
overridevirtual

Implements SkFontScanner.

Definition at line 42 of file SkFontScanner_fontations.cpp.

44 {
45 rust::Box<fontations_ffi::BridgeFontRef> fontRef =
46 make_bridge_font_ref(SkData::MakeFromStream(stream, stream->getLength()), faceIndex);
47 stream->rewind();
48 if (!fontations_ffi::font_ref_is_valid(*fontRef)) {
49 return false;
50 }
51
52 // TODO: For now assume only the default instance (not variation)
53 *numInstances = 1;
54 return true;
55}
static sk_sp< SkData > MakeFromStream(SkStream *, size_t size)
Definition: SkData.cpp:208

◆ scanFile()

bool SkFontScanner_Fontations::scanFile ( SkStreamAsset stream,
int numFaces 
) const
overridevirtual

Implements SkFontScanner.

Definition at line 30 of file SkFontScanner_fontations.cpp.

30 {
31 sk_sp<SkData> fontData = SkData::MakeFromStream(stream, stream->getLength());
32 stream->rewind();
33 rust::Slice<const uint8_t> slice{fontData->bytes(), fontData->size()};
34 ::std::uint32_t num_fonts;
35 if (!fontations_ffi::font_or_collection(slice, num_fonts)) {
36 return false;
37 }
38 *numFaces = num_fonts == 0 ? 1 : num_fonts;
39 return true;
40}
const uint8_t * bytes() const
Definition: SkData.h:43
size_t size() const
Definition: SkData.h:30

◆ scanInstance()

bool SkFontScanner_Fontations::scanInstance ( SkStreamAsset stream,
int  faceIndex,
int  instanceIndex,
SkString name,
SkFontStyle style,
bool *  isFixedPitch,
AxisDefinitions axes 
) const
overridevirtual

Implements SkFontScanner.

Definition at line 58 of file SkFontScanner_fontations.cpp.

64 {
65 SkASSERT(instanceIndex == 0);
66 rust::Box<fontations_ffi::BridgeFontRef> fontRef =
67 make_bridge_font_ref(SkData::MakeFromStream(stream, stream->getLength()), faceIndex);
68 if (!fontations_ffi::font_ref_is_valid(*fontRef)) {
69 return false;
70 }
71
72 if (name != nullptr) {
73 rust::String readFamilyName = fontations_ffi::family_name(*fontRef);
74 *name = SkString(readFamilyName.data(), readFamilyName.size());
75 }
76
77 if (style != nullptr) {
78 rust::Slice<const fontations_ffi::SkiaDesignCoordinate> coordinates;
79 rust::Box<fontations_ffi::BridgeNormalizedCoords> normalizedCoords =
80 resolve_into_normalized_coords(*fontRef, coordinates);
81 fontations_ffi::BridgeFontStyle fontStyle;
82 if (fontations_ffi::get_font_style(*fontRef, *normalizedCoords, fontStyle)) {
83 *style = SkFontStyle(fontStyle.weight, fontStyle.width, (SkFontStyle::Slant)fontStyle.slant);
84 } else {
85 *style = SkFontStyle::Normal();
86 }
87 }
88
89 if (isFixedPitch != nullptr) {
90 *isFixedPitch = false; // TODO
91 }
92
93 return true;
94}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static constexpr SkFontStyle Normal()
Definition: SkFontStyle.h:66
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

The documentation for this class was generated from the following files: