FontFeature.superscripts constructor Null safety

const FontFeature.superscripts()

Enable superscripts. (sups)

This feature causes some fonts to change some glyphs to their superscripted form. This may be more than just changing their position. For example, digits might change to lining figures (see FontFeature.liningFigures) in addition to being raised and shrunk.

It typically does not affect all glyphs, and so is not appropriate for generally causing all text to be superscripted.

This may override other features that substitute glyphs.

The Sorts Mill Goudy font supports the sups feature. It causes digits to be smaller, superscripted, and changes them to lining figures (so they are all the same height).

To create a local project with this code sample, run:
flutter create --sample=dart.dart_ui.FontFeature.superscripts.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 Sorts Mill Goudy font can be downloaded from Google Fonts (https://www.google.com/fonts).
    return const Text(
      'The isotope 238U decays to 206Pb',
      style: TextStyle(
        fontFamily: 'Sorts Mill Goudy',
        fontFeatures: <FontFeature>[
          FontFeature.superscripts(),
        ],
      ),
    );
  }
}

See also:

Implementation

const FontFeature.superscripts() : feature = 'sups', value = 1;