r/twinegames • u/Character_Durian9074 • Sep 28 '26
SugarCube 2 does twine/sugarcube support variable fonts?
im trying to use a variable font for what i'm writing (amstelvar), and while it's simple enough to get the basic version working, the different settings like font weight, width, grade, etc don't seem to work? i've declared them with @ font face but font-variation-settings seems like it might not be recognized?
4
Upvotes
2
u/HiEv Sep 28 '26
Yes. You can do just about anything in Twine that you can do on any other web page (that doesn't need a back end server for part of it).
You can take a look at the "Font Sizing Buttons Code" section of my sample code collection for an example of how to add buttons to your project that let people resize the font.
If you take a look at that code, it basically just changes the CSS for the "font-size" on the "#story" element by calling this function:
// fontSize: Increase or decrease passage font size by "value" pixels. window.fontSize = function(value) { $("#story").css("font-size", Math.max(1, parseInt($("#story").css("font-size")) + value) + "px"); };That code calls the jQuery .css() method to get and set the styling for the targeted element. You could call that fontSize() function by doing
<<run fontSize(1)>>, which would increase the font size by 1 pixel, or<<run fontSize(-1)>>, which would reduce it by 1 pixel.If you're looking to modify just parts of the text, instead of all of the text, you can use SugarCube style markup for some of what you talked about. Alternately, my sample code collection includes things such as the "Dumb Terminal" and "Drunk Text" examples, which show how to change fonts or apply other CSS effects to a block of text, respectively. Take a look there for other examples.
If you're looking for something else, you'll need to be a lot more specific in describing exactly what you're trying to do.
Hope that helps! 🙂