Overview
Rive files can embed fonts, but these fonts might not contain all characters your application needs. The fallback font system allows you to specify system fonts or custom fonts to use when characters are missing from the embedded font.Fallback Font Providers
The iOS Runtime provides two ways to specify fallback fonts:RiveFallbackFontDescriptor
Descriptors generate system fonts with specific attributes:UIFont Directly
You can also use anyUIFont instance as a fallback font provider.
Setting Global Fallback Fonts
Set fallback fonts that will be used for all Rive text:Style-Specific Fallback Fonts
For more control, set a callback that returns different fonts based on text style:fallbackFontsCallback is set, fallbackFonts is ignored.
Complete SwiftUI Example
UIKit Example
Font Weight Matching
TheRiveFontStyle provides weight information to match fonts:
System Font Design
Use different system font designs:Font Width Options
Using Custom Font Files
To use custom font files in your app:- Add the font file to your Xcode project
- Include it in your app’s Info.plist under “Fonts provided by application”
- Reference it by name:
RiveFallbackFontProvider Protocol
BothRiveFallbackFontDescriptor and UIFont conform to RiveFallbackFontProvider:
Best Practices
- Set Fallbacks Early: Configure fallback fonts in your app delegate or before loading Rive files
- Test Missing Characters: Test with text that contains characters not in your embedded font
- Weight Matching: Match fallback font weights to Rive text styles for consistent appearance
- Fallback Order: List fonts in order of preference; the first font with the glyph will be used
- Global vs. Callback: Use global
fallbackFontsfor simplicity, callbacks for fine-grained control - Font Availability: Check font availability before using custom fonts by name
Common Use Cases
Multilingual Support
Emoji Support
Special Characters
Troubleshooting
Missing Characters Still Not Rendering
- Verify fallback fonts are set before creating
RiveView - Check that fallback fonts contain the required glyphs
- Ensure custom fonts are properly added to your project
Font Weight Not Matching
- Use the
fallbackFontsCallbackto match weights precisely - Test different font weights to find the best match
Performance Concerns
- Limit the number of fallback fonts in the array
- Use font descriptors instead of loading many font instances
See Also
- Rive Text - Working with dynamic text
- Data Binding - Binding data to animations