Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Docs/opentype-font-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ FieldWorks stores font options as renderer-neutral feature strings such as `smcp

In the current WinForms UI, use the Font Options button in font controls to choose the configurable features exposed by the selected font. Graphite remains available for now, but the Font Options UI is no longer limited to Graphite fonts.

## Feature names and values

Feature labels are resolved in order: the name the font supplies for a stylistic set (`ssXX`) or character variant (`cvXX`) via its GSUB `featureParams` and `name` table; a localized name from `FwCoreDlgControls.resx`; the English name from the registered-feature catalog; and finally a `Stylistic Set N` / `Character Variant N` / `Feature #<tag>` fallback. Labels show the name only, matching the Graphite presentation; four-character tags appear only in the last-resort fallback. `OpenTypeFontFeatureInfoReader` in `FwUtils` reads this information from GSUB and GPOS through a table-source delegate (GDI `GetFontData` in the app, font-file bytes in tests) and degrades to a tag-only record if a table is malformed.

A character variant that names its options is presented as a multi-valued submenu — `None` plus each named option — and stored as `cv43=2`, where the value is the 1-based option index. Character variants and stylistic sets without font-supplied strings fall back to an on/off toggle.

`OpenTypeFeatureCatalog` in `FwUtils` classifies registered features. Features it marks hidden (shaping-required features such as `mark`, `ccmp`, `init`; and glyph-palette features such as `aalt`) are discovered but not shown as toggles. Features it marks default-on (`liga`, `clig`, `calt`, `kern`) display as enabled when the stored feature string does not mention them; the string gains an explicit `tag=0` only when the user turns such a feature off. Unset features are never written.

Graphite feature IDs are still converted only at the Graphite renderer boundary. OpenType feature tags stay as four-character tags and are passed to the Uniscribe OpenType path when Graphite is not enabled.

For export, CSS output maps these values to `font-feature-settings`, and Notebook export preserves writing-system default font features in `DefaultFontFeatures`.
Expand Down
15 changes: 15 additions & 0 deletions Src/Common/FwUtils/FwUtilsTests/FwUtilsTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,19 @@
<ProjectReference Include="../../ViewsInterfaces/ViewsInterfaces.csproj" />
<ProjectReference Include="../FwUtils.csproj" />
</ItemGroup>

<!-- Charis SIL test font: downloaded (not committed) by Build/PackageRestore.targets into
Downloads/CharisSIL; copied beside the test assembly so OpenTypeFontFeatureInfoReader tests
can slice its tables privately. Keep CharisSilTestFontVersion in sync with CharisSilVersion
in Build/PackageRestore.targets (see also Src/views/Test/TestViews.vcxproj). LT-22638. -->
<PropertyGroup>
<CharisSilTestFontVersion>6.200</CharisSilTestFontVersion>
<CharisSilTestFontPath>$(FwRoot)\Downloads\CharisSIL\CharisSIL-$(CharisSilTestFontVersion)\CharisSIL-Regular.ttf</CharisSilTestFontPath>
</PropertyGroup>
<Target Name="CopyCharisSilTestFont" AfterTargets="Build">
<Copy SourceFiles="$(CharisSilTestFontPath)"
DestinationFolder="$(OutDir)TestData\Fonts\CharisSIL"
SkipUnchangedFiles="true"
Condition="Exists('$(CharisSilTestFontPath)')" />
</Target>
</Project>
73 changes: 73 additions & 0 deletions Src/Common/FwUtils/FwUtilsTests/OpenTypeFeatureCatalogTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) 2026 SIL International
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)

using System.Linq;
using NUnit.Framework;

namespace SIL.FieldWorks.Common.FwUtils
{
[TestFixture]
public class OpenTypeFeatureCatalogTests
{
// The exact set the pre-LT-22638 FontFeaturesButton hid via its s_nonUserConfigurableTags
// blocklist. Every one must stay hidden so the catalog does not un-hide shaping features.
private static readonly string[] LegacyBlocklist =
{
"abvf", "abvm", "abvs", "akhn", "blwf", "blwm", "blws", "ccmp",
"cjct", "curs", "dist", "fina", "haln", "half", "init", "isol",
"ljmo", "locl", "mark", "medi", "mkmk", "nukt", "pref", "pres",
"pstf", "psts", "rclt", "rkrf", "rlig", "tjmo", "vjmo"
};

[Test]
public void LegacyBlocklistTags_AreAllHidden()
{
foreach (var tag in LegacyBlocklist)
{
Assert.That(OpenTypeFeatureCatalog.IsKnown(tag), Is.True, $"'{tag}' should be catalogued");
Assert.That(OpenTypeFeatureCatalog.IsHidden(tag), Is.True, $"'{tag}' should remain hidden");
}
}

[Test]
public void DiscretionaryLigatures_AreUserVisible()
{
// Audit correction: Paratext hides dlig, but it is the canonical user-facing ligature feature.
Assert.That(OpenTypeFeatureCatalog.IsHidden("dlig"), Is.False);
}

[Test]
public void AccessAllAlternates_IsHidden()
{
// Audit correction: aalt is a glyph palette, not a meaningful on/off toggle.
Assert.That(OpenTypeFeatureCatalog.IsHidden("aalt"), Is.True);
}

[TestCase("liga")]
[TestCase("clig")]
[TestCase("calt")]
[TestCase("kern")]
public void CommonlyDefaultOnFeatures_AreDefaultOn(string tag)
{
Assert.That(OpenTypeFeatureCatalog.IsHidden(tag), Is.False);
Assert.That(OpenTypeFeatureCatalog.IsDefaultOn(tag), Is.True);
}

[Test]
public void UnknownTag_IsNeitherKnownNorHidden()
{
Assert.That(OpenTypeFeatureCatalog.IsKnown("zzzz"), Is.False);
Assert.That(OpenTypeFeatureCatalog.IsHidden("zzzz"), Is.False);
Assert.That(OpenTypeFeatureCatalog.GetEnglishName("zzzz"), Is.Null);
}

[Test]
public void VisibleFeatures_HaveEnglishNames()
{
foreach (var tag in OpenTypeFeatureCatalog.AllTags.Where(t => !OpenTypeFeatureCatalog.IsHidden(t)))
Assert.That(OpenTypeFeatureCatalog.GetEnglishName(tag), Is.Not.Null.And.Not.Empty,
$"visible feature '{tag}' needs a friendly name");
}
}
}
Loading
Loading