FontFeature.scientificInferiors constructor Null safety
Use scientific inferiors. (sinf
)
Some fonts have variants of the figures (e.g. the digit 2) that, when this feature is enabled, render in a manner more appropriate for subscripted digits ("inferiors") used in scientific contexts, e.g. the subscripts in chemical formulae.
This may override other features that substitute glyphs.
The Piazzolla font supports the
sinf
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.scientificInferiors.1 mysample
flutter create --sample=dart.dart_ui.FontFeature.scientificInferiors.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 Piazzolla font can be downloaded from Google Fonts (https://www.google.com/fonts).
return const Text(
'C8H10N4O2',
style: TextStyle(
fontFamily: 'Piazzolla',
fontFeatures: <FontFeature>[
FontFeature.scientificInferiors(),
],
),
);
}
}
See also:
Implementation
const FontFeature.scientificInferiors() : feature = 'sinf', value = 1;