In Fontist, a “Font Formula” is used to install one or several fonts.
This structure is modelled after Homebrew’s Formula.
Each Formula defines:
-
what fonts are provided by this Formula
-
metadata of the Formula
-
what remote resources are needed to be downloaded
-
for each font provided, what styles are provided and their filenames
-
mechanism for installing the fonts
-
mechanism to test that fonts are installed
name: Source
description: Adobe Source Fonts
homepage: https://www.adobe.com
...
The description
, homepage
attributes are used to register metadata for the Formula.
Resources are remotely fetched data.
In this example, the file source-fonts.zip
is to be downloaded from the URL
https://github.com/fontist/source-fonts/releases/download/v1.0/source-fonts-1.0.zip
.
EXAMPLE:
resources:
source-fonts.zip:
urls:
- https://github.com/fontist/source-fonts/releases/download/v1.0/source-fonts-1.0.zip
sha256: 0107b5d4ba305cb4dff2ba19138407aa2153632a2c41592f74d20cd0d0261bfd
-
The
urls
attribute lets you specify where to download this resource from. -
The
sha256
command checks the downloaded file against the provided SHA-256 hash.
In some cases, multiple URLs are provided if they are not the most reliable.
EXAMPLE:
resources:
PowerPointViewer.exe:
urls:
- https://gitlab.com/fontmirror/archive/-/raw/master/PowerPointViewer.exe
- https://nchc.dl.sourceforge.net/project/mscorefonts2/cabs/PowerPointViewer.exe
- https://archive.org/download/PowerPointViewer_201801/PowerPointViewer.exe
sha256: 249473568eba7a1e4f95498acba594e0f42e6581add4dead70c1dfb908a09423
file_size: '62914560'
-
The
urls
command lets you set multiple URLs. -
The
file_size
command checks against file size downloaded.
The fonts
attribute lets you declare fonts provided
by this Formula.
fonts
contains two attributes here:
-
Font family name. For example, in the case of Adobe Source Code Pro, it is
Source Code Pro
. This name is only used in Fontist (e.g. for installing) and does not affect the usage of installed fonts. -
A
styles
hash: a hash that maps font styles (e.g. “Bold”) to a filename, used for detection of fonts. These fields are commonly filled by theotfinfo
utility.-
Required fields are:
-
family_name
-
type
-
full_name
-
font
-
-
Other fields are optional:
-
post_script_name
-
version
-
description
-
copyright
-
-
EXAMPLE:
- name: Source Code Pro
styles:
- family_name: Source Code Pro
type: Regular
full_name: Source Code Pro
post_script_name: SourceCodePro-Regular
version: 2.030
description:
copyright: Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
with Reserved Font Name ‘Source’.
font: SourceCodePro-Regular.ttf
- family_name: Source Code Pro
type: Italic
full_name: Source Code Pro Italic
post_script_name: SourceCodePro-It
version: 1.050
description:
copyright: Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
with Reserved Font Name ‘Source’.
font: SourceCodePro-It.ttf
All these declared fonts are stored inside the Formula when defined.
Sometimes fonts are provided in TTC format (truetype collection) meaning that a single file can contain multiple fonts.
The font_collections
attribute is used to declare font collections and
the fonts within.
It contains the following attributes:
-
filename
: the filename of this font collection, used for detection. -
fonts
: this works slightly different than from thefonts
at the top level. It still takes two attributes, the font family name and a styles hash. The styles hash only acceptstype
andfull_name
, which is a map from the font style (e.g., “Bold”) to the font name inside the font collection.
EXAMPLE:
This example shows that:
-
the font collection can be identified with the filename
CAMBRIA.TTC
; -
it contains two fonts, “Cambria” and “Cambria Math”;
-
the font “Cambria” with style “Regular” is provided by extracting
Cambria
fromCAMBRIA.TTC
-
the font “Cambria Math” (default “Regular”) is provided by extracting
Cambria Math
fromCAMBRIA.TTC
font_collections:
- filename: CAMBRIA.TTC
fonts:
- name: Cambria
styles:
- type: Regular
full_name: Cambria
- name: Cambria Math
styles:
- type: Regular
All these declared fonts are stored inside the Formula when defined.
The extract
attribute is used to retrieve and extract resources.
It could consist of one or more instructions. Each instruction has several attributes:
-
format (required), could be
zip
,cab
, orexe
-
file (optional), which file to use if there are several ones
-
options (optional), options to pass to an extractor, e.g.
zip
takes anfonts_sub_dir
parameter
Once the extract method finishes, Fontist would have a full map of where each declared font is located.
EXAMPLE:
extract:
format: zip
options:
fonts_sub_dir: fonts/
EXAMPLE:
extract:
- format: exe
- format: cab
file: ppviewer.cab