Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mini RFC] TextLayer support for pre-packed font atlas #7837

Open
Pessimistress opened this issue Apr 16, 2023 · 1 comment
Open

[Mini RFC] TextLayer support for pre-packed font atlas #7837

Pessimistress opened this issue Apr 16, 2023 · 1 comment
Assignees
Labels

Comments

@Pessimistress
Copy link
Collaborator

Target Use Case

Currently, the TextLayer only supports packing font atlas locally on the client side. Although the process is usually pretty fast (~6ms for the default ascii character set, ~60ms if sdf:true), there are also some limitations:

  • Auto packing relies on CSS font settings, which may silently fail if a web font is not yet loaded or fails to load. Additional steps are required to make it work in the documentation
  • We have observed significant platform-dependent variation when it comes to text rendering, including the handling of baseline position, antialiasing, etc. As of now, TextLayer render tests are disabled because we are unable to get it to work consistently across dev environments.

Proposal

Allow TextLayer to use a pre-packed font atlas.

  • Link to a tool in the documentation to generate and save a font atlas: prototype. A pre-packed font atlas is a JSON consisting:
    • source: the packed image as base64-encoded PNG
    • mapping: the character definitions
    • version: the deck.gl version used to generate the file
    • settings: the font settings used to generate the file
    • attribution: optional font licensing information
  • Add a new prop fontAtlas to TextLayer which points to a statically hosted font atlas. If this prop is supplied, the FontAtlasManager will skip packing and use information from the file instead.
@ibgreen
Copy link
Collaborator

ibgreen commented Apr 16, 2023

Some thoughts:

  • default fonts - it is great that fonts can be generated in advance by users, however it is a somewhat messy step to integrate into an application build workflow. Can we find some fonts whose atlases we can host without getting into license troubles)
  • separate font module (@deck.gl/fonts) or (@luma.gl/fonts) - the fonts functionality getting quite extensive (and overwhelming for someone just looking at the text layer). I feel that the font generation is a great candidate for breaking into a separate module, with a small clean general purpose interface. I think it could even go into luma.gl as it would not need to have any deck dependencies, but even in deck.gl it would make sense to be able to work this functionality separately.

Also, I suspect that there is extensive prior art, perhaps some projects have formats that could be supported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants