-
I have a variable font I've added to theme.json and I would like the following to be included in the css:
Is there a way to do this through the theme.json file? |
Beta Was this translation helpful? Give feedback.
Answered by
t-hamano
Feb 2, 2023
Replies: 1 comment 1 reply
-
Hi. When specifying a font family, its properties can also be defined. Like this: {
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"typography": {
"fontFamilies": [
{
"fontFace": [
{
"fontFamily": "Source Serif Pro",
"fontFeatureSettings": "some-value",
"src": [
"file:./assets/fonts/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2"
]
}
],
"fontFamily": "\"Source Serif Pro\", serif",
"name": "Source Serif Pro",
"slug": "source-serif-pro"
}
]
}
}
}
From this definition, the following styles are output: <style id="wp-fonts-local">
@font-face{
font-family:"Source Serif Pro";
font-style:normal;font-weight:400;
font-display:fallback;src:url('/wp-content/themes/emptytheme/assets/fonts/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2') format('woff2');
font-feature-settings:some-value;
}
</style> Is this the solution you are looking for? |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
CGTS
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi.
When specifying a font family, its properties can also be defined. Like this:
From this definition, the following styles are output: