mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-06-21 21:51:03 +08:00
Feature options on Fonts
Adds runtime and editor support for setting feature flags on a Font. The biggest change to the font engine is that the feature options are now stored on the Font object itself instead of hard-coded during shaping. This is nice as it requires no extra data to be piped through for individual run styling. It also means that we generalized the concept of creating a variable font as configuring a version of the font (see withOptions replacing makeVariation) so that variable axis and feature settings are treated as options to a Font configuration. This also allows us to track existing variations and options on the configured Font such that any further call to "withOptions" on that already configured Font will propagate previous changes if not overridden. This fortuitously also fixes an issue the modifiers were exhibiting where a variation set on the TextStyle that wasn't part of the modifier set would be lost. Diffs= 31d9a5424 Feature options on Fonts (#5479) 8b7587241 Runtime/interpolate states cpp (#5437) Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
This commit is contained in:
@ -1 +1 @@
|
||||
59858e3330db2d56f9db570df8bcb8f6af23b154
|
||||
31d9a54243e694ede76dc133cf209d7b67c13708
|
||||
|
@ -148,8 +148,10 @@ class TextModifierGroup extends TextModifierGroupBase {
|
||||
}
|
||||
|
||||
if (axisVariations.isNotEmpty) {
|
||||
var varFont = font.makeVariation(axisVariations.entries
|
||||
.map((entry) => FontAxisCoord(entry.key, entry.value)));
|
||||
var varFont = font.withOptions(
|
||||
axisVariations.entries
|
||||
.map((entry) => FontAxisCoord(entry.key, entry.value)),
|
||||
[]);
|
||||
if (varFont != null) {
|
||||
_cleanupFonts.add(varFont);
|
||||
font = varFont;
|
||||
|
@ -65,8 +65,8 @@ class TextStyle extends TextStyleBase
|
||||
TextVariationHelper? _variationHelper;
|
||||
TextVariationHelper? get variationHelper => _variationHelper;
|
||||
|
||||
Font? _makeVariableFont() => asset?.font?.makeVariation(
|
||||
_variations.map((axis) => FontAxisCoord(axis.tag, axis.axisValue)));
|
||||
Font? _makeVariableFont() => asset?.font?.withOptions(
|
||||
_variations.map((axis) => FontAxisCoord(axis.tag, axis.axisValue)), []);
|
||||
|
||||
Font? get font => _variationHelper?.font ?? asset?.font;
|
||||
|
||||
|
@ -9,7 +9,7 @@ class TextStyleAxis extends TextStyleAxisBase {
|
||||
@override
|
||||
bool validate() => super.validate() && parent is TextStyle;
|
||||
|
||||
String get tagName => FontAxis.tagToName(tag);
|
||||
String get tagName => FontTag.tagToName(tag);
|
||||
|
||||
@override
|
||||
void update(int dirt) {}
|
||||
|
@ -7,7 +7,7 @@ import 'package:rive_common/rive_text.dart';
|
||||
export 'package:rive/src/generated/text/text_variation_modifier_base.dart';
|
||||
|
||||
class TextVariationModifier extends TextVariationModifierBase {
|
||||
String get tagName => FontAxis.tagToName(axisTag);
|
||||
String get tagName => FontTag.tagToName(axisTag);
|
||||
|
||||
@override
|
||||
void axisTagChanged(int from, int to) =>
|
||||
|
@ -15,7 +15,7 @@ dependencies:
|
||||
http: ^0.13.3
|
||||
meta: ^1.3.0
|
||||
plugin_platform_interface: ^2.0.2
|
||||
rive_common: ^0.0.10
|
||||
rive_common: 0.1.0
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
Reference in New Issue
Block a user