import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; /// The bundled icon font terminals fall back to for Powerline and Nerd Font /// glyphs (fonts/README.md): a subset of Symbols Nerd Font Mono. const String terminalSymbolsFamily = 'SymbolsNerdFontMono'; const String terminalSymbolsAsset = 'fonts/symbols-nerd-font/SymbolsNerdFontMono-Subset.ttf'; const String terminalSymbolsLicenseAsset = 'fonts/symbols-nerd-font/LICENSE'; Future? _loading; /// Registers [terminalSymbolsFamily] the first time a terminal is drawn. It /// is a plain asset, not a `fonts:` family, so the web build does not /// download it at startup. Once registered the engine reports a font change /// and terminal views draw again with it. A failed load is logged; the /// glyphs then stay as the platform's fallback draws them. Future ensureTerminalSymbolsFont() => _loading ??= _load(); Future _load() async { try { final loader = FontLoader(terminalSymbolsFamily) ..addFont(rootBundle.load(terminalSymbolsAsset)); await loader.load(); } catch (error) { debugPrint('Terminal symbols font did not load: $error'); } }