Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Fix font paths #51

Merged
merged 2 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ function twentytwentytwo_support() {
* Enqueue scripts and styles.
*/
function twentytwentytwo_styles() {
// Register theme stylesheet.
wp_register_style( 'twentytwentytwo-style', '' );
// Add styles inline.
wp_add_inline_style( 'twentytwentytwo-style', twentytwentytwo_get_font_face_styles() );
// Enqueue theme stylesheet.
$theme_version = wp_get_theme()->get( 'Version' );
$version_string = is_string( $theme_version ) ? $theme_version : false;
wp_enqueue_style( 'twentytwentytwo-style', get_template_directory_uri() . '/style.css', array(), $version_string );
wp_enqueue_style( 'twentytwentytwo-style' );
}
add_action( 'wp_enqueue_scripts', 'twentytwentytwo_styles' );
endif;
Expand All @@ -33,12 +35,34 @@ function twentytwentytwo_styles() {
* Enqueue editor styles.
*/
function twentytwentytwo_editor_styles() {
// Enqueue editor styles.
add_editor_style(
array(
get_stylesheet_uri(),
)
);
wp_add_inline_style( 'wp-block-library', twentytwentytwo_get_font_face_styles() );
}
add_action( 'admin_init', 'twentytwentytwo_editor_styles' );
endif;
endif;

if ( ! function_exists( 'twentytwentytwo_get_font_face_styles' ) ) :
/**
* Get font face styles.
*
* @return string
*/
function twentytwentytwo_get_font_face_styles() {
return "
@font-face{
font-family: 'Source Serif Pro';
font-weight: 200 900;
font-style: normal;
font-stretch: normal;
src: url('" . get_theme_file_uri( 'assets/fonts/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2' ) . "') format('woff2');
}

@font-face{
font-family: 'Source Serif Pro';
font-weight: 200 900;
font-style: italic;
font-stretch: normal;
src: url('" . get_theme_file_uri( 'assets/fonts/source-serif-pro/SourceSerif4Variable-Italic.ttf.woff2' ) . "') format('woff2');
}
";
}
endif;
33 changes: 0 additions & 33 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,3 @@ Text Domain: twentytwentytwo
Twenty Twenty-Two WordPress Theme, (C) 2021 WordPress.org
Twenty Twenty-Two is distributed under the terms of the GNU GPL.
*/

/*--------------------------------------------------------------
>>> TABLE OF CONTENTS:
----------------------------------------------------------------

0. Fonts

----------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------- */
/* 0. Fonts
/* -------------------------------------------------------------------------- */

/*
* Fonts can be reworked if this core issue is resolved:
* https://github.com/WordPress/wordpress-develop/pull/1573
*/

@font-face{
font-family: 'Source Serif Pro';
font-weight: 200 900;
font-style: normal;
font-stretch: normal;
src: url('/wp-content/themes/twentytwentytwo/assets/fonts/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2') format('woff2');
}

@font-face{
font-family: 'Source Serif Pro';
font-weight: 200 900;
font-style: italic;
font-stretch: normal;
src: url('/wp-content/themes/twentytwentytwo/assets/fonts/source-serif-pro/SourceSerif4Variable-Italic.ttf.woff2') format('woff2');
}