markboulton / specimen-builder

Apache License 2.0
95 stars 14 forks source link

Specimen Builder

Specimen Builder is a quick and easy way to build digital type specimens. It uses Specimen Skeleton as a base and builds on top of it with a theme design and some configuration. Specimen Skeleton is built using Eleventy

The design rationale for specimen builder comes from several months of design research into the effectiveness of digital type specimens. You can read the final report of that research here.

Requirements

Getting started

To get started, run the following commands from the root of the repo:

This will give you a basic specimen with the default content, configuration, and fonts.

Workflow for adding your own fonts

Deleting the placeholder fonts

Add your own fonts

Editing the placeholder content

Editing the default 'main_id' variable

Changing the design


Information architecture

The specimen produced by this tool has vertically stacked 'containers', from top to bottom, they are:

  1. Navigation. Containing the Light/Dark toggle.
  2. Masthead. Containing critical information regarding the typeface, in addition to large evaluative glyphs and a call to action to download the font.
  3. Interactive Controls. An important container for user evaluation. These controls automatically generate sliders and drop downs from either individual font files, or from variable font axis. Simple typesetting tools are available for the user to change alignment, size, and line height.
  4. Specimen. Containing several single words set in varying weights. These should be individualised per font.
  5. Setting. A container to demonstrate long-form content at various dense settings at sizes.
  6. Character Grid. A comprehensive categorised list of all characters within the fonts together with a large size preview.
  7. Language. A container displaying a list of supported languages.

HTML files in src/_includes/ correspond to each container.


Extending Specimen Builder

You can extend the functionality of the specimens produced using Specimen Builder by simply editing the content or CSS.

Font styles

When you ran yarn fontdata, Specimen Skeleton (remember: the system that is the foundation for Specimen Builder) produced font styles in a css file in _src/css/font.css. These can be used as utility classes for typesetting the 'specimen' or 'setting' containers.

Design tokens

Specimen Builder provides some simple utility classes in the design token CSS – src/css/theme.css – to fine-tune your typesetting. The following classes are available:

Reading direction

If producing specimens for languages that read right to left, or top to bottom, you need to edit a variable in _src/data/site.js called 'direction' and change its value to either:

These values will change the text blocks in each container.

Extending Specimen Builder even further!

Specimen Skeleton – the foundation on which Specimen Builder is built – provides us with some useful tools to extend the specimens even further:

Using assets

In HTML, to use an image from your img directory, use the following URL value with the relative path to your image:

<img src="https://github.com/markboulton/specimen-builder/raw/master/{% webpackAssetPath '../img/my_logo.svg' %}">

If you want to inline an SVG image, use:

{% include '../img/my_logo.svg' %}

or

{% webpackAssetContents 'img/my_logo.svg' %}

In CSS, point to the file using the path relative to your CSS file:

background-image: url(../img/my_logo.svg);

In CSS, images below 8 KB will be inlined automatically. To force inlined or external, append ?inline or ?external respectively, e.g. url(../img/my_logo.svg?external);. Inlining in HTML files

Am I in view?

Simple example to stop CPU-melting animations when they're not in the viewport. Elements with the class .am-i-in-view will get a class .in-view when they're in the viewport, and have that class removed when they leave the viewport. Use this to start/stop heavy animations.

Note: this can be repurposed for lazy loading images, pausing video, etc.


Converting ttf to woff2

If you need to compress your .ttf font files to .woff2, you can use this handy utility from Google

https://github.com/google/woff2

If you're using homebrew on a Mac, you can install it with brew install woff2. It'll give you the tools woff2_decompress and woff2_compress.

Use this one liner to compress all .ttf fonts in the current directory: for f in *.ttf; do woff2_compress $f; done

Content sources

If you are creating specimens in multiple languages, you can use these resources for sourcing content:

  1. Rosetta's Universal Specimen The Universal Specimen from Rosetta displays the Universal Declaraiton of Human Rights in multiple panels in 138 languages.

  2. Aksharamukha : Script Converter This is an excellent resource for providing sample text – from old scriptures, or religious text – across many complex scripts and languages (including derivations).

More about Specimen Skeleton

Specimen Skeleton is an Eleventy-based specimen boilerplate. It helps you get a basic site up and running quickly, and offers you a few interactive elements to build your demos from.

It will analyse your variable font and generate the CSS necessary and all the sliders, so you'll hit the ground running!