Repository navigation
LT-22854: Control the Avalonia interface font from the theme - #1196
johnml1135 wants to merge 4 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1196 +/- ##
=======================================
Coverage 39.88% 39.89%
=======================================
Files 1542 1543 +1
Lines 355361 355403 +42
Branches 41320 41324 +4
=======================================
+ Hits 141753 141784 +31
- Misses 184253 184262 +9
- Partials 29355 29357 +2
🚀 New features to boost your workflow:
|
The five faces in use (Regular, Italic, Bold, BoldItalic, SemiBold) ship unmodified inside FwAvaloniaTheme.dll with the OFL text and a notice recording the SHA-256 of each file. Nothing registers or uses them yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The interface font is no longer left to the platform default. The FwUiFontFamily token names it, FwUiFont registers the bundled font collection and points Semi's DefaultFontFamily, ContentControlThemeFontFamily and SemiFontFamilyRegular at a stack of that font followed by the fallbacks the UI language needs. The default is Andika; fa, hi, ko, te and zh-CN get a Windows system font first and the SIL or Noto family second. The other UI languages are covered by the default itself. Data text keeps its writing-system font, and the writing-system abbreviation column is measured in the interface font. The token generator learns FontFamily entries. Tests cover each fallback language's sample string. Two tests that built Avalonia controls on the NUnit thread become AvaloniaTest, since the headless session owns the dispatcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ADR 0004 records that the theme controls the interface font, Andika as the proposed default and the alternatives, the Semi resource keys, the five faces, the unchanged sizes and the per-language fallback fonts. Two passages that still described the Fluent theme and its font now name the Semi theme and the FieldWorks interface font. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The nine committed dialog snapshots are regenerated with the interface in Andika. Lines are about 3 px taller at 11 px, so rows and dialogs grow a little; AssertNoCrowding still passes for every dialog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f5874ae to
0921803
Compare
|
So my first thought on looking at this is how it will interact with the users ability to choose the UI font from the styles dialog. I'll do a code review on it, but I wanted to capture my thoughts first. |
jasonleenaylor
left a comment
There was a problem hiding this comment.
The token mechanism is a good shape, but please don't let the default raise the line height. Interface density is a feature of FieldWorks that nearly all users value, and Andika's 1.61 em line against Segoe UI's 1.33 makes every row and dialog taller. Pick a default that keeps today's line height, or bring the line-height tokens the ADR defers into this PR. Users with limited vision who need larger or taller text should get it through the user font setting in the inline comment, not through the default.
This review was assisted by Claude Opus 5.5.
| /// the order tried. A family that is not installed is skipped, so each list names a | ||
| /// Windows system font first and an SIL or Noto family second. Keyed by language code, so | ||
| /// every Chinese culture shares one list.</summary> | ||
| private static readonly Dictionary<string, string[]> FallbacksByLanguage = |
There was a problem hiding this comment.
FieldWorks already lets users choose a UI font: the UiElement style is listed in the Styles dialog (FwStylesDlg.cs:148 shows internal styles), with a font per writing system, and the WinForms views use it for UI text drawn in Views (FwBaseVc.MakeUiElementString, FilterBar.cs:930, the detail view's literal headings). Nothing in Avalonia reads it yet, and this table adds a second, fixed mechanism alongside it. It also misses ar, bn, km, ml, my, ne, ta, th and ur, which the installer ships (Installer.targets:98-127). The Avalonia interface font should integrate with that setting: take UiElement's font for the UI writing system, with the bundled font as the default when none is set, instead of a hard-coded fallback table.
Start here:
Src/Common/FwAvalonia/FwUiFont.cs, then the tokenFwUiFontFamilyinSrc/Common/FwAvaloniaTheme/Tokens/FwColorTokens.axaml. The decision is inDocs/architecture/adr/0004-interface-font-controlled-by-the-theme.md. Jira: https://jira.sil.org/browse/LT-22854Ready for review. Nothing is red; one xWorksTests clipboard test failed once and passes alone (see Tests).
FieldWorks now controls the font of its Avalonia interface. One theme token,
FwUiFontFamily, names it, and Semi's font resources point at that token, so all text inherits it from the root. The font is bundled inFwAvaloniaTheme, so it is the same on every machine and nothing needs installing. Five UI languages (fa, hi, ko, te, zh-CN) get fallback lists: a Windows system font first, then the SIL or Noto family. To change the font later, change the token and replace the bundled files. No code changes.Proposed default: Andika 7.000 (OFL, five faces, about 4.1 MB). The cost is height: lines are about 21% taller (1.61 em against 1.33 em), so rows and dialogs grow by a few pixels. Font sizes (11 px, 13 px) and x-height (0.508 em against 0.500 em) are unchanged. The default is the proposal; the mechanism is the point. Alternatives are in the first accordion.
Headless captures from the dialog tests, not the running product:
All 9 before/after pairs are attached to LT-22854.
Where to look
FwUiFontTestschecks each fallback language's sample string.AssertNoCrowdingstill passes for every dialog.DisposeDialogResources_*tests moved to[AvaloniaTest](accordion).Not in this PR: the installer still ships Andika 6.101 (LT-19288); decision-register rows for #1191 (#1191).
Next: approve the token mechanism, and say whether Andika is the default you want or one of the alternatives.
Reading this a year from now -- start here
This branch had no research or working notes in the tree. The reasoning below is the record: why the font is controlled by the theme, what the default is and what else was considered. The durable decision is also in ADR 0004.
Alternatives to Andika, and why each was not the default
Andika 7.000 is the only SIL Latin sans with full Latin, Cyrillic, Greek and IPA and all the weights FieldWorks uses. It is the proposal, not a settled choice: the token can name any of these instead.
Cost of the default: line height 1.61 em against 1.33 em (about 21% taller, about 3 px at 11 px).
Reviewer notes: two test changes
The two
DisposeDialogResources_*tests moved to[AvaloniaTest]. The problem was already there. They builtnew Control()on the NUnit thread, outside the headless dispatcher, so they depended on which thread owned the dispatcher. Setting the font resources changed that timing and exposed it. With[Test], 1 in 3 full runs failed with "Call from invalid thread". Running them on the headless thread fixes it.In
xWorksTests,FwDragDropDataTests.TextDrag_FromAvaloniaPayload_LegacyClipboardBridgeReadsBothRichAndNeutralLanesfailed once in a full filter run and passed when the class ran alone. It reads the system clipboard and does not touch fonts.Evidence: tests and checks
FwAvaloniaTests: 949 passed, 1 skipped.FwAvaloniaDialogsTests: 289 of 289 passed.xWorksTests, Avalonia filter (FullyQualifiedName~Avalonia): 1814 passed, 2 skipped, 1 failed (the clipboard test above; 4 of 4 pass in its class alone).build.ps1 -CommentHygiene -TokenHygieneis clean, and the PowerShell 5.1 and 7.0 compatibility check is clean. Re-run on this head:comment-hygiene.ps1andtoken-hygiene.ps1clean;git diff --check origin/main..HEADclean.Docs/migration/baseline-screenshots/are refreshed for the new font.🤖 Generated with Claude Code
This change is