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

Allow using TTFLoader in useFont #2303

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mz8i
Copy link
Contributor

@mz8i mz8i commented Jan 16, 2025

Resolves #2094
(this is a second PR after #2095 got reverted to avoid a breaking change).

In comparison to the previous PR, the code here does not try to automatically determine if TTFLoader should be used.
It is only enabled manually through the second argument to useFont.

Additional considerations:

  • currently there's no option to pass the reversed option to TTFLoader, which is required to correctly parse some font files. Suggestions for the cleanest API here are welcome.
  • I wasn't 100% sure about the correct setup for the preload and clear functions for useFont in the case where useFont has more than one argument.

Why

What

Checklist

  • Documentation updated (example)
  • Storybook entry added (example)
  • Ready to be merged

mz8i and others added 2 commits January 15, 2025 23:49
* Fix useFont example in docs

* Remove unused imports from Text3D

* Use TTFLoader in useFont

* Update documentation for Text3D

* Add story for Text3D using TTFLoader

* ttf font

---------

Co-authored-by: Antoine BERNIER <[email protected]>
To avoid a breaking change, this only uses `TTFLoader` when
the `ttfLoader` argument of `useFont` is set to `true`.
Copy link

vercel bot commented Jan 16, 2025

@mz8i is attempting to deploy a commit to the Poimandres Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

codesandbox-ci bot commented Jan 16, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@mz8i
Copy link
Contributor Author

mz8i commented Jan 16, 2025

@abernier creating this new PR as you suggested in #2095 - any comments to the above points will be appreciated!

Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drei ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 16, 2025 4:49pm

@CodyJasonBennett
Copy link
Member

Why wasn't feature detection in #2095 done by looking at the file extension?

@mz8i
Copy link
Contributor Author

mz8i commented Jan 16, 2025

Originally I thought detecting based on MIME type would be more generic. But I removed the detection anyway - correct me if I'm wrong, but I think any sort of detection would potentially be a breaking change for users who rely on the hook to always apply FontLoader regardless of extension , MIME type etc (and avoiding a breaking change was why the original PR was reverted)

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

Successfully merging this pull request may close these issues.

Allow Text3D to use TTFLoader
2 participants