FontFeature.subscripts constructor
Enable subscripts. (subs
)
This feature causes some fonts to change some glyphs to their subscripted form.
It typically does not affect all glyphs, and so is not appropriate for generally causing all text to be subscripted.
This may override other features that substitute glyphs.
The Piazzolla font supports the
link
subs
feature. It causes
digits to be smaller and subscripted.
To create a local project with this code sample, run:
flutter create --sample=dart.dart_ui.FontFeature.subscripts.1 mysample
import 'package:flutter/widgets.dart';
/// Flutter code sample for [FontFeature.FontFeature.subscripts].
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 Piazzolla font can be downloaded from Google Fonts
// (https://www.google.com/fonts).
return const Text(
'Line from x1,y1 to x2,y2',
style: TextStyle(
fontFamily: 'Piazzolla',
fontFeatures: <FontFeature>[
FontFeature.subscripts(),
],
),
);
}
}
See also:
- docs.microsoft.com/en-us/typography/opentype/spec/features_pt#subs
- FontFeature.scientificInferiors, which is similar but intended specifically for subscripts used in scientific contexts.
- FontFeature.superscripts, which is similar but for subscripting.
Implementation
const FontFeature.subscripts() : feature = 'subs', value = 1;