Add Variable Fonts Support

Please add support for variable fonts. Introduction to variable fonts on the web

It’s good for ease of use and performance. I can load a single woff2 file and get all font size & styles for my project. Browser support is decent at 95% and growing. “variable fonts” | Can I use… Support tables for HTML5, CSS3, etc

I did a comparison also. Inter font (latin only woff2 only) requires 180KB and 9 woff2 files to load all sizes. Inter font variable requires only 1 request and 160KB to load all the fonts. I can decide to use any font size without to be bothered to upload them later.

21 Likes

@ChrisCastillo posted a video on it. I am yet to check it out but posting here for reference. Loom | Free Screen & Video Recording Software

4 Likes

Did you get it to work? In Bricks 1.5.2 the workflow does not work for meDid you get it to work? In Bricks 1.5.2 the workflow does not work for me.

Hi @sebastianberger,

I just fiddled with variable fonts for a while before I got it to work. Did you get it to work by now? For me the trick was to disable disallowed file uploads in wo-config so I could upload the files through the media library. Then I followed @omega instructional video (thanks for that!), just selecting the same file over and over for all variations and that appears to work fine.

Regards!
Kevin

Hey Kevin
I use Matthias Altmanns Script for that and that works like a charme. :slightly_smiling_face:

3 Likes

Is work already underway to implement these types of fonts? I see that there are more and more of them in google fonts. Besides, it’s a brilliant solution, less work and less server traffic.

3 Likes

Bricks needs this. Font installation is painful AF.

Some basic usability things in Bricks I just don’t understand… workflow could be a lot more efficient with a few tweaks like this.

Isn’t it working now? We install the font as usual, but in the font-variation-settings field we write this
‘wght’ 400 , ‘wdth’ 130

Does this only work with Google Fonts ? I cant find my fonts on the site listed.

Do I need to connect custom variable fonts in bricks separately via CSS?

Download the variable font file, hopefully it’s woff2. If it’s a Google font, download from the Web Font Loader tool: https://webfontloader.altmann.de/

In Bricks, add the custom font and name it exactly as you want to reference in CSS/Bricks. So if you downloaded Montserrat, don’t name it “Montserrat Variable Font” or this is what you need to type in Bricks to use it. Just called “Montserrat” exactly as it would be if loading from Google.

Add all variations to the custom font. Just because it’s variable doesn’t mean you don’t have to create them. Montserrat supports 100 through 900 so add all of them you need at each weight level. Connect each variation to the same woff2 file. It would look like this:

If you wanted to add the variable italic fonts, then create all the variations again but change “Normal” to “Italic” and point to that woff2 file.

In the Bricks->Performance settings, turn on the option to disable Google Fonts. This isn’t necessary, but of course you don’t need it if you are loading local fonts. Plus we are using the same font name, it I don’t know which one would “win” when referenced.

After saving the settings, open the frontend, open web dev tools and the DOM, then search for the font name. You should see the block of CSS creating all the variations like this:

<style id="bricks-frontend-inline-css" > @font-face {
    font-family: "Montserrat";
    font-weight: 100;
    font-display: swap;
    src: url(https://aaaa.com/wp-content/uploads/2024/11/Montserrat-VariableFont_wght.woff2) format("woff2");
}
@font-face {
    font-family: "Montserrat";
    font-weight: 200;
    font-display: swap;
    src: url(https://aaaa.com/wp-content/uploads/2024/11/Montserrat-VariableFont_wght.woff2) format("woff2");
}
@font-face {
    font-family: "Montserrat";
    font-weight: 300;
    font-display: swap;
    src: url(https://aaaa.com/wp-content/uploads/2024/11/Montserrat-VariableFont_wght.woff2) format("woff2");
}
@font-face {
    font-family: "Montserrat";
    font-weight: 400;
    font-display: swap;
    src: url(https://aaaa.com/wp-content/uploads/2024/11/Montserrat-VariableFont_wght.woff2) format("woff2");
}
@font-face {
    font-family: "Montserrat";
    font-weight: 500;
    font-display: swap;
    src: url(https://aaaa.com/wp-content/uploads/2024/11/Montserrat-VariableFont_wght.woff2) format("woff2");
}
@font-face {
    font-family: "Montserrat";
    font-weight: 600;
    font-display: swap;
    src: url(https://aaaa.com/wp-content/uploads/2024/11/Montserrat-VariableFont_wght.woff2) format("woff2");
}
@font-face {
    font-family: "Montserrat";
    font-weight: 700;
    font-display: swap;
    src: url(https://aaaa.com/wp-content/uploads/2024/11/Montserrat-VariableFont_wght.woff2) format("woff2");
}
@font-face {
    font-family: "Montserrat";
    font-weight: 800;
    font-display: swap;
    src: url(https://aaaa.com/wp-content/uploads/2024/11/Montserrat-VariableFont_wght.woff2) format("woff2");
}
@font-face {
    font-family: "Montserrat";
    font-weight: 900;
    font-display: swap;
    src: url(https://aaaa.com/wp-content/uploads/2024/11/Montserrat-VariableFont_wght.woff2) format("woff2");
}
</style >

The “font-family” definition will match the name you create in Bricks when adding the font, so it would say “Montserrat Variable” if you named it different, and this is how you would reference it in Bricks/CSS.

Once everything is done, you can go in the DOM and live edit some bit of text and change the font weight, it should visibly change for each supported weight you added.

Hope that helps!

1 Like

Thanks for the advice :ok_hand:

This solution repeats the usual font loading and does not fundamentally change the approach.

The meaning of working with variable fonts is slightly different. You upload one file and then specify any size in the constructor or CSS settings. This is something similar to working with the SVG standard.

1 Like

Ya you basically do it this way to make sure the predefined bold sizes match up in Bricks builder.
Even though it’s a bit redundant, it’s still all pointing to the one woff2 file so there is no real increase in assets or file sizes happening. Just a bit more CSS is all.

1 Like

Why not just use this setting in Bricks? You then have every weight in steps of 1 from 1 to 1000 or whatever that particular font supports?
font

1 Like

The point is to have a clean connection between the Bricks custom fonts screen and the font weights selector in standard options.
That’s all a normal person would need anyway.

Who is needing precisely weight 525 and could not just use 500 or 600?

I don’t have a problem with what you pointed out, if the person is used to it. But if someone ever changes the font and it’s not a variable one, or they don’t understand this (clients, editors), then it’s all for naught anyway.

Like I mentioned, adding all the variations which point to the same file anyway, is almost nothing in overhead, but it makes Bricks style weight selector work. And I stick with common weights 400, 600, 700, 900 just in case another font is used or isn’t variable, these sizes typically are available.

Just a few thoughts.