interface SdfTrFontFaceOptions {
    atlasDataUrl: string;
    atlasUrl: string;
    descriptors: Partial<TrFontFaceDescriptors>;
    fontFamily: string;
    metrics?: FontMetrics;
    stage: Stage;
}

Hierarchy (view full)

Properties

atlasDataUrl: string
atlasUrl: string
descriptors: Partial<TrFontFaceDescriptors>
fontFamily: string
metrics?: FontMetrics

Font metrics used for layout and default line height calculations.

Provides the font metrics in order to ensure consistent text layout across different font types (Canvas/Web, SDF, etc.).

Important: We HIGHLY recommend providing these metrics for both SDF and Web/Canvas fonts. You can use the Lightning 3 msdf-generator tool to generate these metrics from a font file. The metrics generated by this tool can be used with both SDF and Web/Canvas fonts.

If not provided, a warning will be logged and the text layout may not be consistent across different font types.

If not provided, the metrics will be gathered depending on the font type.

  • For SDF fonts, the metrics will be gathered from the font atlas data. If the font is generated using Lightning 3's msdf-generator tool, the metrics will be the most accurate.
  • For Web/Canvas fonts, the metrics will be gathered from the CanvasRenderingContext2D.measureText() method. The accuracy/consistency of these metrics depends on the browser implementation. And will not guarantee the line-by-line alignment of text with SDF fonts.
stage: Stage