Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fonts.cc File Reference
#include <memory>
#include "flutter/skwasm/export.h"
#include "flutter/skwasm/live_objects.h"
#include "flutter/skwasm/wrappers.h"
#include "third_party/skia/include/core/SkFontMgr.h"
#include "third_party/skia/include/ports/SkFontMgr_empty.h"
#include "third_party/skia/modules/skparagraph/include/FontCollection.h"
#include "third_party/skia/modules/skparagraph/include/TypefaceFontProvider.h"

Go to the source code of this file.

Functions

SKWASM_EXPORT Skwasm::FlutterFontCollectionfontCollection_create ()
 
SKWASM_EXPORT void fontCollection_dispose (Skwasm::FlutterFontCollection *collection)
 
static sk_sp< SkFontMgr > default_fontmgr ()
 
SKWASM_EXPORT SkTypeface * typeface_create (SkData *font_data)
 
SKWASM_EXPORT void typeface_dispose (SkTypeface *typeface)
 
SKWASM_EXPORT void fontCollection_registerTypeface (Skwasm::FlutterFontCollection *collection, SkTypeface *typeface, SkString *font_name)
 
SKWASM_EXPORT void fontCollection_clearCaches (Skwasm::FlutterFontCollection *collection)
 

Function Documentation

◆ default_fontmgr()

static sk_sp< SkFontMgr > default_fontmgr ( )
static

Definition at line 33 of file fonts.cc.

33 {
34 static sk_sp<SkFontMgr> mgr = SkFontMgr_New_Custom_Empty();
35 return mgr;
36}

Referenced by typeface_create().

◆ fontCollection_clearCaches()

SKWASM_EXPORT void fontCollection_clearCaches ( Skwasm::FlutterFontCollection collection)

Definition at line 62 of file fonts.cc.

63 {
64 collection->collection->clearCaches();
65}
sk_sp< skia::textlayout::FontCollection > collection
Definition wrappers.h:37

References Skwasm::FlutterFontCollection::collection.

◆ fontCollection_create()

SKWASM_EXPORT Skwasm::FlutterFontCollection * fontCollection_create ( )

Definition at line 15 of file fonts.cc.

15 {
17 auto collection = sk_make_sp<skia::textlayout::FontCollection>();
18 auto provider = sk_make_sp<skia::textlayout::TypefaceFontProvider>();
19 collection->enableFontFallback();
20 collection->setDefaultFontManager(provider, "Roboto");
22 std::move(collection),
23 std::move(provider),
24 };
25}
uint32_t live_font_collection_count

References Skwasm::live_font_collection_count.

◆ fontCollection_dispose()

SKWASM_EXPORT void fontCollection_dispose ( Skwasm::FlutterFontCollection collection)

Definition at line 27 of file fonts.cc.

28 {
30 delete collection;
31}

References Skwasm::live_font_collection_count.

◆ fontCollection_registerTypeface()

SKWASM_EXPORT void fontCollection_registerTypeface ( Skwasm::FlutterFontCollection collection,
SkTypeface *  typeface,
SkString *  font_name 
)

Definition at line 49 of file fonts.cc.

52 {
53 if (font_name) {
54 SkString alias = *font_name;
55 collection->provider->registerTypeface(sk_ref_sp<SkTypeface>(typeface),
56 alias);
57 } else {
58 collection->provider->registerTypeface(sk_ref_sp<SkTypeface>(typeface));
59 }
60}
sk_sp< skia::textlayout::TypefaceFontProvider > provider
Definition wrappers.h:38

References Skwasm::FlutterFontCollection::provider.

◆ typeface_create()

SKWASM_EXPORT SkTypeface * typeface_create ( SkData *  font_data)

Definition at line 38 of file fonts.cc.

38 {
40 auto typeface = default_fontmgr()->makeFromData(sk_ref_sp<SkData>(font_data));
41 return typeface.release();
42}
static sk_sp< SkFontMgr > default_fontmgr()
Definition fonts.cc:33
uint32_t live_typeface_count

References default_fontmgr(), and Skwasm::live_typeface_count.

◆ typeface_dispose()

SKWASM_EXPORT void typeface_dispose ( SkTypeface *  typeface)

Definition at line 44 of file fonts.cc.

44 {
46 typeface->unref();
47}

References Skwasm::live_typeface_count.