Vixen
02b45cc4
csharp
public sealed class FontFace

One loaded font, ready to shape with.

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

Remarks

The font is held at design-unit scale and never at a pixel size. That is a decision worth stating: HarfBuzz's OpenType path has no hinting and no size-specific behaviour, so shaping the same string at 12pt and at 48pt produces the same glyphs at proportional positions. Keeping the scale at units-per-em makes that identity explicit, and it makes the shaping cache size-independent — one entry serves every size the same string is drawn at, which for a UI redrawing at several DPI scales is most of them.

The caller multiplies by size / UnitsPerEm at layout time. Anything that later needs size-dependent shaping — optical sizing through a variable axis, say — sets the axis rather than the scale, and would want a separate face.

Not thread-safe. HarfBuzz's hb_font_t is mutable and shaping writes to it, so a face is used from one thread at a time; parallel layout gets a face per worker.

Fields and properties (8)

  • public string Name

    What to call this face in a diagnostic.

  • public int UnitsPerEm

    The font's design grid — the unit every position out of shaping is in.

  • public int GlyphCount

    How many glyphs the font has.

  • public FontMetrics Metrics

    The horizontal metrics.

  • public bool HasOutlines

    Whether this face stores outlines in a format Vixen can read.

  • public ImmutableArray<FontAxis> Axes

    The axes this font can be instanced along, in its own order.

  • public bool IsVariable

    Whether the font has axes at all.

  • public FontVariation Instance

    Which instance the shaper is currently set to.

Methods (9)

  • public static FontFace Load(byte[] data, int index = 0, string? name = null)

    Loads a font from the bytes of an sfnt file.

  • public ushort GlyphFor(int codePoint)

    The glyph a code point maps to through the font's cmap.

  • public bool Supports(int codePoint)

    Whether the font can draw a code point at all.

  • public string GlyphName(ushort glyphId)

    The name of a glyph, for a diagnostic or a golden test.

  • public bool TryGetGlyphExtents(ushort glyphId, out GlyphBounds bounds)

    The box a glyph occupies, as the font itself reports it.

  • public GlyphOutline GetOutline(ushort glyphId, FontVariation? variation = null)

    A glyph's contours, in design units.

  • public void SetInstance(FontVariation? variation)

    Points the shaper at one instance of a variable font.

  • public FontVariation Variation(IReadOnlyDictionary<string, float> values)

    Turns a set of user-space axis values into a position this face can be read at.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (42, showing 40)

  • FontsHelloUi
  • AdvancedFixtureVixen.Ui.Controls.Advanced.Tests
  • ControlFixtureVixen.Ui.Controls.Tests
  • ControlHarnessVixen.Ui.Controls.Tests
  • DistanceFieldTestsVixen.Ui.Text.Tests
  • DrawListVixen.Ui
  • FontFallbackTestsVixen.Ui.Tests
  • FontRegistryVixen.Ui
  • FontRegistryTestsVixen.Ui.Tests
  • FontSpanVixen.Ui
  • FontVariantVixen.Ui
  • FontVariationTestsVixen.Ui.Text.Tests
  • GlyphAtlasTestsVixen.Ui.Text.Tests
  • GlyphFieldCacheVixen.Ui.Text
  • GlyphFieldCacheTestsVixen.Ui.Text.Tests
  • KeyVixen.Ui.Text
  • LineWrapTestsVixen.Ui.Text.Tests
  • OutlineTestsVixen.Ui.Text.Tests
  • RasterizerTestsVixen.Ui.Testing.Tests
  • RasterizerTestsVixen.Ui.Text.Tests
  • ShapedRunVixen.Ui.Text
  • ShapingCacheVixen.Ui.Text
  • ShapingCacheTestsVixen.Ui.Text.Tests
  • ShapingConformanceTestsVixen.Ui.Text.Tests
  • ShapingTestsVixen.Ui.Text.Tests
  • TestFontsVixen.Ui.Text.Tests
  • TextRunVixen.Ui
  • TextShaperVixen.Ui.Text
  • TextTestsVixen.Ui.Tests
  • TextWrapTestsVixen.Ui.Tests
  • UiElementVixen.Ui
  • UiGeometryBuilderVixen.Ui
  • UiGeometryTestsVixen.Ui.Tests
  • UiImageTestsVixen.Graphics.Golden.Tests
  • VariationConformanceTestsVixen.Ui.Text.Tests
  • ChromeFixtureVixen.Editor.Ui.Tests
  • FontAtlasViewVixen.Editor.AssetEditors
  • FontDocumentVixen.Editor.AssetEditors
  • FontViewVixen.Editor.AssetEditors
  • FontsVixen.Editor.App