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.
To get started, run the following commands from the root of the repo:
yarn install
yarn start
This will give you a basic specimen with the default content, configuration, and fonts.
src/fonts
src/_data/fontdata.json
src/_data/fonts
src/fonts
directory. They must be in woff2 format.yarn fontdata
src/_data/fontdata.json
. This will determine the order the font files will appear in the tester dropdown.src/_data/site.js
src/_data/content.js
main_id
is the variable that defines the font file for the whole specimen. It is defined in src/index.html
in this line of code: {% assign main_id = 0 %}
.src/_data/fontdata.json
.main_id = 3
.src/css/theme.css
.woff2
files. In index.html
, on line 16, change the main_id
variable number to the number in the array generated in _data/fontdata.json
. This will determine the loading font in the type tester.yarn start
- this will start the local development server, view at http://localhost:8080.The specimen produced by this tool has vertically stacked 'containers', from top to bottom, they are:
HTML files in src/_includes/
correspond to each container.
You can extend the functionality of the specimens produced using Specimen Builder by simply editing the content or CSS.
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.
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:
.m-1u
, .m-2u
, and .p-1u
, .p-2u
etc. Where u = 1em, m = margin, and p = padding..italic
type-3xs
, to .type-8xl
..lh08
to .lh14
represent line height values 0.8 to 1.4..align-centre
, .align-left
, .align-justify
, .align-right
.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.
Specimen Skeleton – the foundation on which Specimen Builder is built – provides us with some useful tools to extend the specimens even further:
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
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.
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
If you are creating specimens in multiple languages, you can use these resources for sourcing content:
Rosetta's Universal Specimen The Universal Specimen from Rosetta displays the Universal Declaraiton of Human Rights in multiple panels in 138 languages.
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).
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!