Skip to content

Commit ee35821

Browse files
committed
Create the system fontMgr upfront
1 parent 44c2fd2 commit ee35821

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

package/cpp/api/JsiSkApi.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ class JsiSkApi : public JsiSkHostObject {
6363
*/
6464
JsiSkApi(jsi::Runtime &runtime, std::shared_ptr<RNSkPlatformContext> context)
6565
: JsiSkHostObject(context) {
66-
66+
// We create the system font manager eagerly since it has proven to be too slow
67+
// to do it on demand
68+
JsiSkFontMgrFactory::getFontMgr(getContext());
6769
installFunction("Font", JsiSkFont::createCtor(context));
6870
installFunction("Paint", JsiSkPaint::createCtor(context));
6971
installFunction("RSXform", JsiSkRSXform::createCtor(context));

package/cpp/api/JsiSkParagraphBuilder.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <JsiSkParagraphStyle.h>
1313
#include <JsiSkTextStyle.h>
1414
#include <JsiSkTypefaceFontProvider.h>
15+
#include <JsiSkFontMgrFactory.h>
1516

1617
#pragma clang diagnostic push
1718
#pragma clang diagnostic ignored "-Wdocumentation"
@@ -113,7 +114,8 @@ class JsiSkParagraphBuilder : public JsiSkHostObject {
113114
sk_sp<SkFontMgr> fontManager)
114115
: JsiSkHostObject(std::move(context)) {
115116
_fontCollection = sk_make_sp<para::FontCollection>();
116-
_fontCollection->setDefaultFontManager(JsiSkFontMgrFactory::getFontMgr(context));
117+
auto fontMgr = JsiSkFontMgrFactory::getFontMgr(getContext());
118+
_fontCollection->setDefaultFontManager(fontMgr);
117119
if (fontManager != nullptr) {
118120
_fontCollection->setAssetFontManager(fontManager);
119121
}

0 commit comments

Comments
 (0)