Terminal: grapheme-aware widths, drawn box/Powerline glyphs, line pictures
Emulator (vendored xterm): - Widths follow glibc wcwidth on generated Unicode 16 tables (tool/gen_unicode_tables.py); combining marks, variation selectors, ZWJ sequences, skin tones, flags and Hangul jamo join the previous cell, stored as interned clusters (CellContent.clusterFlag) and drawn and copied whole. U+FE0F and flags take two columns, as modern terminals do; a wide character never starts in the last column. - Box drawing, block elements and Powerline separators are drawn as geometry filling the cell; rows are whole pixels high. - Backgrounds merge per colour; each line is a picture reused until the line changes (BufferLine.version); a line drawn unchanged settles into one laid out paragraph with a span per style. TerminalStyle and TerminalTheme compare by value. App: bundled Symbols Nerd Font Mono subset (568 KiB, MIT) as the terminal's first fallback, loaded on first use; line height 1.1; ?terminalUnicode=1 fixture showcase; bench gains a progress workload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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<void>? _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<void> ensureTerminalSymbolsFont() => _loading ??= _load();
|
||||
|
||||
Future<void> _load() async {
|
||||
try {
|
||||
final loader = FontLoader(terminalSymbolsFamily)
|
||||
..addFont(rootBundle.load(terminalSymbolsAsset));
|
||||
await loader.load();
|
||||
} catch (error) {
|
||||
debugPrint('Terminal symbols font did not load: $error');
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../text/terminal_symbols_font.dart';
|
||||
import 'app_font.dart';
|
||||
|
||||
bool _registered = false;
|
||||
|
||||
/// Adds each bundled interface font's SIL Open Font License to the
|
||||
/// Adds each bundled interface font's SIL Open Font License, and the
|
||||
/// terminal symbols font's MIT licence, to the
|
||||
/// [LicenseRegistry]. The texts are read from the bundle only when a licence
|
||||
/// page asks for them.
|
||||
void registerAppFontLicenses() {
|
||||
@@ -19,5 +21,8 @@ void registerAppFontLicenses() {
|
||||
font.label,
|
||||
], await rootBundle.loadString(asset));
|
||||
}
|
||||
yield LicenseEntryWithLineBreaks(<String>[
|
||||
'Symbols Nerd Font Mono',
|
||||
], await rootBundle.loadString(terminalSymbolsLicenseAsset));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user