FontFeature.historicalForms constructor Null safety
Use historical forms. (hist
)
Some fonts have alternatives for letters whose forms have changed through the ages. In the Latin alphabet, this is common for example with the long-form "s" or the Fraktur "k". This feature enables those alternative glyphs.
This does not enable legacy ligatures, only single-character alternatives. To enable historical ligatures, use FontFeature.historicalLigatures.
This feature may override other glyph-substitution features.
The Cardo font supports the
hist
feature specifically for the
letter "s": it changes occurrences of that letter for the glyph
used by U+017F LATIN SMALL LETTER LONG S.
To create a local project with this code sample, run:
flutter create --sample=dart.dart_ui.FontFeature.historicalForms.1 mysample
flutter create --sample=dart.dart_ui.FontFeature.historicalForms.1 mysample
import 'dart:ui';
import 'package:flutter/widgets.dart';
void main() => runApp(const ExampleApp());
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return WidgetsApp(
builder: (BuildContext context, Widget? navigator) =>
const ExampleWidget(),
color: const Color(0xffffffff),
);
}
}
class ExampleWidget extends StatelessWidget {
const ExampleWidget({super.key});
@override
Widget build(BuildContext context) {
// The Cardo font can be downloaded from Google Fonts (https://www.google.com/fonts).
return const Text(
'VIBRANT fish assisted his business.',
style: TextStyle(
fontFamily: 'Sorts Mill Goudy',
fontFeatures: <FontFeature>[
FontFeature.historicalForms(), // Enables "hist".
// Use FontFeature.historicalLigatures() to enable "hlig" as well.
],
),
);
}
}
See also:
Implementation
const FontFeature.historicalForms() : feature = 'hist', value = 1;