Skip to content

[WASM] Font preloading support  #693

Closed

Description

@jeromelaban

I'm submitting a...

  • Feature request

Current behavior

Fonts specified as WebFonts do not get loaded synchronously, making TextBlock based control measure their content incorrectly. Loading fonts using a data-uri is not a workaround.

Expected behavior

Fonts are loaded and measured properly.

Possible workaround

This works as a workaround, forcing fonts to load very early in the app's life cycle:

body::after {
    font-family: 'Symbols';
    background: transparent;
    content: "";
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

Environment

Nuget Package: 

Package Version(s): 

Affected platform(s):
- [ ] iOS
- [ ] Android
- [x] WebAssembly
- [ ] Windows
- [ ] Build tasks

Visual Studio
- [ ] 2017 (version: )
- [ ] 2017 Preview (version: )
- [ ] for Mac (version: )

Relevant plugins
- [ ] Resharper (version: )

Activity

  1. added
    kind/enhancement
    platform/wasm 🌐
    on Mar 15, 2019
  2. zipswich commented on Oct 31, 2019

    @zipswich

    image

  3. carldebilly commented on Jan 29, 2021

    @carldebilly
    Member

    FontFace.load() could probably be used to fix this problem.
    Doc: https://developer.mozilla.org/en-US/docs/Web/API/FontFace/load

    The load() method of the FontFace interface loads a font based on current object's constructor-passed requirements, including a location or source buffer, and returns a Promise that resolves with the current FontFace object.
  4. added
    project/text 🔤
    on Jan 29, 2021
  5. added
    difficulty/tbd
    on Feb 15, 2021
  6. added
    difficulty/medium 🤔
    and removed
    difficulty/tbd
    on May 31, 2021
  7. added this to the 3.9 milestone on May 31, 2021
  8. removed this from the 3.9 milestone on Aug 11, 2021
  9. carldebilly commented on Nov 1, 2021

    @carldebilly
    Member

    The FontFaceSet api may also help on this issue.

  10. agneszitte commented on Jun 14, 2022

    @agneszitte
    Member

    @jeromelaban / @carldebilly Interesting article here in my opinion:
    https://nooshu.com/blog/2021/01/23/the-importance-of-font-face-source-order-when-used-with-preload/

    A small change in the ordering of your font sources in the `@font-face` rule can have a big impact on data and web performance, especially when used in conju...
  11. removed their assignment
    on Aug 25, 2022
  12. agneszitte commented on Aug 29, 2022

    @agneszitte
    Member

    (@jeromelaban FYI, there is this item also unoplatform/Uno.Themes#733 to make sure it gets proper priority depending of the need)

  13. jeromelaban commented on Dec 2, 2022

    @jeromelaban
    MemberAuthor

    Available in 4.6

  14. added a commit that references this issue on Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

difficulty/medium 🤔kind/enhancementplatform/wasm 🌐project/text 🔤

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions