{"id":427,"date":"2025-10-16T15:41:44","date_gmt":"2025-10-16T15:41:44","guid":{"rendered":"https:\/\/ska-blocks.com\/docs\/?p=427"},"modified":"2025-11-04T17:00:13","modified_gmt":"2025-11-04T17:00:13","slug":"custom-fonts","status":"publish","type":"post","link":"https:\/\/ska-blocks.com\/docs\/custom-fonts\/","title":{"rendered":"Custom fonts"},"content":{"rendered":"\n<p class=\"lead\">Adding a custom font using a child theme &#8211; self-hosting is essential for best performance and removes privacy considerations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Choosing a font for self-hosting<\/h2>\n\n\n\n<div class=\"[&amp;_summary]:py-1 space-y-3 [&amp;_summary]:text-xl [&amp;_summary]:font-theme-heading [&amp;_summary]:hover:underline [&amp;_summary]:decoration-1 [&amp;_summary]:underline-offset-4 [&amp;_summary]:select-none wp-block-ska-element\">\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>Google font<\/summary>\n<p>Find and download the font from <a href=\"https:\/\/fonts.google.com\">Google Fonts<\/a>. If it&#8217;s a &#8220;Variable&#8221; font, you&#8217;ll probably want a single font file such as <code>PlayfairDisplay-VariableFont_wght.ttf<\/code> and optionally <code>PlayfairDisplay-Italic-VariableFont_wght.ttf<\/code>.<\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>Inter variable font<\/summary>\n<p>Inter is a really popular modern font you can get from <a href=\"https:\/\/fonts.google.com\/specimen\/Inter\" target=\"_blank\" rel=\"noreferrer noopener\">Google Fonts<\/a> (or <a href=\"https:\/\/fonts.bunny.net\/family\/inter\" target=\"_blank\" rel=\"noreferrer noopener\">Bunny Fonts<\/a>), load it from <a href=\"https:\/\/rsms.me\/inter\/\" target=\"_blank\" rel=\"noreferrer noopener\">rsms.me\/inter<\/a> CDN sponsored by <a href=\"https:\/\/cloudflare.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Cloudflare<\/a> or self-host it. To <strong>self-host<\/strong>, first download it from <a href=\"https:\/\/rsms.me\/inter\/download\/\">https:\/\/rsms.me\/inter\/download\/<\/a> and find the <code>InterVariable.woff2<\/code> from the <code>web<\/code> directory of the zip file.<\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>Custom font<\/summary>\n<p>If you have a font from another source they usually come with specific instructions about which files and CSS to use &#8211; adapt it accordingly.<\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>System font<\/summary>\n<p>Do you even need a font? Best performance and least hassle &#8211; <a href=\"https:\/\/systemfontstack.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">try a system font from System Font Stack<\/a>. These will look slightly different depending on the operating system the user is using, how ever.<\/p>\n<\/details>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Self-hosting a font<\/h2>\n\n\n\n<p>For this example, let&#8217;s set up the Inter variable font.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Prepare the child theme<\/h3>\n\n\n\n<p>Create a <code>fonts<\/code> directory in your child theme folder (comes by default with <code>ska-theme-child<\/code>) and place the <code>InterVariable.woff2<\/code> file in there. Optionally add an <code>.htaccess<\/code> file (if you&#8217;re using Apache web server):<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">Serve static assets with an efficient cache policy<\/span><\/header><div class=\"content\"><pre class=\"code markup language-markup\"><code class=\"language-markup\"># Serve fonts with an efficient cache policy\n&lt;IfModule mod_headers.c>\n\t&lt;FilesMatch \"\\.(otf|ttf|woff|woff2)$\">\n\t\tHeader set Cache-Control \"max-age=315360000, public\"\n\t&lt;\/FilesMatch>\n&lt;\/IfModule><\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><\/div><\/div>\n\n\n\n<p>Now we need this font loaded on the front end but also in the <strong>Block editor<\/strong> and <strong>TinyMCE editor<\/strong> (classic editor, for editing post types that don&#8217;t support Gutenberg, such as WooCommerce products). This can either be achieved by modifying the child theme&#8217;s <code>style.css<\/code> file or via hooks in the child theme&#8217;s <code>functions.php<\/code> file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Load the self-hosted font<\/h3>\n\n\n\n<p>Child theme&#8217;s <code>style.css<\/code> is the best place to put your <code>@font-face<\/code> because with <code>ska-theme-child<\/code> the child theme&#8217;s <code>style.css<\/code> is &#8220;inlined&#8221; by default &#8211; no extra file request on the front end.<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">\/wp-content\/themes\/ska-theme-child\/style.css<\/span><span class=\"label language-css\">CSS<\/span><\/header><div class=\"content\"><pre class=\"code css language-css\"><code class=\"language-css\">\/**\n * Theme Name: ska-theme-child\n * Template: ska-theme\n * Version: 1.0.1\n *\/\n \n@font-face {\n\tfont-family: 'Inter';\n\tsrc: url('\/wp-content\/themes\/ska-theme-child\/fonts\/InterVariable.woff2') format('woff2');\n\tfont-weight: 100 900;\n\tfont-style: normal;\n\tfont-display: swap;\n}<\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><\/div><\/div>\n\n\n\n<p>Increment the <code>Version<\/code> of the child theme header comment to ensure cache busting.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Pre-load the font<\/h3>\n\n\n\n<p>It&#8217;s a good idea to tell the browser as soon as possible to start fetching the font in order to minimize FOUT (Flash of Unstyled Text).<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">\/wp-content\/themes\/ska-theme-child\/functions.php<\/span><span class=\"label language-php\">PHP<\/span><\/header><div class=\"content\"><pre class=\"code php language-php\"><code class=\"language-php\">add_action('wp_head', function() {\n\techo '&lt;link rel=\"preload\" as=\"font\" href=\"\/wp-content\/themes\/ska-theme-child\/fonts\/InterVariable.woff2\" type=\"font\/woff2\" fetchpriority=\"high\" crossorigin=\"anonymous\">';\n}, 5);<\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><\/div><\/div>\n\n\n\n<p>Be sure to use <code>crossorigin=\"anonymous\"<\/code> even though the font is served from your own domain because otherwise the browser may not treat the URL specified in the <code>style.css<\/code> the same as the one in the <code>&lt;link&gt;<\/code> and produce 2 network requests that take additional time to sort it out.<\/p>\n\n\n\n<p>It&#8217;s not render-blocking, just a strong hint to the browser to get the font downloaded ASAP.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Update Tailwind configuration<\/h3>\n\n\n\n<p>Finally you should update Tailwind typography settings to no longer use an external font.<\/p>\n\n\n\n<ol class=\"-mt-2 mb-8! [&amp;_em]:text-site-subtext wp-block-list\">\n<li>Navigate to <strong>ska-blocks -&gt; Tailwind -&gt; Typography<\/strong>.<\/li>\n\n\n\n<li>Find the font you&#8217;re self-hosting and click &#8220;<strong>Edit<\/strong>&#8220;.<br><em>If you&#8217;re adding a brand new font just click the plus icon.<\/em><\/li>\n\n\n\n<li>Change the font source to &#8220;<strong>No external font<\/strong>&#8220;.<\/li>\n\n\n\n<li>Enter the <strong>font name<\/strong> manually as the <strong>first item<\/strong> under &#8220;Local fonts&#8221; (the rest are fallback fonts).<br><em>This can be done by clicking a plus icon of the first row and then clicking an up arrow icon to move the newly created row to the first position.<\/em><br>Fonts that have a <strong>name with spaces<\/strong> should be wrapped in <strong>double quotes<\/strong> (<code>\"<\/code>).<\/li>\n<\/ol>\n\n\n\n<div data-ska-pswp=\"ska-pswp-1\" class=\"flex flex-row flex-wrap gap-gutter items-start wp-block-ska-lightbox\">\n<a data-pswp-height=\"447\" data-pswp-width=\"429\" href=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image.png\" class=\"p-2 w-48 rounded ring ring-site wp-block-ska-image image\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image.png\" alt=\"ska-blocks Tailwind -&gt; Typography options\" width=\"429\" height=\"447\" loading=\"lazy\" srcset=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image.png 429w, https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-288x300.png 288w\" sizes=\"(max-width: 429px) 100vw, 429px\" \/><\/a>\n\n\n\n<a data-pswp-height=\"732\" data-pswp-width=\"491\" href=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-1.png\" class=\"p-2 w-56 rounded ring ring-site wp-block-ska-image image\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-1.png\" alt=\"De-selecting an external font\" width=\"491\" height=\"732\" loading=\"lazy\" srcset=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-1.png 491w, https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-1-201x300.png 201w\" sizes=\"(max-width: 491px) 100vw, 491px\" \/><\/a>\n\n\n\n<a data-pswp-height=\"472\" data-pswp-width=\"487\" href=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-2.png\" class=\"p-2 w-56 rounded ring ring-site wp-block-ska-image image\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-2.png\" alt=\"Using no external font\" width=\"487\" height=\"472\" loading=\"lazy\" srcset=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-2.png 487w, https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-2-300x291.png 300w\" sizes=\"(max-width: 487px) 100vw, 487px\" \/><\/a>\n<\/div>\n\n\n\n<p>A custom font can include another font as a fallback by using <code>var(--font-{slug})<\/code> as a fallback font:<\/p>\n\n\n\n<div data-ska-pswp=\"ska-pswp-2\" class=\"flex flex-row flex-wrap gap-gutter items-start wp-block-ska-lightbox\">\n<a data-pswp-height=\"487\" data-pswp-width=\"488\" href=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-3.png\" class=\"p-2 w-56 rounded ring ring-site wp-block-ska-image image\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-3.png\" alt=\"UI for Lexend font from Variable Google Fonts\" width=\"488\" height=\"487\" loading=\"lazy\" srcset=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-3.png 488w, https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-3-300x300.png 300w, https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-3-150x150.png 150w\" sizes=\"(max-width: 488px) 100vw, 488px\" \/><\/a>\n\n\n\n<a data-pswp-height=\"232\" data-pswp-width=\"486\" href=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-4.png\" class=\"p-2 w-56 rounded ring ring-site wp-block-ska-image image\"><img decoding=\"async\" src=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-4.png\" alt=\"UI for self-hosted Lexend font\" width=\"486\" height=\"232\" loading=\"lazy\" srcset=\"https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-4.png 486w, https:\/\/ska-blocks.com\/docs\/wp-content\/uploads\/sites\/3\/2025\/10\/image-4-300x143.png 300w\" sizes=\"(max-width: 486px) 100vw, 486px\" \/><\/a>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Optimizing further<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Subset your fonts<\/h3>\n\n\n\n<p>Subsetting a font to only include the characters that your site needs can reduce its&#8217; size by <strong>5-10x<\/strong>.<\/p>\n\n\n\n<p>Alternatively ensure that you&#8217;re only loading the correct subset, e.g. <code>latin<\/code>, and not the full font.<\/p>\n\n\n\n<p>A tool like <a href=\"https:\/\/github.com\/zachleat\/glyphhanger\" target=\"_blank\" rel=\"noreferrer noopener\">glyphhanger<\/a> can be used to scan your site for a whitelist of all the characters that it uses and then create a subset from that.<\/p>\n\n\n\n<p>Or you can create a general-purpose font file using <a href=\"https:\/\/github.com\/fonttools\/fonttools\" target=\"_blank\" rel=\"noreferrer noopener\">fonttools<\/a> that includes a pre-defined set of generic letters, numbers and symbols.<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">Characters you might need<\/span><\/header><div class=\"content\"><pre class=\"code\"><code class=\"\"># Letters\nAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\n\n# Language-specific letters\n\u00d5\u00f5\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u0160\u0161\u017d\u017e\n\n# Numbers\/math\n&lt;\u2264012\u00b23\u00b3456789\u207f\u221e\u00b0+-\u00b1=\u2260~\u2248%\u00f7*\u00d7^\u2211\u220f\u2265>\n\n# Punctuation\n.,;:!?\u2026\n\n# Currency\n$\u00a3\u20ac\n\n# Symbols\n#@&amp;\u00a9\u00ae\u2122\n\n# Quotes\n'\"\u201c\u201d\u2018\u2019\u201b\u201e\u201f`\n\n# Brackets\n()&#91;]{}\n\n# Bullets\n\u25cf\u2022\u2981\u00b7\n\n# Arrows\n\u2192\u2190\u00ab\u00bb\u2191\u2193\u2794\u279c\u2196\u2197\u2198\u2199\n\n# Misc\n|\u2013\u2014_\/\\\u00a7<\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><\/div><\/div>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">Unicode range for the above characters<\/span><\/header><div class=\"content\"><pre class=\"code\"><code class=\"\">U+20,U+21,U+23-7E,U+A3,U+A7,U+A9,U+AB,U+AE,U+B0-B3,U+B7,U+BB,U+C4,U+D5-D7,U+DC,U+E4,U+F5-F7,U+FC,U+2013,U+2014,U+2018,U+2019,U+201B-201F,U+2022,U+2026,U+207F,U+20AC,U+2122,U+2190-2193,U+2196-2199,U+220F,U+2211,U+221E,U+2248,U+2260,U+2264,U+2265,U+25CF,U+2794,U+279C,U+2981<\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><\/div><\/div>\n\n\n\n<p>You can check the original font file with a tool like <a href=\"https:\/\/fontdrop.info\/\" target=\"_blank\" rel=\"noreferrer noopener\">FontDrop!<\/a> for information about axes, instances, OpenType features, glyphs, ligatures and supported languages.<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">Using fonttools<\/span><\/header><div class=\"content\"><pre class=\"code\"><code class=\"\">pyftsubset \"VendSans.ttf\" --output-file=\"VendSans-subset.woff2\" --flavor=woff2 --layout-features+=liga,kern --retain-gids --no-hinting --unicodes=...<\/code><\/pre><\/div><\/div>\n\n\n\n<p>With the font tools <a href=\"https:\/\/fonttools.readthedocs.io\/en\/latest\/subset\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">subsetting tool<\/a> you can create a subset suitable for you.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Additional notes<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Benefits to self-hosting a font<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Preloading<\/strong> &#8211; when using a Google font you can&#8217;t efficiently pre-load the font file because it&#8217;s loaded with a hashed name from the CSS that you include.<\/li>\n\n\n\n<li><strong>Reduced latency<\/strong> &#8211; fonts load directly from your server, eliminating third-party delays.<\/li>\n\n\n\n<li><strong>Caching control<\/strong> &#8211; we set custom cache headers to optimize how browsers store and reuse font files.<\/li>\n\n\n\n<li><strong>No third-party tracking, GDPR compliance<\/strong> &#8211; reduces concerns about user data being sent to external servers, which is critical for privacy regulations.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Downsides to self-hosting a font<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Marginally slower<\/strong> &#8211; a CDN tailored for serving fonts can get the job done in <strong>20-30ms<\/strong>, serving it yourself from a regular web server that makes additional checks may take <strong>50-60ms<\/strong>. When it comes to Google fonts or similar setups, it&#8217;s still faster overall because you have a concrete font file URL you can pre-load with a high priority.<\/li>\n\n\n\n<li><strong>Needs subsetting<\/strong> &#8211; if you download a font from Google Fonts it&#8217;ll be around <code>500kb<\/code>, even though when loading it from Google Fonts you were only served <code>~20-50kb<\/code> chunks of it for the subset that was appropriate (e.g. latin).<br>So when self-hosting you&#8217;ll also want to subset the font in order to not serve a drastically bigger file with unnecessary characters.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Which font file format to use?<\/h3>\n\n\n\n<p><code>woff2<\/code> is the best modern font file format and you should prefer to use that. You can provide an alternative <code>woff<\/code>, <code>otf<\/code> or <code>ttf<\/code> as a fallback but the support for <code>woff2<\/code> is good and it&#8217;s not the end of the world if a user with an old browser can&#8217;t load the font so it&#8217;s probably not worth the extra effort.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Child theme <code>style.css<\/code> on the front end<\/h3>\n\n\n\n<p>With <a href=\"https:\/\/ska-blocks.com\/docs\/getting-started-with-ska-theme\/\" data-type=\"post\" data-id=\"59\">ska-theme<\/a> the child theme&#8217;s stylesheet is enqueued automatically but if you&#8217;re using some other theme you may need to enqueue it yourself via the child theme&#8217;s <code>functions.php<\/code>:<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">Enqueuing a child theme&#8217;s style.css<\/span><span class=\"label language-php\">PHP<\/span><\/header><div class=\"content\"><pre class=\"code php language-php\"><code class=\"language-php\">add_action('wp_enqueue_scripts', function() {\n\twp_enqueue_style(\n\t\t'your-child-theme',\n\t\tget_theme_file_uri('style.css'),\n\t\t&#91;],\n\t\twp_get_theme()->get('Version')\n\t);\n}, 150);<\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><\/div><\/div>\n\n\n\n<p>If you don&#8217;t want ska-theme to automatically load the style it can be turned off using:<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><div class=\"content\"><pre class=\"code php language-php\"><code class=\"language-php\">add_filter('ska_theme_enqueue_child_theme_stylesheet', '__return_false');<\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Child theme <code>style.css<\/code> in the block editor<\/h3>\n\n\n\n<p>With <a href=\"https:\/\/ska-blocks.com\/docs\/getting-started-with-ska-theme\/\" data-type=\"post\" data-id=\"59\">ska-theme<\/a> the child theme&#8217;s stylesheet is automatically enqueued in the block editor. The above method for enqueueing the style on the front end should also carry over to the block editor, but if you need to enqueue it manually then you can add it to the block editor settings with the following filter:<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">Adding child theme style.css to the block editor<\/span><span class=\"label language-php\">PHP<\/span><\/header><div class=\"content\"><pre class=\"code php language-php\"><code class=\"language-php\">add_filter('block_editor_settings_all', function($editor_settings) {\n\tif(get_stylesheet() !== get_template()) {\n\t\t$editor_settings&#91;'styles']&#91;] = &#91;\n\t\t\t'id' => 'your-child-theme',\n\t\t\t'css' => file_get_contents(get_theme_file_path('style.css')),\n\t\t\t'__unstableType' => 'theme',\n\t\t];\n\t}\n\treturn $editor_settings;\n});<\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Child theme <code>style.css<\/code> in the classic editor<\/h3>\n\n\n\n<p>With <a href=\"https:\/\/ska-blocks.com\/docs\/getting-started-with-ska-theme\/\" data-type=\"post\" data-id=\"59\">ska-theme<\/a> the child theme&#8217;s stylesheet is automatically enqueued in the TinyMCE editor. Should you need to do it yourself, here&#8217;s the code:<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">Append child theme style.css to TinyMCE CSS files list<\/span><span class=\"label language-php\">PHP<\/span><\/header><div class=\"content\"><pre class=\"code php language-php\"><code class=\"language-php\">add_filter('mce_css', function($css = '') {\n\tif(get_stylesheet() !== get_template()) {\n\t\treturn $css . ',' . get_theme_file_uri('style.css');\n\t}\n\treturn $css; \/\/ Comma-delimited list of stylesheets.\n});<\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Access control for custom fonts<\/h3>\n\n\n\n<p>If you need serve your custom fonts on multiple domains the <code>.htaccess<\/code> file should include directives to provide cross-origin permissions:<\/p>\n\n\n\n<div class=\"wp-block-ska-code not-prose ska-preset--ska-theme--code\"><header><span class=\"title\">Allowing Klaviyo to use your custom font on klaviyo.com<\/span><\/header><div class=\"content\"><pre class=\"code\"><code class=\"\"># Serve fonts with an efficient cache policy\n&lt;IfModule mod_headers.c>\n\t&lt;FilesMatch \"\\.(otf|ttf|woff|woff2)$\">\n\t\tSetEnvIf Origin \"https:\/\/(www\\.)?klaviyo\\.com$\" ORIGIN_ALLOWED=$0\n\t\tHeader set Access-Control-Allow-Origin \"%{ORIGIN_ALLOWED}e\" env=ORIGIN_ALLOWED\n\t\tHeader set Cache-Control \"max-age=315360000, public\"\n\t&lt;\/FilesMatch>\n&lt;\/IfModule><\/code><\/pre><button :class=\"{error: state === &apos;error&apos;, success: state === &apos;success&apos;}\" x-data=\"{state:&apos;&apos;}\" x-on:click=\"navigator.clipboard ? (navigator.clipboard.writeText($el.previousElementSibling.innerText), $el.innerText = `Copied!`, state = &apos;success&apos;) : ($el.innerText = `Can&amp;#039;t copy`, state = &apos;error&apos;)\" class=\"copy\" type=\"button\">Copy<\/button><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Adding a custom font using a child theme &#8211; self-hosting is essential for best performance and removes privacy considerations. Choosing a font for self-hosting Self-hosting a font For this example, let&#8217;s set up the Inter variable font. 1. Prepare the child theme Create a fonts directory in your child theme folder (comes by default with&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-427","post","type-post","status-publish","format-standard","hentry","category-ska-theme"],"_links":{"self":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts\/427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/comments?post=427"}],"version-history":[{"count":22,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts\/427\/revisions"}],"predecessor-version":[{"id":583,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/posts\/427\/revisions\/583"}],"wp:attachment":[{"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/media?parent=427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/categories?post=427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ska-blocks.com\/docs\/wp-json\/wp\/v2\/tags?post=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}