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: Add PHP APIs to allow the installation of Font Families and Font Faces on the PHP side #58670

Open
Tracked by #60528
gigitux opened this issue Feb 5, 2024 · 1 comment
Labels

Comments

@gigitux
Copy link
Contributor

gigitux commented Feb 5, 2024

What problem does this address?

The Font Library project (#54169) introduces a powerful REST API for seamlessly installing new Font Families and Font Faces, enhancing the website's typographic options.

On the front end, you can only install these fonts using the REST API. However, it might be helpful to have a dedicated PHP API for a smoother installation process on the backend side.

@gigitux gigitux added the [Type] Enhancement A suggestion for improvement. label Feb 5, 2024
@gigitux gigitux changed the title Font Library: Add PHP API to allow the install Font Families and Font Faces on the PHP side Font Library: Add PHP API to allow the installation of Font Families and Font Faces on the PHP side Feb 5, 2024
@gigitux gigitux changed the title Font Library: Add PHP API to allow the installation of Font Families and Font Faces on the PHP side Font Library: Add PHP APIs to allow the installation of Font Families and Font Faces on the PHP side Feb 5, 2024
@creativecoder
Copy link
Contributor

Thanks @gigitux for opening this issue! This has been on my mind to address after stabilizing the Font Library feature for WP 6.5.

I think a PHP API for font library might include something like

wp_insert_font_family( array $font_family_settings )
wp_update_font_family( int $id, array $font_family_settings )
wp_insert_font_face( array $font_face_settings, int $parent_font_family_id, array $font_file_paths )
wp_update_font_face( int $id, array $font_face_settings, int $parent_font_family_id, array $font_file_paths )

Another way to install fonts that I might expect would be to install directly from a collection

wp_install_font_from_collection( string $collection_slug, string $font_family_slug, array $font_faces = array() )

However, I'm not sure how we would identify the font faces right now. Maybe an array that contains a list of properties to match font faces, if they are present in the collection, i.e.

$font_faces = array(
    array(
        'fontWeight` => 'normal',
        'fontStyle' => 'normal',
    ),
    array(
        'fontWeight' => 'bold',
        'fontStyle' => 'normal',
    ),
    array(
        'fontWeight' => 'normal',
        'fontStyle => 'italic',
    ),
);

However, this has subtleties we'd need to consider, like does bold match only a numeric font weight value of 700, or would it just look for something heavier than 400?

Alternatively, we could introduce font face slugs to collections in some way, so that there's an easy way to reference which font faces should be installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants