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

Font Library: Export fonts on theme export #54226

Open
Tracked by #60528
matiasbenedetto opened this issue Sep 6, 2023 · 7 comments
Open
Tracked by #60528

Font Library: Export fonts on theme export #54226

matiasbenedetto opened this issue Sep 6, 2023 · 7 comments
Labels
[Feature] Font Library [Feature] Typography Font and typography-related issues and PRs [Type] Enhancement A suggestion for improvement.

Comments

@matiasbenedetto
Copy link
Contributor

matiasbenedetto commented Sep 6, 2023

What?

  • Add the fonts activated with the font library to the exported theme zip.
  • Set the right font asset source in theme.json

image

@jffng
Copy link
Contributor

jffng commented Dec 11, 2023

  • Add the fonts activated with the font library to the exported theme zip.
  • Set the right font asset source in theme.json

I am not sure if we should do this. I think my preference is to enhance Create Block Theme to handle it: WordPress/create-block-theme#451.

Font Library is designed so that installed fonts are treated more like Media and are theme agnostic — hence the default install location is in wp-content/fonts, not in the theme assets. To make the theme export work with fonts across sites, we'd have to move the fonts inside the theme, and then overwrite each font face's src property with a relative file path in theme.json. This would mean adding some typography specific processing of theme.json, to the current export functionality. There's no precedence for this.

Also a font face src can be a remote host — how would we know when to move the font to the theme assets and rewrite the src, vs leaving the src untouched? We could perform a string comparison to see if the src contains the domain of the current site, and do a replacement with file:/, but that also doesn't seem ideal for the native export functionality which is currently just a dump of the existing templates and styles.

@pbking
Copy link
Contributor

pbking commented Dec 11, 2023

I think it's good to bring up the Media Library, I do think it's related.

Patterns are an integral part of a theme and the patterns that are created in the Site Editor reference assets in the Media Library. Whatever fate befalls the fonts will also befall this media: Either it will be exported with a theme or it won't. You're right in that the assets are managed in the same way.

Ultimately, CBT will be complete when Core/Gutenberg does all the things and CBT can be sunset. Part of that goal is that when a theme is exported the relevant media elements are exported too. If we do it in CBT it is bound for Core anyway. Doing it now will help inform how other relevant media assets are exported and this seems a simple thing to implement and a good time to do it. However if it's better to defer this and experiment to get it right then I hope we can still target the same timeline, wherever the code changes happen.

Regarding fonts from remote hosts, I think that in all instances the result should be the same. A font stored in the theme.zip file and referenced locally. However it's stored in the instance.

@jffng
Copy link
Contributor

jffng commented Dec 11, 2023

Doing it now will help inform how other relevant media assets are exported and this seems a simple thing to implement and a good time to do it.

👍

@creativecoder
Copy link
Contributor

WordPress has been lacking in export features for a long time, and this issue with fonts seems to fall right in line with that problem. At the end of the day, if I export a theme, I want everything that's a part of that theme in the export, including media that's part of patterns and any fonts I use in the templates and styles.

For me, the question is simply how to implement better export functionality. I think experimenting with font export in Gutenberg's theme zip would be a useful starting point to lead the way.

@mikachan
Copy link
Member

I am not sure if we should do this. I think my preference is to enhance Create Block Theme to handle it

I understand why adding this functionality to Create Block Theme may currently feel like the better approach, considering the limited export features currently in WordPress. I'm mainly echoing what's been said above, but I think the new Font Library is a good opportunity to expand the current export features and explore what the next iteration of this functionality looks like in Core.

@matiasbenedetto
Copy link
Contributor Author

I think we would need to implement this on the core at some point. Otherwise, the theme exported by the 'Export' core functionality would be incomplete, right?

We could handle the fonts this way:

  • Uploaded fonts should be moved to the exported .zip theme file.
  • Remote fonts should be referenced as they are.

As a more general comment, all the Export functionality is lacking behind the capabilities implemented on the Create Block Theme plugin; at some point, we should try to move the newer functionality around exporting a theme and testing well in CBT to core.

@jffng
Copy link
Contributor

jffng commented Jan 19, 2024

I un-assigned myself, since I will not finish this before my extended leave. The above PR is a good place to start I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Font Library [Feature] Typography Font and typography-related issues and PRs [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

6 participants