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

Feature: preloader function for fonts and SDF generation #39

Closed
lojjic opened this issue Apr 19, 2020 · 0 comments
Closed

Feature: preloader function for fonts and SDF generation #39

lojjic opened this issue Apr 19, 2020 · 0 comments

Comments

@lojjic
Copy link
Collaborator

lojjic commented Apr 19, 2020

Font download and SDF generation is currently lazy, waiting until a TextMesh is first created and sync()-ed. This can cause a noticeable period of blankness when a scene is first rendered.

We should add a function that users can call to preload a font and optionally generate SDF for a set of initial glyphs. It would take a callback that is invoked when the font file is loaded, parsed, and the SDFs are ready. It would then be ready for TextMeshes to use without any noticeable delay.

Proposal:

import {preloadFont} from 'troika-3d-text'
showLoadingScreen()
preloadFont('path/to/font.woff', 'abcdefghijklmnopqrstuvwxyz', () => {
  showScene()
})
lojjic added a commit that referenced this issue Apr 20, 2020
This allows preloading of font files and optional pregeneration of glyph
SDFs for sets of characters. Closes issue #39. Also added some timings
to the font processor result.
@lojjic lojjic closed this as completed Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant