1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
---
title: Font
---
Represents a font, with one or more masters.
## Font._formatspecific
* Python type: `dict`
Each object in Babelfont has an optional attached dictionary to allow the storage
of format-specific information. Font creation software may store any additional
information that they wish to have preserved on import and export under a
namespaced (reverse-domain) key in this dictionary. For example, information
specific to the Glyphs software should be stored under the key `com.glyphsapp`.
The value stored under this key may be any data serializable in JSON; typically
it will be a `dict`.
Note that there is an important distinction between the Python object format
of this field and the Babelfont-JSON representation. When stored to JSON, this key
is exported not as `_formatspecific` but as a simple underscore (`_`).
## Font.upm
* Python type: `int`
The font's units per em.
*If not provided, defaults to* `1000`.
## Font.version
* Python type: `(int, int)`
* Babelfont-JSON type: `[int,int]`
Font version number as a tuple of integers (major, minor).
*If not provided, defaults to* `(1, 0)`.
## Font.axes
* Python type: [[`Axis`](Axis.html)]
* When writing to Babelfont-JSON, each item in the list must be placed on a separate line.
A list of axes, in the case of variable/multiple master font. May be empty.
## Font.instances
* Python type: [[`Instance`](Instance.html)]
* When writing to Babelfont-JSON, each item in the list must be placed on a separate line.
A list of named/static instances.
## Font.masters
* Python type: [[`Master`](Master.html)]
* When writing to Babelfont-JSON, each item in the list must be placed on a separate line.
A list of the font's masters.
## Font.glyphs
* Python type: `GlyphList`
* Babelfont-JSON type: `[dict]`
* When writing to Babelfont-JSON, this structure is stored under the separate file `glyphs.json`.
* When writing to Babelfont-JSON, each item in the list must be placed on a separate line.
A list of all glyphs supported in the font.
The `GlyphList` structure in the Python object is a dictionary with array-like
properties (or you might think of it as an array with dictionary-like properties)
containing [`Glyph`](Glyph.html) objects. The `GlyphList` may be iterated
directly, and may be appended to, but may also be used to index a `Glyph` by
its name. This is generally what you want:
```Python
for g in font.glyphs:
assert isinstance(g, Glyph)
font.glyphs.append(newglyph)
glyph_ampersand = font.glyphs["ampersand"]
```
## Font.note
* Python type: `str`
Any user-defined textual note about this font.
*If not provided, defaults to* `None`.
## Font.date
* Python type: `datetime`
* Babelfont-JSON type: `str`
The font's date. When writing to Babelfont-JSON, this
should be stored in the format `%Y-%m-%d %H:%M:%S`. *If not provided, defaults
to the current date/time*.
## Font.names
* Python type: [`Names`](Names.html)
## Font.customOpenTypeValues
* Python type: [[`OTValue`](OTValue.html)]
Any values to be placed in OpenType tables on export to override defaults
## Font.features
* Python type: `FontFeatures`
A representation of the font's OpenType features
|