How to load a font from memory or file?

662 views
Skip to first unread message

Yosof

unread,
Mar 8, 2024, 8:02:34 PM3/8/24
to skia-discuss
I recently upgraded to a new skia version provided by vcpkg and I found that SkFontMgr::RefDefault() was removed

instead there is SkFontMgr::RefEmpty() which as the name implies has no fonts at all!
I suspect this is the cause the text layout is always empty


I tried to load fonts using TypefaceFontProvider but its onMakeFromData() and onMakeFromFile() are stubbed and returning nullptr

How should I load fonts ?
And is there still a method to load the system fonts like was before or I have to implement all of this myself?

Red Artist

unread,
Mar 9, 2024, 8:26:46 AM3/9/24
to skia-discuss

You can still use the custom fontmgrs, like SkFontMgr_New_Custom_Directory which loads fonts from a specific directory.

But if you wanted to keep previous behavior of system font managers, look at what rust-skia did. https://github.com/rust-skia/rust-skia/releases/tag/0.71.0

Yosof

unread,
Mar 9, 2024, 1:14:53 PM3/9/24
to skia-discuss
working fine now
Reply all
Reply to author
Forward
0 new messages