@shopify/react-native-skia 1.3.7 → 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,10 +45,20 @@ public:
45
45
  }
46
46
 
47
47
  JSI_HOST_FUNCTION(matchFamilyStyle) {
48
- auto name = arguments[0].asString(runtime).utf8(runtime);
49
- auto fontStyle = JsiSkFontStyle::fromValue(runtime, arguments[1]);
50
- sk_sp<SkFontStyleSet> set(getObject()->onMatchFamily(name.c_str()));
51
- sk_sp<SkTypeface> typeface(set->matchStyle(*fontStyle));
48
+ auto name = count > 0 ? arguments[0].asString(runtime).utf8(runtime) : "";
49
+ auto fontStyle =
50
+ count > 1 ? JsiSkFontStyle::fromValue(runtime, arguments[1]) : nullptr;
51
+ if (name == "" || fontStyle == nullptr) {
52
+ throw std::runtime_error("matchFamilyStyle requires a name and a style");
53
+ }
54
+ auto set = getObject()->onMatchFamily(name.c_str());
55
+ if (!set) {
56
+ throw std::runtime_error("Could not find font family " + name);
57
+ }
58
+ auto typeface = set->matchStyle(*fontStyle);
59
+ if (!typeface) {
60
+ throw std::runtime_error("Could not find font style for " + name);
61
+ }
52
62
  return jsi::Object::createFromHostObject(
53
63
  runtime, std::make_shared<JsiSkTypeface>(getContext(), typeface));
54
64
  }
@@ -4,5 +4,5 @@ import type { FontStyle } from "./Font";
4
4
  export interface SkFontMgr extends SkJSIInstance<"FontMgr"> {
5
5
  countFamilies(): number;
6
6
  getFamilyName(index: number): string;
7
- matchFamilyStyle(name?: string, style?: FontStyle): SkTypeface;
7
+ matchFamilyStyle(name: string, style: FontStyle): SkTypeface;
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["FontMgr.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkTypeface } from \"../Typeface\";\n\nimport type { FontStyle } from \"./Font\";\n\nexport interface SkFontMgr extends SkJSIInstance<\"FontMgr\"> {\n countFamilies(): number;\n getFamilyName(index: number): string;\n matchFamilyStyle(name?: string, style?: FontStyle): SkTypeface;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["FontMgr.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkTypeface } from \"../Typeface\";\n\nimport type { FontStyle } from \"./Font\";\n\nexport interface SkFontMgr extends SkJSIInstance<\"FontMgr\"> {\n countFamilies(): number;\n getFamilyName(index: number): string;\n matchFamilyStyle(name: string, style: FontStyle): SkTypeface;\n}\n"],"mappings":""}
@@ -4,5 +4,5 @@ import type { FontStyle } from "./Font";
4
4
  export interface SkFontMgr extends SkJSIInstance<"FontMgr"> {
5
5
  countFamilies(): number;
6
6
  getFamilyName(index: number): string;
7
- matchFamilyStyle(name?: string, style?: FontStyle): SkTypeface;
7
+ matchFamilyStyle(name: string, style: FontStyle): SkTypeface;
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["FontMgr.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkTypeface } from \"../Typeface\";\n\nimport type { FontStyle } from \"./Font\";\n\nexport interface SkFontMgr extends SkJSIInstance<\"FontMgr\"> {\n countFamilies(): number;\n getFamilyName(index: number): string;\n matchFamilyStyle(name?: string, style?: FontStyle): SkTypeface;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["FontMgr.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkTypeface } from \"../Typeface\";\n\nimport type { FontStyle } from \"./Font\";\n\nexport interface SkFontMgr extends SkJSIInstance<\"FontMgr\"> {\n countFamilies(): number;\n getFamilyName(index: number): string;\n matchFamilyStyle(name: string, style: FontStyle): SkTypeface;\n}\n"],"mappings":""}
@@ -4,5 +4,5 @@ import type { FontStyle } from "./Font";
4
4
  export interface SkFontMgr extends SkJSIInstance<"FontMgr"> {
5
5
  countFamilies(): number;
6
6
  getFamilyName(index: number): string;
7
- matchFamilyStyle(name?: string, style?: FontStyle): SkTypeface;
7
+ matchFamilyStyle(name: string, style: FontStyle): SkTypeface;
8
8
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "1.3.7",
10
+ "version": "1.3.8",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "react-native": "src/index.ts",
@@ -6,5 +6,5 @@ import type { FontStyle } from "./Font";
6
6
  export interface SkFontMgr extends SkJSIInstance<"FontMgr"> {
7
7
  countFamilies(): number;
8
8
  getFamilyName(index: number): string;
9
- matchFamilyStyle(name?: string, style?: FontStyle): SkTypeface;
9
+ matchFamilyStyle(name: string, style: FontStyle): SkTypeface;
10
10
  }