Skip to content

Commit 0b7d920

Browse files
committed
feat: bump js runtime to 2.37.0 for fallback font API exposure. Also add github issue template
1 parent 56b706c commit 0b7d920

8 files changed

Lines changed: 209 additions & 20 deletions

File tree

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Rive Documentation
4+
url: https://rive.app/docs/
5+
about: Please refer to the Rive documentation for feature use, supported versions, and troubleshooting steps before submitting an issue.
6+
- name: Rive Community Support
7+
url: https://community.rive.app/
8+
about: For general questions and answers, please use the Rive Community.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Problem with the Rive React Runtime
2+
description: Report a bug or unexpected behavior in the Rive React runtime.
3+
body:
4+
- type: markdown
5+
attributes:
6+
value: |
7+
Thanks for using Rive and taking the time to fill this issue report out! Before filing an issue, please:
8+
- Confirm if the issue is still present on the [latest version of `@rive-app/react-canvas`](https://www.npmjs.com/package/@rive-app/react-canvas) or [`@rive-app/react-webgl2`](https://www.npmjs.com/package/@rive-app/react-webgl2)
9+
- Check the [Rive documentation](https://rive.app/docs/runtimes/react/react)
10+
- Search for help on the [Rive forums](https://community.rive.app/c/start-here)
11+
- For general Rive product feature requests, use the [feature request forum](https://community.rive.app/c/feature-requests/)
12+
13+
- type: checkboxes
14+
id: preflight
15+
attributes:
16+
label: Submission checklist
17+
options:
18+
- label: I have confirmed the issue is present in the latest version of `@rive-app/react-canvas` or `@rive-app/react-webgl2` (or the renderer variant I'm using)
19+
required: true
20+
- label: I have searched the documentation and forums and could not find an answer
21+
required: true
22+
- label: I have searched existing issues and this is not a duplicate
23+
required: true
24+
25+
- type: textarea
26+
id: description
27+
attributes:
28+
label: Description
29+
description: What issue are you running into? What's your expected behavior?
30+
placeholder: Describe the issue you're experiencing
31+
validations:
32+
required: true
33+
34+
- type: textarea
35+
id: repro-description
36+
attributes:
37+
label: Reproduction steps / code
38+
description: |
39+
Please provide the most **minimal reproduction** you can. Paste a code snippet if the problem is small enough. Or, you can also share a link to a minimal GitHub repository that reproduces the issue (ideally with a `package.json` and instructions to run)
40+
41+
Alternatively, you can share a CodeSandbox link or upload a .zip of your reproduction in the next question.
42+
placeholder: |
43+
```js
44+
// paste your code here
45+
```
46+
validations:
47+
required: false
48+
49+
- type: upload
50+
id: repro-files
51+
attributes:
52+
label: Upload your reproduction files / stack trace
53+
description: |
54+
55+
If your reproduction is more complex, you can upload a .zip of your project.
56+
Include a file with your stack trace if available as well if you cannot provide it above.
57+
Please make sure to include a `README` with instructions on how to run the reproduction.
58+
59+
- type: input
60+
id: rive_version
61+
attributes:
62+
label: Rive React package version
63+
description: Which version of `@rive-app/react-canvas` (or other renderer variant) are you using?
64+
placeholder: "e.g. @rive-app/react-canvas@4.27.3"
65+
validations:
66+
required: true
67+
68+
- type: upload
69+
id: riv_file
70+
attributes:
71+
label: Source `.riv` / `.rev` file
72+
description: |
73+
If you are able, attaching the runtime-exported `.riv` file (and ideally the source `.rev` backup) is immensely helpful for reproducing and fixing the issue quickly.
74+
75+
Note: Use a ZIP archive to upload `.riv`/`.rev` files (GitHub only supports certain file types). You can also share files privately at support@rive.app.
76+
validations:
77+
required: false
78+
79+
- type: upload
80+
id: screenshots
81+
attributes:
82+
label: Screenshots / video
83+
description: If applicable, add screenshots or a screen recording to help explain the problem.
84+
validations:
85+
required: false
86+
87+
- type: input
88+
id: browser
89+
attributes:
90+
label: Browser & version
91+
placeholder: "e.g. Chrome 123 Stable, Firefox 124, Safari 17.4"
92+
93+
- type: input
94+
id: os
95+
attributes:
96+
label: Operating system & version
97+
placeholder: "e.g. macOS 14.4, Windows 11, Ubuntu 22.04"
98+
99+
- type: textarea
100+
id: additional_context
101+
attributes:
102+
label: Additional context
103+
description: Any other context about the problem (frameworks, bundlers, relevant config, frequency of occurrence, etc.).
104+
validations:
105+
required: false
823 KB
Binary file not shown.
52 KB
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import FallbackFonts from './FallbackFonts';
4+
5+
const meta = {
6+
title: 'FallbackFonts',
7+
component: FallbackFonts,
8+
parameters: {
9+
layout: 'fullscreen',
10+
},
11+
args: {},
12+
} satisfies Meta<typeof FallbackFonts>;
13+
14+
export default meta;
15+
type Story = StoryObj<typeof meta>;
16+
17+
export const Default: Story = {};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React, {useEffect} from "react";
2+
import {useRive, RiveFont, decodeFont, Layout, Fit, Alignment} from "@rive-app/react-webgl2";
3+
4+
const THAI_FALLBACK_FONT_URL =
5+
"https://raw.githubusercontent.com/google/fonts/main/ofl/notoserifthai/NotoSerifThai%5Bwdth%2Cwght%5D.ttf";
6+
7+
const ARABIC_FALLBACK_FONT_URL =
8+
"./NotoSansArabic-VariableFont_wdth,wght.ttf";
9+
10+
const INITIAL_TEXT_SUFFIX = " สวัสดี AND مرحبا بالعالم";
11+
12+
13+
const FallbackFonts = () => {
14+
// Run before the Rive component is loaded to ensure fallback font strategy is set before Rive begins rendering
15+
useEffect(() => {
16+
const loadFont = async () => {
17+
const notoSerifThai = await fetch(THAI_FALLBACK_FONT_URL).then((res) => res.arrayBuffer());
18+
const notoSansArabic = await fetch(ARABIC_FALLBACK_FONT_URL).then((res) => res.arrayBuffer());
19+
const riveArabicDecodedFont = await decodeFont(new Uint8Array(notoSansArabic));
20+
const riveThaiDecodedFont = await decodeFont(new Uint8Array(notoSerifThai));
21+
// Check unicode ranges for glyphs and map to font support
22+
RiveFont.setFallbackFontCallback((missingGlyph: number, weight: number) => {
23+
if (missingGlyph >= 0x0600 && missingGlyph <= 0x06FF && riveArabicDecodedFont) {
24+
console.log("Setting fallback for Arabic. Missing Glyph unicode: ", String.fromCodePoint(missingGlyph), missingGlyph, " Weight: ", weight);
25+
return riveArabicDecodedFont;
26+
} else if (missingGlyph >= 0x0E00 && missingGlyph <= 0x0E7F && riveThaiDecodedFont) {
27+
console.log("Setting fallback for Thai. Missing Glyph unicode: ", String.fromCodePoint(missingGlyph), missingGlyph, " Weight: ", weight);
28+
return riveThaiDecodedFont;
29+
}
30+
return null;
31+
});
32+
};
33+
loadFont();
34+
}, []);
35+
36+
const { RiveComponent } = useRive({
37+
src: "fallback-fonts-3.riv",
38+
autoplay: true,
39+
autoBind: true,
40+
stateMachines: "State Machine 1",
41+
layout: new Layout({
42+
fit: Fit.Contain,
43+
alignment: Alignment.Center,
44+
}),
45+
onRiveReady: (rive) => {
46+
const defaultInstance = rive.viewModelInstance;
47+
const textProp = defaultInstance?.string("text");
48+
if (textProp) {
49+
textProp.value = `${textProp.value} - ${INITIAL_TEXT_SUFFIX}`; // Add Thai and Arabic text to demonstrate fallback font support.
50+
}
51+
},
52+
});
53+
54+
return (
55+
<RiveComponent />
56+
);
57+
};
58+
59+
export default FallbackFonts;

package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
},
3636
"homepage": "https://github.com/rive-app/rive-react#readme",
3737
"dependencies": {
38-
"@rive-app/canvas": "2.35.4",
39-
"@rive-app/canvas-lite": "2.35.4",
40-
"@rive-app/webgl": "2.35.4",
41-
"@rive-app/webgl2": "2.35.4"
38+
"@rive-app/canvas": "2.37.0",
39+
"@rive-app/canvas-lite": "2.37.0",
40+
"@rive-app/webgl": "2.37.0",
41+
"@rive-app/webgl2": "2.37.0"
4242
},
4343
"peerDependencies": {
4444
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0"

0 commit comments

Comments
 (0)