feat(terminal): bundle JetBrainsMono Nerd Font for terminal glyphs

The terminal tabs and inline terminal panel used xterm's default
`monospace`, which lacks Nerd Font glyphs — so TUIs like yazi rendered
box-drawing, Powerline symbols and file-type icons as tofu.

Declare a `JetBrainsMono Nerd Font` family in pubspec and apply it via
`TerminalStyle` (with a Cascadia Code / Fira Code / system-monospace
fallback chain) to the `TerminalView` in both `terminal_page.dart`
(tabs) and `inline_terminal_panel.dart` (mobile split view). The font
binary (nerd-fonts v3.3.0) is bundled like RustDesk's other assets;
`flutter/fetch_font.sh` can refresh it. Client-only; the server stays stock.
This commit is contained in:
Artur Puig 2026-06-21 22:41:37 +02:00
commit 25e05eec3a
5 changed files with 50 additions and 2 deletions

Binary file not shown.

22
flutter/fetch_font.sh Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Downloads JetBrainsMono Nerd Font for terminal glyph support (yazi, etc.)
set -euo pipefail
FONT_DIR="$(dirname "$0")/assets"
FONT_FILE="$FONT_DIR/JetBrainsMonoNerdFont-Regular.ttf"
FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/download/v3.3.0/JetBrainsMono.zip"
if [ -f "$FONT_FILE" ]; then
echo "Font already exists: $FONT_FILE"
exit 0
fi
echo "Downloading JetBrainsMono Nerd Font..."
mkdir -p "$FONT_DIR"
TMPZIP=$(mktemp /tmp/JetBrainsMono.XXXXXX.zip)
trap 'rm -f "$TMPZIP"' EXIT
wget -q "$FONT_URL" -O "$TMPZIP"
unzip -q -o "$TMPZIP" "JetBrainsMonoNerdFont-Regular.ttf" -d /tmp/
mv /tmp/JetBrainsMonoNerdFont-Regular.ttf "$FONT_FILE"
echo "Installed: $FONT_FILE ($(du -h "$FONT_FILE" | cut -f1))"

View file

@ -98,8 +98,18 @@ class _InlineTerminalPanelState extends State<InlineTerminalPanel> {
// Slightly larger than xterm's default (13) with comfortable line height for
// legibility on a phone-sized split view.
static const TerminalStyle _textStyle =
TerminalStyle(fontSize: 14, height: 1.3);
static const TerminalStyle _textStyle = TerminalStyle(
fontSize: 14,
height: 1.3,
fontFamily: 'JetBrainsMono Nerd Font',
fontFamilyFallback: [
'Cascadia Code',
'Fira Code',
'Menlo',
'Consolas',
'monospace',
],
);
// Show the on-screen special-keys bar (Esc/Ctrl/Alt/arrows/). Honours the
// same option as the stock mobile terminal (default on).

View file

@ -47,6 +47,18 @@ class _TerminalPageState extends State<TerminalPage>
static const EdgeInsets _defaultTerminalPadding =
EdgeInsets.symmetric(horizontal: 5.0, vertical: 2.0);
static const TerminalStyle _terminalStyle = TerminalStyle(
fontSize: 14,
fontFamily: 'JetBrainsMono Nerd Font',
fontFamilyFallback: [
'Cascadia Code',
'Fira Code',
'Menlo',
'Consolas',
'monospace',
],
);
late FFI _ffi;
late TerminalModel _terminalModel;
double? _cellHeight;
@ -199,6 +211,7 @@ class _TerminalPageState extends State<TerminalPage>
_terminalModel.terminal,
controller: _terminalModel.terminalController,
focusNode: _terminalFocusNode,
textStyle: _terminalStyle,
// Note: autofocus is not used here because focus is managed manually
// via _onTabStateChanged() to handle tab switching properly.
backgroundOpacity: 0.7,

View file

@ -172,6 +172,9 @@ flutter:
- family: More
fonts:
- asset: assets/more.ttf
- family: JetBrainsMono Nerd Font
fonts:
- asset: assets/JetBrainsMonoNerdFont-Regular.ttf
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.