-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: revised API design #57616
Comments
This is the new shape for the font families endpoints proposed. @TimothyBJacobs @spacedmonkey @swissspidy @costdev @hellofromtonya @kadamwhite It would be important if you could take a look here and share your thoughts about this refactoring proposal. |
I added the Font Collections API specs in the issue description. |
I removed the |
Noting here that we have the following endpoints implemented in a feature branch that can be reviewed directly:
We're still tweaking small bits as we update the client to work with the new API structure, but these should be in near final form. Here's the feature branch PR: #57688 Feedback now is welcome, as this will be very close to what we plan to propose merging for WP 6.5 (after merging to Gutenberg trunk for 17.6). |
Noting that I've updated the font collection endpoints in the description to reflect that we're returning the full data for each collection in |
@creativecoder Thanks for the ping! Just a few questions for clarity come to mind at the moment.
Is there a benefit in having
I don't think that I saw any examples where both
In the example, the path is |
Thanks @costdev for taking a look!
It's for clarity. Font family and face definitions come directly from the theme.json schema, so this is meant to clarify it's the theme.json version, not the API namespace version, css spec level, or anything else.
That's correct, these 2 properties are not used in the same level of any responses. We could use
That would make sense, though the theme.json schema is already using |
My understanding is that this was discussed and architectured on internal A8C systems for Team Pixel. I think this is a good demonstration of why even non-Automatticians felt the editor chats could be canceled. Further discussions like this are examples of issues that ought to be discussed publicly, either on the make/core P2 or - at the least - in GitHub discussions on this repo with a call to action on make/core. |
Hi Peter, thanks for the feedback 🙏 . A make/core post for increased awareness could have been more helpful. On the other hand, how would a GitHub discussion make it more public? |
I'm talking exclusively of the architecture discussions that took place on the Team Pixel P2 and in the team's docs in the period prior to this issue being opened. A significant number of contributors do not have access to these discussions so discussing them is this repo or on make/core will open the discussions up to all contributors, not just those sponsored by Automattic. |
Since this has been merged #57688 are we able to move this out or through the 6.5 board? It's unclear to me if any discussion will continue here or what the role of this issue is at this point. Happy to keep it open! Just want clarity and for the board to be as up to date as possible. |
Thanks for asking @annezazu ! Personally, I'd like to keep this issue open, at least until after the Core PR for the revised Font Library REST API implementation is opened (should be very soon) and has received feedback. If there are any revisions needed in the API design based on that feedback, I think it would be good to track that here for continuity. |
hi @creativecoder Are you happy you've received feedback for the REST API yet? If not please let me know and I will reach out for input. Thank you. |
Now that the API endpoints have been merged to Core, I'll close this issue. We can open separate issues if there are specific things that need to be addressed. Thank you! |
Companion issue to #55278
This issue outlines a proposed design for font management REST API endpoints.
Font Family
A font family with the settings used in
theme.json
format. A font family may have child font faces that are part of the family.GET wp/v2/font-families
List the installed font families.
Font family theme.json properties are nested in
font_family_settings
to keep camel-cased properties out of the root level of the response, where snake-casing is required.Request:
Response:
GET wp/v2/font-families/<id>
Get a font family by id.
Request:
Response:
Using embeddings to get font face information, as well.
Request:
Response:
POST wp/v2/font-families
Create a new font family.
Request:
Response:
POST wp/v2/font-families/<id>
Update font family by id. It merges the received data with the existing data in the font family post (the same way the
wp/v2/posts
endpoint works).Request:
Response:
DELETE wp/v2/font-families/<id>
Delete font family by id. All child font faces and assets are deleted.
Request:
Response:
Request:
Response:
Font Face
Font faces that are used within a font family.
Font face theme.json properties are nested in
font_face_settings
to keep camel-cased properties out of the root level of the response, where snake-casing is required.The API design uses the
wp/v2/posts/<id>/revisions
endpoints as a model, since that is also a nested route with a parent/child relationship.GET wp/v2/font-families/<id>/font-faces
Get all of the font faces for a font family.
Request:
Response:
GET wp/v2/font-families/<id>/font-faces/<id>
Get a single font face for a font family.
Request:
Response:
POST wp/v2/font-families/<id>/font-faces
Add a font face to an existing font family.
Creates one font face for a font family, stores its asset(s), and creates its preview(s). Currently, the font face assets can be added in 2 ways:
The
Content-Type
is alwaysmultipart/form-data
with a JSON string for the data, so that file uploads are supported when used.Upload font face assets attached in the http request:
Request:
Response:
Install font definition without processing src:
Request:
Response:
DELETE wp/v2/font-families/<id>/font-faces/<id>
Delete one font face from a font family.
Request:
Response:
Font Collections
A font collection is a list of font family definitions that can be installed.
GET wp/v2/font-collections
List font collections
Request:
GET wp/v2/font-collections
Response:
GET wp/v2/font-collections/
Get font collection by slug.
Request:
GET wp/v2/font-collections/collection-example
Response:
Activating Font Families and Font Faces
Activating a font family and/or font faces is done by directly updating Global Styles using the existing endpoint (
wp/v2/global-styles
), since adding the fonts to the Global Styles settings is what adds them as typography options for styles across the site.The text was updated successfully, but these errors were encountered: