Fonts and Colors
The easiest way to customize your story's fonts and colors is with the Style backstage tab1, which sets values in the
config.style object for you. As you make changes in that tab, your story's appearance will automatically update, so you can easily experiment to find a look that fits your story. However, changes you make will not be permanently saved-- the next time you test or play your story, it will revert back to its previous appearance.
In order to make changes in the Style tab permanent, you must copy the code in the Config panel at the top of the tab into your starting passage's vars section. (This passage is shown with a rocket-ship icon in Twine's story map.) Clicking anywhere in the box the code sits in will automatically select all of it to make copying and pasting easy.
Doing so will cause the appropriate variables to be set when your story first begins-- which doesn't mean that it has to be the only appearance your story takes on. You can change variables in the
config.style object in a later passage's vars section and your story's appearance will change when the passage is visited. You could use this, for example, to denote a dream sequence or flashback.
The other panels in the Style tab, Page, Header, and Footer, all have the same fields. As you might guess, Page sets the base style of your story and Header and Footer govern the areas above and below the main text. By default, Chapbook stories don't have a header.
The values you set for page, header, and footer styles inherit from each other. That means that if a header or footer style value isn't set, it will use the corresponding page value instead. If a page value isn't set either, Chapbook's default style will be used instead.
Setting Text Style
Chapbook uses a concise notation for specifying text style. Below is a simple example:
This sets a Palatino typeface at 18 pixels tall.2 But in actual use, you ought to use something like this instead:
Slashes separate alternate typefaces in what is called a font stack. Before the advent of web fonts, font stacks were a crucial part of web design. At that time, web browsers were only capable of displaying fonts installed in the operating system, so designers had to specify alternate typefaces in order to create a consistent appearance across different operating systems.
In our current times, font stacks affect more what a page looks like at first glance--typically, text appears immediately in a system font, then in a web font after it finishes loading. (See [External Web Fonts][external-web-fonts.md] for details on how to use a web font with Chapbook.) But there are players who will have disabled web fonts, either out of personal preference or a need to save network bandwidth, and it's good practice to design your story to accommodate that.
The example above indicates that if a typeface named Palatino isn't available to the player's web browser,
serif signals it should fall back to a generic serif font.3 If you'd like to set your story in Helvetica, you might use:
Many people viewing your story using a Windows computer won't have Helvetica available, but they almost certainly will have Arial, Microsoft's Helvetica competitor, and if for some reason they have neither, the story will use whatever sans serif font is available.
When specifying typefaces that have spaces in their name, you don't need to do anything special:
Times/Times New Roman/serif 20
You can also modify a font with the words
small caps. If you'd like to use multiple styles, just put spaces between them:
Palatino 18 bold italic
There is a special font style named
regular, which removes any bold, italic, underline, or small-cap styling that the font would normally inherit. Font styles must be entered in all-lowercase. This is because you can omit parts of the declaration. All of the below are valid font notations:
18 small caps
The omitted parts are inherited as described above.
Although you don't have to use it, Chapbook has a built-in color palette called Open Color. It has a versatile range of hues that are designed to harmonize with each other.
white, Open Color has 13 base hues:
To use them, enter the appropriate name. Open Color also offers 10 shades per hue:
As above, to use a particular shade, enter the name in its box, e.g.
yellow-6. You can also use any other color notation that web browsers understand, from the traditional hex triplet notation (e.g.
#0b7285) to more modern ones, such as
hsla(0%, 65%, 48%, 0.75).
When setting colors in
config, often you can specify both a background and foreground. For instance, you can set
'orange-9 on orange-0'. However, when specifying a border color, for instance
config.style.page.link.lineColor, only the foreground is used.
As with fonts, you can omit parts of a color declaration. Setting
'on blue-4' causes links to use the page's foreground color, whatever it may be, but use a medium blue as background.
To review, launching your story with Twine's Test button will cause the backstage view to appear, including the Style tab.
If you are familiar with CSS units, you can also use them, e.g.
Palatino 1rem or
What's a serif? Wikipedia aptly answers.