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.

header
main content

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

Applies to:

  • config.style.page.font
  • config.style.page.link.font
  • config.style.page.link.active.font
  • config.style.header.font
  • config.style.header.link.font
  • config.style.header.link.active.font

Chapbook uses a concise notation for specifying text style. Below is a simple example:

Palatino 18

This sets a Palatino typeface at 18 pixels tall.2 But in actual use, you ought to use something like this instead:

Palatino/serif 18

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:

Helvetica/Arial/sans-serif 14

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 bold, italic, underline or 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:

  • Palatino
  • 18
  • bold italic
  • Palatino bold
  • 18 small caps

The omitted parts are inherited as described above.

Colors

Applies to:

  • config.style.backdrop
  • config.style.page.color
  • config.style.page.link.color
  • config.style.page.link.lineColor
  • config.style.page.link.active.color
  • config.style.page.link.active.lineColor
  • config.style.page.color
  • config.style.page.link.color
  • config.style.page.link.lineColor
  • config.style.page.link.active.color
  • config.style.page.link.active.lineColor

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.

Besides black and white, Open Color has 13 base hues:

gray
red
pink
grape
violet
indigo
blue
cyan
teal
green
lime
yellow
orange

To use them, enter the appropriate name. Open Color also offers 10 shades per hue:

gray-0
red-0
pink-0
grape-0
violet-0
indigo-0
blue-0
cyan-0
teal-0
green-0
lime-0
yellow-0
orange-0
gray-1
red-1
pink-1
grape-1
violet-1
indigo-1
blue-1
cyan-1
teal-1
green-1
lime-1
yellow-1
orange-1
gray-2
red-2
pink-2
grape-2
violet-2
indigo-2
blue-2
cyan-2
teal-2
green-2
lime-2
yellow-2
orange-2
gray-3
red-3
pink-3
grape-3
violet-3
indigo-3
blue-3
cyan-3
teal-3
green-3
lime-3
yellow-3
orange-3
gray-4
red-4
pink-4
grape-4
violet-4
indigo-4
blue-4
cyan-4
teal-4
green-4
lime-4
yellow-4
orange-4
gray-5
red-5
pink-5
grape-5
violet-5
indigo-5
blue-5
cyan-5
teal-5
green-5
lime-5
yellow-5
orange-5
gray-6
red-6
pink-6
grape-6
violet-6
indigo-6
blue-6
cyan-6
teal-6
green-6
lime-6
yellow-6
orange-6
gray-7
red-7
pink-7
grape-7
violet-7
indigo-7
blue-7
cyan-7
teal-7
green-7
lime-7
yellow-7
orange-7
gray-8
red-8
pink-8
grape-8
violet-8
indigo-8
blue-8
cyan-8
teal-8
green-8
lime-8
yellow-8
orange-8
gray-9
red-9
pink-9
grape-9
violet-9
indigo-9
blue-9
cyan-9
teal-9
green-9
lime-9
yellow-9
orange-9

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][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 config.style.page.color to '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 config.style.page.link.color to 'on blue-4' causes links to use the page's foreground color, whatever it may be, but use a medium blue as background.

1. To review, launching your story with Twine's Test button will cause the backstage view to appear, including the Style tab.
2. If you are familiar with [CSS units][css-units], you can also use them, e.g. Palatino 1rem or Palatino 25%.
3. What's a serif? Wikipedia aptly answers.

results matching ""

    No results matching ""