Skip to content

Fix LT-22351: OpenType/Graphite font features from style defaults now reach Dictionary Preview#1005

Draft
johnml1135 wants to merge 4 commits into
mainfrom
LT-22351
Draft

Fix LT-22351: OpenType/Graphite font features from style defaults now reach Dictionary Preview#1005
johnml1135 wants to merge 4 commits into
mainfrom
LT-22351

Conversation

@johnml1135

@johnml1135 johnml1135 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Root cause

liblcm's BaseStyleInfo.ProcessStyleRules dropped a style's default ktptFontVariations (OpenType/Graphite font features) when loading from persisted Rules (sillsdev/liblcm#388). FieldWorks' StyleInfo had a compensating adapter, so Data Entry was unaffected — but Dictionary Preview CSS generation (CssGenerator.GenerateCssStyleFromLcmStyleSheetAddFontInfoCss) reads plain BaseStyleInfo straight out of LcmStyleSheet, bypassing the adapter, so font-feature-settings never reached the generated preview CSS.

Depends on liblcm #388 — do not merge until a liblcm release containing it is published and Build/SilVersions.props is bumped to that version (currently pinned to 11.0.0-beta0173, which predates the fix).

What changed

  • Removed the StyleInfo.LoadDefaultFontFeatures compatibility adapter (Src/FwCoreDlgs/FwCoreDlgControls/StyleInfo.cs) now that liblcm loads default font features itself.
  • Added regression tests through the real BaseStyleInfo/IStStyle path (not the TestStyle double) for: Dictionary Preview CSS, CSS precedence (a style's own features beat the writing system's fallback), and the equivalent Word-export path.
  • Updated the add-opentype-font-features openspec docs, which still described the removed adapter as load-bearing.

Why CI is red right now

This is expected, not a regression — every failure here traces back to the same cause:

Check Status Why
Check commit messages ✅ fixed 3 commit titles exceeded 72 chars; reworded, force-pushed
5 NUnit tests (SaveToDB_DefaultFontFeatures_RoundTripsThroughRules, 2×CssGenerator*, 2×LcmWordGenerator*) ❌ still failing All assert the fixed behavior, but CI resolves liblcm 11.0.0-beta0173 — before #388's fix — so features are still silently dropped in this run. They pass locally against a repacked liblcm build with the fix.

These tests will go green on their own once liblcm #388 merges, a release publishes to nuget.org, and Build/SilVersions.props is bumped to reference it — no FieldWorks-side code change needed.

JIRA

LT-22324 partially implements → LT-22351

🤖 Generated with Claude Code


This change is Reviewable

liblcm's BaseStyleInfo.ProcessStyleRules previously dropped a style's
default ktptFontVariations (font features) when loading from persisted
Rules (sillsdev/liblcm#388). FieldWorks compensated for this in the Styles
dialog only, via StyleInfo.LoadDefaultFontFeatures, which manually rescanned
style.Rules for ktptFontVariations after calling the base constructor. The
Dictionary Preview CSS path (CssGenerator.GenerateCssStyleFromLcmStyleSheet
-> AddFontInfoCss) never went through StyleInfo -- it reads plain
BaseStyleInfo objects straight out of LcmStyleSheet -- so it had no such
adapter and silently lost default font features, meaning
font-feature-settings never reached the generated preview CSS.

Now that liblcm loads default font features itself, remove the
FieldWorks-side adapter and let StyleInfo(IStStyle) rely entirely on
BaseStyleInfo.ProcessStyleRules, as the LT-22324 design doc intended once
the round-trip test passed through the authoritative liblcm path.

Add a CssGenerator regression test that builds a style the way
LcmStyleSheet does in production (a real IStStyle with persisted Rules,
wrapped in BaseStyleInfo -- not a TestStyle double with an in-memory
ExplicitValue) and asserts that default font features reach the generated
CSS end-to-end.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@johnml1135

Copy link
Copy Markdown
Contributor Author

Note: CI on this PR is expected to be red until sillsdev/liblcm#388 is released and Build/SilVersions.props is bumped. The committed SilVersions.props still pins upstream 11.0.0-beta0173, which lacks the liblcm fix, so both the pre-existing gate test (SaveToDB_DefaultFontFeatures_RoundTripsThroughRules) and the new CssGenerator regression test in this PR will fail against that pin in CI. This is the expected pre-release state, not a broken branch -- see the DO NOT MERGE note above.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

NUnit Tests

    1 files  ±0      1 suites  ±0   10m 24s ⏱️ + 3m 34s
4 306 tests +4  4 228 ✅  - 1  73 💤 ±0  5 ❌ +5 
4 315 runs  +4  4 237 ✅  - 1  73 💤 ±0  5 ❌ +5 

For more details on these failures, see this check.

Results for commit 5bc3727. ± Comparison against base commit f505729.

♻️ This comment has been updated with latest results.

johnml1135 and others added 3 commits July 10, 2026 17:39
Review follow-ups on the LT-22351 branch:

- Widen SafelyAddStyleToSheetAndTable to accept BaseStyleInfo (both
  collections it touches already store BaseStyleInfo) and add a matching
  SafelyRemoveStyleFromSheetAndTable helper.
- The persisted-Rules preview test now uses those helpers and removes its
  style in a finally block: m_styleSheet is per-fixture but the base class
  undoes all data changes per test, so leaving a BaseStyleInfo wrapping a
  real IStStyle behind would strand a stale entry with a dead RealStyle
  that can crash later tests order-dependently.
- Add GenerateCssForConfiguration_NormalStyleOwnFontFeatures_
  BeatWritingSystemDefaultFontFeatures: now that liblcm loads a style's
  own default ktptFontVariations from persisted Rules (sillsdev/liblcm#388),
  a Normal style WITH its own features must win over the writing system's
  DefaultFontFeatures fallback in AddFontInfoCss; the existing sibling test
  only covered Normal WITHOUT its own features.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The Word export path (WordStylesGenerator.AddFontInfoWordStyles) has the
same precedence logic as the CSS path but had no coverage through the
authoritative liblcm load path: the existing typography test used a
TestStyle double with an in-memory ExplicitValue (bypassing
BaseStyleInfo.ProcessStyleRules) and the existing Normal-style test only
covered the writing-system DefaultFontFeatures fallback branch.

Add two tests mirroring the CSS-side coverage:

- GenerateCharacterStyleFromLcmStyleSheet_DefaultFontFeaturesFromPersisted
  StyleRules_AddsWordTypographyProperties: a real IStStyle whose persisted
  Rules carry ktptFontVariations, wrapped in a plain BaseStyleInfo the way
  LcmStyleSheet does in production, produces the expected w14 typography
  properties (sillsdev/liblcm#388).
- GenerateCharacterStyleFromLcmStyleSheet_NormalStyleOwnFontFeatures_Beat
  WritingSystemDefaultFontFeatures: a Normal style with its own persisted
  features wins over the WS DefaultFontFeatures fallback (font family
  still falls back to the WS default font).

Both tests clean up in finally blocks so no stale entry wrapping an
undone IStStyle is left in the fixture-lifetime stylesheet.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
design.md Decision 11, proposal.md, and research.md still described
StyleInfo.LoadDefaultFontFeatures as an existing, load-bearing
compatibility adapter. Update those passages to record that the adapter
was removed under LT-22351 once liblcm's BaseStyleInfo.ProcessStyleRules
gained the ktptFontVariations case (sillsdev/liblcm#388) and the Decision
11 gating condition (SaveToDB_DefaultFontFeatures_RoundTripsThroughRules
passing through the authoritative path) was satisfied. Surgical wording
updates only; no restructuring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

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.

2 participants