{"id":2031,"date":"2024-05-03T10:52:13","date_gmt":"2024-05-03T16:52:13","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=2031"},"modified":"2024-05-03T10:52:15","modified_gmt":"2024-05-03T16:52:15","slug":"multiplexed-fonts-have-a-cool-superpower","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/multiplexed-fonts-have-a-cool-superpower\/","title":{"rendered":"&#8220;Multiplexed&#8221; Fonts Have a Cool Superpower"},"content":{"rendered":"\n<p>Just to cut to the chase, the superpower is being able to adjust their weight (or at least one of their attributes, or as variable fonts call them, an &#8220;axis&#8221;) without changing the space they occupy. This means that interactive effect and animations can be done without worry for awkward reflow situations and performance problems. I&#8217;ll snipe <a href=\"https:\/\/v-fonts.com\/tags\/C9\">the definition from Variable Fonts<\/a>:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Multiplexed typefaces (sometime alternately referred to as \u201cduplexed\u201d or \u201cuniwidth\u201d) maintain a consistent set width across at least one axis of variation, like weight, allowing for adjustments without causing text to reflow.<\/p>\n<\/blockquote>\n\n\n\n<p>I was just playing with an idea around this recently and only after sharing an idea learned the proper terminology. <a href=\"https:\/\/fonts.google.com\/knowledge\/using_variable_fonts_on_the_web\/interactive_animations_with_variable_fonts\">Nick Sherman wrote about this<\/a> and the article has this compelling demo:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"297\" src=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/05\/unnamed.gif?resize=1024%2C297&#038;ssl=1\" alt=\"\" class=\"wp-image-2035\" srcset=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/05\/unnamed.gif?resize=1024%2C297&amp;ssl=1 1024w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/05\/unnamed.gif?resize=300%2C87&amp;ssl=1 300w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/05\/unnamed.gif?resize=768%2C223&amp;ssl=1 768w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/05\/unnamed.gif?resize=1536%2C445&amp;ssl=1 1536w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p>I quite like that!<\/p>\n\n\n\n<p>The reason I was having a play with it was I was watching <a href=\"https:\/\/www.youtube.com\/watch?v=ddTV12hErTc\">Marques Brownlee&#8217;s review of the Rabbit R1<\/a> and noticed how the menu looks as you scroll through it:<\/p>\n\n\n\n\t\t<figure class=\"wp-block-jetpack-videopress jetpack-videopress-player\" style=\"\" >\n\t\t\t<div class=\"jetpack-videopress-player__wrapper\"> <iframe title=\"VideoPress Video Player\" aria-label='VideoPress Video Player' width='500' height='281' src='https:\/\/videopress.com\/embed\/0Eg6GBho?cover=1&amp;autoPlay=0&amp;controls=1&amp;loop=0&amp;muted=0&amp;persistVolume=1&amp;playsinline=0&amp;preloadContent=metadata&amp;useAverageColor=1&amp;hd=0' frameborder='0' allowfullscreen data-resize-to-parent=\"true\" allow='clipboard-write'><\/iframe><script src='https:\/\/v0.wordpress.com\/js\/next\/videopress-iframe.js?m=1674852142'><\/script><\/div>\n\t\t\t\n\t\t\t\n\t\t<\/figure>\n\t\t\n\n\n<p>You can see there that is <em>kind of<\/em> what is happening. The text is clearly getting bigger, yet the menu items above or below are not reflowed, they stay the same essential size. The text does get quite a bit bigger horizontally, so perhaps this doesn&#8217;t fit the definition of multiplexing, but it&#8217;s in the same ballpark.<\/p>\n\n\n\n<p>I took a crack at it here:<\/p>\n\n\n\n<div class=\"wp-block-cp-codepen-gutenberg-embed-block cp_embed_wrapper\"><iframe id=\"cp_embed_zYXQEEX\" src=\"\/\/codepen.io\/anon\/embed\/zYXQEEX?height=450&amp;theme-id=47434&amp;slug-hash=zYXQEEX&amp;default-tab=result\" height=\"450\" scrolling=\"no\" frameborder=\"0\" allowfullscreen allowpaymentrequest name=\"CodePen Embed zYXQEEX\" title=\"CodePen Embed zYXQEEX\" class=\"cp_embed_iframe\" style=\"width:100%;overflow:hidden\">CodePen Embed Fallback<\/iframe><\/div>\n\n\n\n<p>I thought what I could do is use an HTML structure that includes an internal styling-only <code>&lt;span&gt;<\/code>, like:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-code-table\"><span class='shcb-loc'><span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">nav<\/span>&gt;<\/span>\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">ul<\/span>&gt;<\/span>\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">li<\/span>&gt;<\/span>\n<\/span><\/span><span class='shcb-loc'><span>      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"#\"<\/span>&gt;<\/span>\n<\/span><\/span><mark class='shcb-loc'><span>        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span>&gt;<\/span>Menu Item<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span>\n<\/span><\/mark><span class='shcb-loc'><span>\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Then when the menu item is hovered over, I could to a <code>scale<\/code> transform on the <code>&lt;span&gt;<\/code> and have it not effect the natural height of the <code>&lt;a&gt;<\/code> parent. Which works great! <\/p>\n\n\n\n<p>Then just to fiddle with variable fonts a smidge, I updated the <code>font-variation-settings<\/code> and animated them.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-code-table\"><span class='shcb-loc'><span><span class=\"hljs-selector-tag\">ul<\/span> {\n<\/span><\/span><span class='shcb-loc'><span>  <span class=\"hljs-attribute\">font<\/span>: <span class=\"hljs-number\">100%<\/span> system-ui; <span class=\"hljs-comment\">\/* on macs, yields San Franciso, which is variable *\/<\/span>\n<\/span><\/span><span class='shcb-loc'><span>  &gt; li {\n<\/span><\/span><span class='shcb-loc'><span>    &gt; a {\n<\/span><\/span><span class='shcb-loc'><span>      <span class=\"hljs-attribute\">font-variation-settings<\/span>: <span class=\"hljs-string\">\"wght\"<\/span> <span class=\"hljs-number\">600<\/span>, <span class=\"hljs-string\">\"wdth\"<\/span> <span class=\"hljs-number\">100<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>      &amp;:hover,\n<\/span><\/span><span class='shcb-loc'><span>      &amp;:focus {\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-attribute\">font-variation-settings<\/span>: <span class=\"hljs-string\">\"wght\"<\/span> <span class=\"hljs-number\">900<\/span>, <span class=\"hljs-string\">\"wdth\"<\/span> <span class=\"hljs-number\">700<\/span>;\n<\/span><\/span><mark class='shcb-loc'><span>        @media (<span class=\"hljs-attribute\">prefers-reduced-motion<\/span>: no-preference) {\n<\/span><\/mark><mark class='shcb-loc'><span>          transition: scale <span class=\"hljs-number\">0.1s<\/span>, font-variation-settings <span class=\"hljs-number\">0.1s<\/span>;\n<\/span><\/mark><span class='shcb-loc'><span>        }\n<\/span><\/span><span class='shcb-loc'><span>        <span class=\"hljs-selector-tag\">span<\/span> {\n<\/span><\/span><span class='shcb-loc'><span>          <span class=\"hljs-attribute\">display<\/span>: block;\n<\/span><\/span><span class='shcb-loc'><span>          <span class=\"hljs-attribute\">scale<\/span>: <span class=\"hljs-number\">1.33<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>          <span class=\"hljs-attribute\">transform-origin<\/span>: left center;\n<\/span><\/span><span class='shcb-loc'><span>        }\n<\/span><\/span><span class='shcb-loc'><span>      }\n<\/span><\/span><span class='shcb-loc'><span>    }\n<\/span><\/span><span class='shcb-loc'><span>  }\n<\/span><\/span><span class='shcb-loc'><span>}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>I only put the <code>transition<\/code> on the hover\/focus state on purpose. Normally that is a mistake, but here, I wanted the &#8220;off&#8221; transition to be instant and only do a smidge of morphing as the menu item becomes active. <\/p>\n\n\n\n<p>But back to multiplexed fonts&#8230; some fonts are literally designed to allow this, like <a href=\"https:\/\/hex.xyz\/HEX_Franklin\/\">HEX Franklin<\/a>:<\/p>\n\n\n\n\t\t<figure class=\"wp-block-jetpack-videopress jetpack-videopress-player\" style=\"\" >\n\t\t\t<div class=\"jetpack-videopress-player__wrapper\"> <iframe title=\"VideoPress Video Player\" aria-label='VideoPress Video Player' width='500' height='259' src='https:\/\/videopress.com\/embed\/ElcfZEGi?cover=1&amp;autoPlay=0&amp;controls=1&amp;loop=0&amp;muted=0&amp;persistVolume=1&amp;playsinline=0&amp;preloadContent=metadata&amp;useAverageColor=1&amp;hd=0' frameborder='0' allowfullscreen data-resize-to-parent=\"true\" allow='clipboard-write'><\/iframe><script src='https:\/\/v0.wordpress.com\/js\/next\/videopress-iframe.js?m=1674852142'><\/script><\/div>\n\t\t\t\n\t\t\t\n\t\t<\/figure>\n\t\t\n\n\n<p>You can see it isn&#8217;t totally perfect at all weights, but it&#8217;s pretty close! I just think that is so neat. If you&#8217;re using a font that has this ability, it would be a shame <em>not<\/em> to use it. <\/p>\n\n\n\n<p>Check out <a href=\"https:\/\/fontspectrum.com\/\">Electric Blue<\/a> as well, where the effect is a perfect multiplex, but less traditional:<\/p>\n\n\n\n\t\t<figure class=\"wp-block-jetpack-videopress jetpack-videopress-player\" style=\"\" >\n\t\t\t<div class=\"jetpack-videopress-player__wrapper\"> <iframe title=\"VideoPress Video Player\" aria-label='VideoPress Video Player' width='500' height='114' src='https:\/\/videopress.com\/embed\/7fKkFp8F?cover=1&amp;autoPlay=0&amp;controls=1&amp;loop=0&amp;muted=0&amp;persistVolume=1&amp;playsinline=0&amp;preloadContent=metadata&amp;useAverageColor=1&amp;hd=0' frameborder='0' allowfullscreen data-resize-to-parent=\"true\" allow='clipboard-write'><\/iframe><script src='https:\/\/v0.wordpress.com\/js\/next\/videopress-iframe.js?m=1674852142'><\/script><\/div>\n\t\t\t\n\t\t\t\n\t\t<\/figure>\n\t\t\n\n\n<p>Nick has some important notes:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>On a related note, some variable fonts also offer a \u201c<a href=\"https:\/\/fonts.google.com\/knowledge\/glossary\/grade_axis\">grade<\/a>\u201d axis separate from (and often in addition to) the standard&nbsp;<a href=\"https:\/\/fonts.google.com\/knowledge\/glossary\/weight_axis\">weight<\/a>&nbsp;axis. This allows for multiplexed adjustments to a typeface\u2019s apparent weight even if its standard weight axis would otherwise affect spacing.<\/p>\n\n\n\n<p>Not all variable fonts offer multiplexed variations, but there is a&nbsp;<a href=\"https:\/\/v-fonts.com\/tags\/C9\">growing selection<\/a>&nbsp;available. And it\u2019s worth noting that almost all&nbsp;<a href=\"https:\/\/fonts.google.com\/knowledge\/glossary\/monospaced\">monospaced<\/a>&nbsp;variable fonts are naturally multiplexed.<\/p>\n<\/blockquote>\n\n\n\n<p>On that first point, <a href=\"https:\/\/v-fonts.com\/fonts\/roboto-flex\">Roboto Flex<\/a> is like that. It&#8217;s got a weight access that changes dimensions, but the GRAD axis does not. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just to cut to the chase, the superpower is being able to adjust their weight (or at least one of their attributes, or as variable fonts call them, an &#8220;axis&#8221;) without changing the space they occupy. This means that interactive effect and animations can be done without worry for awkward reflow situations and performance problems. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2047,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[39,169],"class_list":["post-2031","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-post","tag-typography","tag-variable-fonts"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/05\/small-medium-large-thumb.jpg?fit=1000%2C500&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/2031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=2031"}],"version-history":[{"count":6,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/2031\/revisions"}],"predecessor-version":[{"id":2049,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/2031\/revisions\/2049"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/2047"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=2031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=2031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=2031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}