FontFeature class

A feature tag and value that affect the selection of glyphs in a font.

{@inject-html}

{@end-inject-html}This example shows usage of several OpenType font features, including Small Caps (smcp), old-style figures, fractional ligatures and stylistic sets.{@inject-html}
class TypePage extends StatelessWidget {
 // The Cardo, Milonga and Raleway Dots fonts can be downloaded from
 // Google Fonts (https://www.google.com/fonts).

final titleStyle = TextStyle( fontSize: 18, fontFeatures: FontFeature.enable('smcp'), color: Colors.blueGrey600, );

@override Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Spacer(flex: 5), Text('regular numbers have their place:', style: titleStyle), Text('The 1972 cup final was a 1-1 draw.', style: TextStyle( fontFamily: 'Cardo', fontSize: 24, )), Spacer(), Text('but old-style figures blend well with lower case:', style: titleStyle), Text('The 1972 cup final was a 1-1 draw.', style: TextStyle( fontFamily: 'Cardo', fontSize: 24, fontFeatures: FontFeature.oldstyleFigures())), Spacer(), Divider(), Spacer(), Text('fractions look better with a custom ligature:', style: titleStyle), Text('Add 1/2 tsp of flour and stir.', style: TextStyle( fontFamily: 'Milonga', fontSize: 24, fontFeatures: FontFeature.enable(&#39;frac&#39;))), Spacer(), Divider(), Spacer(), Text('multiple stylistic sets in one font:', style: titleStyle), Text('Raleway Dots', style: TextStyle(fontFamily: 'Raleway Dots', fontSize: 48)), Text('Raleway Dots', style: TextStyle( fontFeatures: FontFeature.stylisticSet(1), fontFamily: 'Raleway Dots', fontSize: 48, )), Spacer(flex: 5), ], ), ), ); } }

{@end-inject-html}

Constructors

FontFeature(String feature, [ int value = 1 ])
Creates a FontFeature object, which can be added to a TextStyle to change how the engine selects glyphs when rendering text. [...]
const
FontFeature.disable(String feature)
Create a FontFeature object that disables the feature with the given tag.
const
FontFeature.enable(String feature)
Create a FontFeature object that enables the feature with the given tag.
const
FontFeature.oldstyleFigures()
Use oldstyle figures. [...]
const
FontFeature.proportionalFigures()
Use proportional (varying width) figures. [...]
const
FontFeature.randomize()
Randomize the alternate forms used in text. [...]
const
FontFeature.slashedZero()
Use the slashed zero. [...]
const
FontFeature.stylisticSet(int value)
Select a stylistic set. [...]
factory
FontFeature.tabularFigures()
Use tabular (monospace) figures. [...]
const

Properties

feature String
The tag that identifies the effect of this feature. Must consist of 4 ASCII characters (typically lowercase letters). [...]
final
hashCode int
The hash code for this object. [...]
read-only, override
value int
The value assigned to this feature. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

toString() String
Returns a string representation of this object.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
override