Vixen
dd8b0a81
csharp
public sealed class FontFeatureSet

The OpenType features a run is shaped with, as one comparable value.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

⚠ This exists because of ShapingCache's key, and that is the part of the feature most likely to have shipped broken. The cache is keyed on the font and the string, because shaping is a function of those two — which stopped being true the moment a feature array could differ between two callers. Without the set in the key, the first paragraph shaped wins and every later one gets its glyphs: a table of tabular figures next to a paragraph of proportional ones would silently share whichever was drawn first, and nothing anywhere would say so.

⚠ Sorted and deduplicated on the way in, so two declarations that ask for the same thing in a different order are one cache entry. A later duplicate wins, which is CSS's rule for a repeated <feature-tag-value> and is also what makes font-feature-settings able to override font-variant-numeric: the high-level property's features are added first and the low-level escape hatch's after them.

A reference type with a cached hash, and None is a singleton — so the overwhelmingly common case, text with no features at all, compares by reference and hashes to a constant.

Fields and properties (3)

  • public static readonly FontFeatureSet None

    No features. Shared, so the common case costs no allocation and no walk.

  • public ImmutableArray<FontFeature> Features

    The features, by ascending tag, one entry per tag.

  • public bool IsEmpty

    Whether there are none, which is what almost all text asks for.

Methods (5)

  • public static FontFeatureSet Of(ReadOnlySpan<FontFeature> features)

    Builds a set, sorting and deduplicating.

  • public bool Equals(FontFeatureSet? other)

    Indicates whether the current object is equal to another object of the same type.

  • public override bool Equals(object? obj)

    Determines whether the specified object is equal to the current object.

  • public override int GetHashCode()

    Serves as the default hash function.

  • public override string ToString()

    Returns a string that represents the current object.

Used by (10)

  • ComputedTextVixen.Ui
  • FontFeatureStyleTestsVixen.Ui.Tests
  • FontFeatureTestsVixen.Ui.Text.Tests
  • KeyVixen.Ui.Text
  • NumericFigureVisibilityTestsVixen.Ui.Styling.Utilities.Tests
  • ShapingCacheVixen.Ui.Text
  • TextShaperVixen.Ui.Text
  • UiDocumentVixen.Ui
  • UiElementVixen.Ui
  • UtilityFamilySupportTestsVixen.Editor.Ui.Tests