Skip to content

LT-22854: Control the Avalonia interface font from the theme - #1196

Merged
jasonleenaylor merged 15 commits into
mainfrom
LT-22854-andika-ui-font
Nov 23, 2026
Merged

jasonleenaylor merged 15 commits into
mainfrom
LT-22854-andika-ui-font

Conversation

@johnml1135

@johnml1135 johnml1135 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Start here: Src/Common/FwAvalonia/FwUiFont.cs selects the application-wide interface font stack from the theme and startup UI language.

Segoe UI is the default on Windows to preserve the density of the current interface. The stack adds named script fallbacks for the installer UI languages and ends with the platform default. The bundled Andika collection remains private; writing-system data continues to use its writing-system font.

The interface font is selected once for the application, so menus do not change with the open project. The UiElement style continues to govern UI-writing-system text drawn in Views; it does not set Avalonia chrome. The question for review is whether the chosen families cover the supported installations without clipping or missing glyphs.

Where to look

  • FwColorTokens.axaml and ADR 0004: Segoe UI density and the app-wide decision.
  • FwUiFont.FallbacksByLanguage: ordered Windows and SIL/Noto families.
  • FwUiFontTests: ordered family selection and sample shaping for the installer languages.

Not here: project-specific Avalonia interface fonts and line-height tokens. The nine dialog screenshots under Docs/migration/baseline-screenshots/ are regenerated with Segoe UI.

Verification (Windows/x64, at the font commit before a comment-only rewrap):

  • .\build.ps1 -CommentHygiene -TokenHygiene: passed. Comment hygiene passes at the head.
  • FwAvaloniaTests: 973 passed, 1 skipped, including all FwUiFontTests (ordered fallbacks for 14 languages and the sample-shaping cases).
  • FwAvaloniaDialogsTests: 289 passed. LexTextControlsTests (Avalonia): 42 passed.
  • Not run: the full test.ps1, and a live density and clipping check at other DPI settings.

Next: review the refreshed screenshots and the fallback table.


Fallbacks and evidence

The prior ADR recorded Andika's 1.61 em line metric against 1.33 em for Segoe UI. Line-height tokens remain deferred. The added cases cover ar, bn, km, ml, my, ne, ta, th and ur. Sample character maps were inspected in locally installed Windows font files, but that does not prove shaping or availability on every supported Windows installation. Khmer UI was not installed on the test machine, so Khmer falls through to Noto Sans Khmer or the platform default there; its family name is not verified against Microsoft's documentation.

🤖 Generated with Claude Code


This change is Reviewable

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

NUnit Tests

    1 files  ± 0      1 suites  ±0   8m 0s ⏱️ - 6m 57s
7 356 tests +53  7 277 ✅ +53  79 💤 ±0  0 ❌ ±0 
7 365 runs  +53  7 286 ✅ +53  79 💤 ±0  0 ❌ ±0 

Results for commit afa1600. ± Comparison against base commit fae5de0.

♻️ This comment has been updated with latest results.

@codecov-commenter

codecov-commenter commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.56701% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.35%. Comparing base (fae5de0) to head (afa1600).

Files with missing lines Patch % Lines
Src/xWorks/Avalonia/Composer/DetailComposer.cs 65.78% 8 Missing and 5 partials ⚠️
Src/Common/FwAvalonia/FwUiFont.cs 97.77% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1196      +/-   ##
==========================================
+ Coverage   40.34%   40.35%   +0.01%     
==========================================
  Files        1597     1598       +1     
  Lines      360082   360176      +94     
  Branches    42148    42163      +15     
==========================================
+ Hits       145282   145365      +83     
- Misses     185121   185128       +7     
- Partials    29679    29683       +4     
Files with missing lines Coverage Δ
Src/Common/FwAvalonia/Detail/DataTree.cs 91.82% <100.00%> (+0.07%) ⬆️
Src/Common/FwAvalonia/Detail/DetailModel.cs 79.32% <ø> (ø)
...rc/Common/FwAvalonia/Detail/DetailSectionHeader.cs 96.46% <100.00%> (+0.06%) ⬆️
Src/Common/FwAvalonia/Detail/FwFieldControls.cs 88.32% <100.00%> (ø)
Src/Common/FwAvalonia/FwAvaloniaApp.cs 83.33% <100.00%> (+0.98%) ⬆️
Src/Common/FwAvalonia/FwThemeResources.cs 69.23% <100.00%> (+2.56%) ⬆️
.../Common/FwAvaloniaTheme/Tokens/FwColorTokens.axaml 100.00% <100.00%> (ø)
...c/xWorks/Avalonia/Composer/NormalStyleFontSizes.cs 92.85% <100.00%> (+0.17%) ⬆️
Src/Common/FwAvalonia/FwUiFont.cs 97.77% <97.77%> (ø)
Src/xWorks/Avalonia/Composer/DetailComposer.cs 75.65% <65.78%> (-0.17%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@johnml1135
johnml1135 force-pushed the LT-22854-andika-ui-font branch from f5874ae to 0921803 Compare October 23, 2026 11:29
@jasonleenaylor

Copy link
Copy Markdown
Contributor

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 jasonleenaylor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone a different way on UiElement, deliberately. The interface font is chosen once at startup, from the theme and the UI language, and applies to the whole application. UiElement is a project style, so wiring it into Avalonia chrome would make menus and dialogs change font with whichever project is open. Avalonia's font resources are also application-wide, so a second project window would change the first. UiElement keeps its current job, UI-writing-system text drawn in Views, and writing-system text still uses its writing-system fonts. ADR 0004 records the decision.

The missing languages are fixed in c276827: ar, bn, km, ml, my, ne, ta, th and ur now have ordered fallbacks (Windows UI font first, then an SIL or Noto font, then the platform default). FwUiFontTests asserts the order for all 14 languages and shapes a sample for each. Those tests pass on Windows.

Larger text for users with limited vision isn't handled here. If it's needed, I'd make it an application-wide user setting rather than a project style.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm holding to this one, scoped to the text that has followed UiElement until now rather than menus and dialog controls. For FieldWorks users, UiElement is the documented way to control interface text in data entry views: support has pointed users to it for field labels and Entries column dropdowns (LT-21445, LT-20368), and the 2008 work in LT-8084/LT-8611 deliberately gave every project the definitions for the UI writing system so that text takes its font from the project. Those surfaces are the ones moving to Avalonia, and with a fixed font, users lose a control they have been told to use. An application-wide font for menus and dialog controls is fine (that matches LT-10805). Multiple project windows look like a scoping problem rather than a blocker: Avalonia looks up resources through a control's own window before the application, so it may be possible to set the UiElement font for each project window rather than for the whole application.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In bb9d5a2, the section headings in the data-entry view (the UiElement runs in the *-Jt-Summary parts) take the font that the project's UiElement style gives the UI writing system. DetailComposer reads the font and DetailModel carries it, so each project window has its own. Menus, dialogs and field labels stay on the theme font: slice labels have always been a fixed 10 pt sans serif (Slice.cs:80), and nothing in the label code reads UiElement. If you meant a label case that does follow UiElement (LT-21445 / LT-20368?), tell me which one. Making labels follow it would be new behaviour, not something we keep.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LT-21445 settles the "labels" question: Ken's labels are the section headings drawn by Views (his example, "Publication Settings", is a LiteralLabelVc heading). Here is every place WinForms applies UiElement, and where each one stands:

Text WinForms Avalonia in this PR
Data-entry section headings ("Sense 1", "Etymology", "Publication Settings") UiElement (SummarySlice / FwBaseVc.MakeUiElementString) UiElement font for the UI writing system, separate in each project window (249c2d4; dd67129 pins "Publication Settings" with a test)
Data-entry field labels ("Lexeme Form", "Gloss") Fixed 10 pt sans serif (Slice.cs:80); never UiElement Theme font
Entries column filter dropdowns UiElement (FilterBar.cs:926-931) Not in Avalonia yet; ADR 0004 says they take UiElement when the filter bar moves
Interlinear text labels and writing-system tags UiElement (InterlinVc, WsListManager.cs:298) Not in Avalonia yet; ADR 0004 says the same for them (dd67129)
Menus, dialogs, buttons Windows default font Theme font for the whole application (matches LT-10805)

@johnml1135

Copy link
Copy Markdown
Contributor Author

On density: the default is Segoe UI again, so line height is back to today's 1.33 em. Line-height tokens are still deferred. The nine dialog screenshots under Docs/migration/baseline-screenshots/ are regenerated with Segoe UI. Build, FwAvaloniaTests, FwAvaloniaDialogsTests and the Avalonia LexTextControlsTests pass on Windows. I haven't checked clipping at other DPI settings.

johnml1135 and others added 7 commits November 3, 2026 11:28
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>
Nine committed screenshots still showed the old Andika interface font.
Regenerate exactly those nine by running the Avalonia dialog tests and
copying the captures from Output/Snapshots, as the visual snapshot
testing guide describes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@johnml1135
johnml1135 force-pushed the LT-22854-andika-ui-font branch from c276827 to 4b07e88 Compare November 3, 2026 16:58

@jasonleenaylor jasonleenaylor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for restoring Segoe UI and for the fallbacks. I checked both at this head: the density is back, and all 14 shipped non-Latin locales have a fallback with a test each. I've replied in the UiElement thread, and there are three smaller points inline.

This review was assisted by Claude Opus 5.5.

<!-- Andika 7.000 plus its licence and notice, so the OFL text travels inside the assembly
with the font. Registered at startup by FwUiFont as the "fonts:FieldWorks" collection.
-->
<AvaloniaResource Include="Assets\Fonts\*.ttf;Assets\Fonts\OFL.txt;Assets\Fonts\NOTICE.txt" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Segoe UI as the default, is Andika staying for a planned use, such as a theme that selects it? Right now the five faces (about 4 MB) are embedded in FwAvaloniaTheme.dll and registered by FwUiFont, but nothing outside FwUiFontTests uses them. If there's no planned use, I'd remove the fonts, the registration, the tests that exercise them, and the acknowledgment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 5ee55a9: the Andika faces, their licence files, the FwUiFont registration, the tests that used them and the acknowledgments entry. Nothing outside FwUiFontTests used them. The installer's separate Andika package is unchanged.

for writing-system data.

Windows validation must measure density, clipping and script glyph fallback.
Screenshot baselines still depict Andika and must be refreshed on Windows.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is out of date: the baselines were regenerated with Segoe UI. More broadly, the trim in 5d9fb5c left the ADR saying what the code does but not why. Could you add back a few lines of why and revisit-when: Segoe UI for density, why the fallbacks are named, and why Andika stays bundled (or not, per the csproj comment)? The UiElement paragraph may change depending on that thread.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in bb9d5a2. The reference-images line now says Segoe UI. The ADR now also gives why Segoe UI, why the fallbacks are named, why Andika was removed and when to look at it again, and which text follows UiElement.

== "AddNewSense.Gloss." + wsTag);

[AvaloniaTest]
public void DialogText_UsesTheAndikaInterfaceFont()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This asserts FwUiFont.UiFontFamily, which is Segoe UI by default now. Rename it to something like DialogText_UsesTheInterfaceFont.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to DialogText_UsesTheInterfaceFont in 83f21ce. No other test used the old Andika name.

johnml1135 and others added 4 commits November 9, 2026 11:41
Nothing outside FwUiFontTests used the five embedded faces now that
Segoe UI is the default. Drop the fonts, their licence files, the
AvaloniaResource item, the collection registration in FwUiFont, the
tests that exercised them and the acknowledgments entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test asserts FwUiFont.UiFontFamily, which is Segoe UI by default,
so the Andika in its name was stale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Section headings follow the UiElement style in the WinForms detail
view, so the composer now reads the style's font for the UI writing
system and the Avalonia DataTree draws headings in it. The model carries
it, so each project window has its own. Menus, dialogs and field labels
stay on the theme font, as no UiElement text exists there today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fix the out-of-date line about the reference images and add the
reasons: Segoe UI for density, why the fallbacks are named, and why
Andika was removed. State which text follows the UiElement style.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

A LiteralString summary part such as Publication Settings composes as
a header row, which the data tree already draws in the UiElement
font; a composer test now pins that. ADR 0004 also says the
interlinear text view's labels and writing-system tags take UiElement
when that view moves to Avalonia.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jasonleenaylor and others added 3 commits November 19, 2026 11:07
DetailModel and DetailComposer conflicted with LT-22811 (#1236), which
gave the model a ValueFontSize. Both are kept: the composer passes the
Normal style size to the constructor and sets the UiElement font.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the WinForms detail view the section headings take the UiElement
style's size as well as its font, so a user who enlarges UiElement in
Format > Styles gets larger headings. The composer now also reads the
style's size for the UI writing system, falling back to its size for
all writing systems, and the DataTree draws headings at it. With no
size set, headings stay at the theme size. Field labels are unchanged,
as they never followed UiElement. ADR 0004 now says font and size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pin test for the Lexicon Edit menus assumed the entry's relation rows
come in a fixed order. liblcm returns LexEntryReferences from a hash-based
bag, so the order follows object identity hashes and changes with the
objects earlier tests create. Both the WinForms and the Avalonia detail
view show the relations in that order.

Sort the relation rows by label before comparing them with the pin. The
pinned list itself does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jasonleenaylor jasonleenaylor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I merged main and pushed two commits on top: section headings now take the UiElement size as well as its font (e75a58b), and main's Lexicon menu pin test now compares the relation rows by label (afa1600). liblcm returns LexEntryReferences in no defined order, and the new font tests changed which order CI saw.

This review was assisted by Claude Opus 5.5.

@jasonleenaylor
jasonleenaylor merged commit b1e369b into main Nov 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants