FontFeature.fractions constructor

const FontFeature.fractions()

Use ligatures to represent fractions. (afrc)

When this feature is enabled (and the font supports it), sequences of digits separated by U+002F SOLIDUS character (/) or U+2044 FRACTION SLASH (⁄) are replaced by ligatures that represent the corresponding fraction.

This feature may imply the FontFeature.numerators and FontFeature.denominator features.

The Ubuntu Mono font supports the frac feature. It causes digits around slashes to be turned into dedicated fraction glyphs. This contrasts to the effect seen with FontFeature.alternativeFractions.

link

To create a local project with this code sample, run:
flutter create --sample=dart.dart_ui.FontFeature.FontFeature.fractions.1 mysample

import 'package:flutter/widgets.dart';

/// Flutter code sample for [FontFeature.fractions].

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 Ubuntu Mono font can be downloaded from Google Fonts
    // (https://www.google.com/fonts).
    return const Text(
      'Fractions: 1/2 2/3 3/4 4/5',
      style: TextStyle(
        fontFamily: 'Ubuntu Mono',
        fontFeatures: <FontFeature>[
          FontFeature.fractions(),
        ],
      ),
    );
  }
}

See also:

Implementation

const FontFeature.fractions() : feature = 'frac', value = 1;