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 Face: to generate and print font-face styles for theme.json fonts #51770

Merged
merged 38 commits into from
Jul 10, 2023

Commits on Jul 6, 2023

  1. Add WP_Font_Face_Resolver.

    The Resolver handles data interaction between the theme.json
    and WP_Font_Face. It gets the fonts from theme.json and converts
    into the array structure needed for font-face processing.
    hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    3ffdfa1 View commit details
    Browse the repository at this point in the history
  2. Add WP_Font_Face.

    This new class handles validating font-face properties and
    generating and printing font-face styles.
    
    Only the "generate_and_print()" method is public exposed.
    All other functionality is hidden as interworkings.
    
    Integrates WP_Fonts_Provider_Local into the class,
    rather than as a separate provider class, as Font Face
    only supports local font files. By integrating into
    the WP_Font_Face, it avoids exposing provider registration
    and eliminates future BC concerns. If in the future
    support for custom providers is needed, the local
    provider functionality can be safely removed from
    WP_Font_Face without BC concerns or impacts.
    hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    fe8106c View commit details
    Browse the repository at this point in the history
  3. Add wp_print_font_faces().

    This function works for both block-powered and classic sites.
    
    For block-powered sites, it gets the fonts from theme.json via
    the Font Face Resolver.
    
    For classic sites, themes and plugins can programmatically invoke
    it and pass their fonts to it.
    
    The instance of WP_Font_Face is variable cached within this
    global function instead of providing a separate global function.
    
    Why? The entry point to use Font Face is via wp_print_font_faces().
    No other methods are public. Therefore, a global wp_font_face()
    function should not be needed as it would not provide benefits.
    hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    017862e View commit details
    Browse the repository at this point in the history
  4. Relocate iframed editor assets font printing.

    Removes wp_print_fonts() from _gutenberg_get_iframed_editor_assets().
    
    Adds a filter callback to into each global functions file.
    
    This approach keeps the code centralized with its specific
    print function.
    
    Benefits:
    * Avoids switching logic in _gutenberg_get_iframed_editor_assets().
    * Avoids confusion for backporting to Core.
    hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    f91f244 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    aaeb453 View commit details
    Browse the repository at this point in the history
  6. Fix wp_print_font_faces().

    1. The action is passing an empty string. Removed the `array` type hint.
    
    2. Fixed the instantiation code. 🤦
    hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    0cf9f63 View commit details
    Browse the repository at this point in the history
  7. Fixed property typo

    hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    5e189d4 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    5aed83c View commit details
    Browse the repository at this point in the history
  9. Fix class name.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    2f5f107 View commit details
    Browse the repository at this point in the history
  10. Fix the test.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    ab03732 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    9048aaf View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    771934c View commit details
    Browse the repository at this point in the history
  13. Add a comment.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    458b1dd View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    818259d View commit details
    Browse the repository at this point in the history
  15. Rename files.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    5f172e9 View commit details
    Browse the repository at this point in the history
  16. Fix fatal error.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    ac45ee2 View commit details
    Browse the repository at this point in the history
  17. Fix package name.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    bd8b39c View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    610f403 View commit details
    Browse the repository at this point in the history
  19. Commit draft test.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    2986f7e View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    3a1af83 View commit details
    Browse the repository at this point in the history
  21. Improve the test.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    2fc983c View commit details
    Browse the repository at this point in the history
  22. CS fix

    aristath authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    d9a4e36 View commit details
    Browse the repository at this point in the history
  23. Fix font names.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    265b5e0 View commit details
    Browse the repository at this point in the history
  24. Fix package name.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    b2e0a09 View commit details
    Browse the repository at this point in the history
  25. Remove unrelated tests.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    3f90a70 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    5c23eab View commit details
    Browse the repository at this point in the history
  27. Fix property names.

    Remove unused property.
    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    674187e View commit details
    Browse the repository at this point in the history
  28. Fix DocBlocks.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    cf95e34 View commit details
    Browse the repository at this point in the history
  29. Fix CS.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    a59bb60 View commit details
    Browse the repository at this point in the history
  30. Fix test class names.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    b878840 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    e392dca View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    41860aa View commit details
    Browse the repository at this point in the history
  33. Fix the failing test.

    anton-vlasenko authored and hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    7fedb60 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    33f65a2 View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    c6746db View commit details
    Browse the repository at this point in the history
  36. Test reorganization.

    1. Adds a test case to the fonts directory.
    
    2. Adds a dataset trait for sharing datasets amongst different test classes.
    This change the maintance burden of redundant datasets by centralizing in a shared trait.
    
    3.Removes the style variation tests as these are no longer relevant to the Font Face.
    
    4. A wee bit of renaming and reformatting.
    hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    8ef75f1 View commit details
    Browse the repository at this point in the history
  37. Add wp_print_fonts() tests.

    1. Adds test for when no fonts are passed into the function, i.e. meaning it will pull from the resolver.
    
    2. Improves resolver test to validate the full returned array structure.
    
    3. Moves the expected fonts to the dataset trait to share it between these 2 tests.
    
    4. A wee bit of girlscouting.
    hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    6359091 View commit details
    Browse the repository at this point in the history
  38. Bail out if no fonts to process.

    1. Adds guard clause to WP_Font_Face::generate_and_print().
    2. Adds unhappy test for it.
    3. Adds similar unhappy test for wp_print_font_faces().
    hellofromtonya committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    6f8e601 View commit details
    Browse the repository at this point in the history