Skip to content

Allow using TTFLoader in useFont#2303

Draft
mz8i wants to merge 3 commits intopmndrs:masterfrom
mz8i:feature/2094-ttfloader-2
Draft

Allow using TTFLoader in useFont#2303
mz8i wants to merge 3 commits intopmndrs:masterfrom
mz8i:feature/2094-ttfloader-2

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 <antoine.bernier@gmail.com>
To avoid a breaking change, this only uses `TTFLoader` when
the `ttfLoader` argument of `useFont` is set to `true`.
@vercel
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.

@codesandbox-ci
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!

@vercel
Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
drei Ready Ready Preview Comment Oct 7, 2025 6:56am

@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)

@mz8i
Copy link
Contributor Author

mz8i commented Mar 9, 2025

@abernier @CodyJasonBennett would you have any more comments about this PR?

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