-
Notifications
You must be signed in to change notification settings - Fork 138
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
Fallback Font Files #256
Comments
Hi @kalegd, Wha't are your thoughts on those? |
If it needs to be embedded I definitely vote against it. No need to add the bloat for a fallback many users might not need. I'll try to make some time in the coming weeks and sift through the code to see if we could find some sort of non-bloating way to make it work and give a demo if so |
Agreed, but... This would really be great to provide a default/getstarted font for new users. This is one of the very first issue @felixmariotto added #20 // Using `ThreeMeshUI.FontLibrary.prepare( fontFamily, [...fontFamily] )
// We can ensure any fontFamily passed in that function and theirs variants are properly loaded and setup
FontLibrary.prepare(
FontLibrary.addFontFamily("Default").addVariant(400,"normal",
// replace by your own font if needed
"https://cdn.jsdelivr.net/npm/msdf-fonts/build/OpenSans-Regular-msdf.json",
"https://cdn.jsdelivr.net/npm/msdf-fonts/build/OpenSans-Regular-msdf.png" )
).then( () => {
// build blocks and texts...
} charset as additional option in the url? |
I like that idea! I definitely think using an externally hosted font library is easier for new users to onboard vs making their own Font files, and we can revisit if this repo providing a default font is feasible in the future depending on if/how FontLibrary changes over time +1 on adding charset to the url. I'll publish some changes to the msdf-fonts repo for that. What are your thoughts on the following format? {font}-{charset}-msdf.json where {charset} might be
^For charset naming I'm leaning towards using the names for unicode character blocks with allowances for custom character sets for other useful open source projects like this repo |
Sounds great. If I may, if you could also put font variant (weight & style), that would be very useful. not sure about the order thou |
I'm fine with creating directories for organization purposes, but I'll likely maintain all details in the filename in case users decide to download them and host it themselves With that in mind, I've gone ahead with With {weight+style} following the naming convention of the fonts .ttf file. Usually I see something like Can always change this in future versions if needed You can access the fonts that should support all three-mesh-ui examples below. I added a few characters like https://cdn.jsdelivr.net/npm/msdf-fonts/build/custom/three-mesh-ui/roboto/Roboto-Regular-three-mesh-ui-msdf.png Hopefully in a few weeks I'll make a nice general msdf font file with everything you need that's not in the custom folder, but I need to look into some Unicode blocks like the general punctuation block and think about how I want to organize things more before then |
Make perfect sens. So I would avoid repeating information on path too. It would lead to extra long path with no more values. |
Alright, I've removed the redundant folders and also added general msdf files to support all characters that the corresponding .ttf files support. So every character that Roboto supports can be found in https://cdn.jsdelivr.net/npm/msdf-fonts/build/Roboto-Regular-msdf.json + But the character subsets based on unicode blocks are now under a To support all three-mesh-ui examples you could use either the full /build/Roboto-Regular-msdf files (~3.2 MB total) or the custom character set via /build/custom/three-mesh-ui-Roboto-Regular-msdf files (~545 KB) |
Wondering what your thoughts would be on using a default font file for when users don't provide one? I know people usually prefer having full control over dependency version in javascript, but I'd view this more as a fallback than a dependency as such
The text was updated successfully, but these errors were encountered: