Skip to content

Consider performing font fallback analysis only if the chosen font is not adequate #10858

@skyline75489

Description

@skyline75489

Description of the new feature/enhancement

Right now the _AnalyzeFontFallback is always called if the text is "complex":

// Perform our custom font fallback analyzer that mimics the pattern of the real analyzers.
RETURN_IF_FAILED(_AnalyzeFontFallback(this, 0, textLength));

We already know that even for pure ASCII characters, some fonts will treat them as "complex". But the real need for font fallback emerges only when the font don't actually contains the needed glyph. For example when dealing with "ABC中文". You have to find "Microsoft YaHei" as fallback, otherwise "中文" is nowhere to be find in "Cascadia Code“.

Proposed technical implementation details (optional)

To avoid the unnecessary overhead of finding fallbacks (MapCharacters, which is relatively expensive), my proposed solution is to delay the fallback analysis and put it in _ShapeGlyphRun. Inside _ShapeGlyphRun, the method GetGlyphs will tell you precisely if there are available glyphs inside the desired font (_glyphIndices):

hr = _fontRenderData->Analyzer()->GetGlyphs(

If no glyphs can be found (which I assume is a rather rare case), then the fallback analysis is necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-PerformancePerformance-related issueArea-RenderingText rendering, emoji, complex glyph & font-fallback issuesIssue-TaskIt's a feature request, but it doesn't really need a major design.Product-TerminalThe new Windows Terminal.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions