• Stars
    star
    151
  • Rank 246,057 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 10 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A bridge from UFOs to FontTools objects (and therefore, OTFs and TTFs).

GitHub Actions status PyPI Version Codecov Join the chat at https://gitter.im/fonttools-dev/ufo2ft

ufo2ft

ufo2ft ("UFO to FontTools") is a fork of ufo2fdk whose goal is to generate OpenType font binaries from UFOs without the FDK dependency.

The library provides two functions, compileOTF and compileTTF, which work exactly the same way:

from defcon import Font
from ufo2ft import compileOTF
ufo = Font('MyFont-Regular.ufo')
otf = compileOTF(ufo)
otf.save('MyFont-Regular.otf')

In most cases, the behavior of ufo2ft should match that of ufo2fdk, whose documentation is retained below (and hopefully is still accurate).

Naming Data

As with any OpenType compiler, you have to set the font naming data to a particular standard for your naming to be set correctly. In ufo2fdk, you can get away with setting two naming attributes in your font.info object for simple fonts:

  • familyName: The name for your family. For example, "My Garamond".
  • styleName: The style name for this particular font. For example, "Display Light Italic"

ufo2fdk will create all of the other naming data based on thse two fields. If you want to use the fully automatic naming system, all of the other name attributes should be set to None in your font. However, if you want to override the automated system at any level, you can specify particular naming attributes and ufo2fdk will honor your settings. You don't have to set all of the attributes, just the ones you don't want to be automated. For example, in the family "My Garamond" you have eight weights. It would be nice to style map the italics to the romans for each weight. To do this, in the individual romans and italics, you need to set the style mapping data. This is done through the styleMapFamilyName and styleMapStyleName attributes. In each of your roman and italic pairs you would do this:

My Garamond-Light.ufo

  • familyName = "My Garamond"
  • styleName = "Light"
  • styleMapFamilyName = "My Garamond Display Light"
  • styleMapStyleName = "regular"

My Garamond-Light Italic.ufo

  • familyName = "My Garamond"
  • styleName = "Display Light Italic"
  • styleMapFamilyName = "My Garamond Display Light"
  • styleMapStyleName = "italic"

My Garamond-Book.ufo

  • familyName = "My Garamond"
  • styleName = "Book"
  • styleMapFamilyName = "My Garamond Display Book"
  • styleMapStyleName = "regular"

My Garamond-Book Italic.ufo

  • familyName = "My Garamond"
  • styleName = "Display Book Italic"
  • styleMapFamilyName = "My Garamond Display Book"
  • styleMapStyleName = "italic"

etc.

Additionally, if you have defined any naming data, or any data for that matter, in table definitions within your font's features that data will be honored.

Feature generation

If your font's features do not contain kerning/mark/mkmk features, ufo2ft will create them based on your font's kerning/anchor data.

In addition to Adobe OpenType feature files, ufo2ft also supports the MTI/Monotype format. For example, a GPOS table in this format would be stored within the UFO at data/com.github.googlei18n.ufo2ft.mtiFeatures/GPOS.mti.

Fallbacks

Most of the fallbacks have static values. To see what is set for these, look at fontInfoData.py in the source code.

In some cases, the fallback values are dynamically generated from other data in the info object. These are handled internally with functions.

Merging TTX

If the UFO data directory has a com.github.fonttools.ttx folder with TTX files ending with .ttx, these will be merged in the generated font. The index TTX (generated when using using ttx -s) is not required.

Color fonts

ufo2ft supports building COLR and CPAL tables.

If there is com.github.googlei18n.ufo2ft.colorPalettes key in font lib, and com.github.googlei18n.ufo2ft.colorLayerMapping key in the font or in any of the glyphs lib, then ufo2ft will build CPAL table from the color palettes, and COLR table from the color layers.

colorPalettes is a array of palettes, each palette is a array of colors and each color is a array of floats representing RGBA colors. For example:

<key>com.github.googlei18n.ufo2ft.colorPalettes</key>
<array>
  <array>
    <array>
      <real>0.26</real>
      <real>0.0</real>
      <real>0.23</real>
      <real>1.0</real>
    </array>
    <array>
      <real>0.86</real>
      <real>0.73</real>
      <real>0.28</real>
      <real>1.0</real>
    </array>
  </array>
</array>

colorLayerMapping is a array of color layers, each color layer is a array of layer name and palette color index. It is a per-glyph key, but if present in the font lib then it will be used for all glyphs that lack it. For example:

<key>com.github.googlei18n.ufo2ft.colorLayerMapping</key>
<array>
  <array>
    <string>color.1</string>
    <integer>1</integer>
  </array>
  <array>
    <string>color.2</string>
    <integer>0</integer>
  </array>
</array>

With these this key present, ufo2ft will copy the color layers into individual glyphs and setup COLR table.

Alternatively, if the color layers are already separate UFO glyphs, the com.github.googlei18n.ufo2ft.colorLayers font lib key can be used. It uses a table keyed by base glyph, and the value is an array of color layers, each color layer is an array of glyph name and palette color index. For example:

<key>com.github.googlei18n.ufo2ft.colorLayers</key>
<dict>
  <key>alef-ar</key>
  <array>
    <array>
      <string>alef-ar.color0</string>
      <integer>2</integer>
    </array>
  </array>
  <key>alefHamzaabove-ar</key>
  <array>
    <array>
      <string>alefHamzaabove-ar.color0</string>
      <integer>1</integer>
    </array>
    <array>
      <string>alefHamzaabove-ar.color1</string>
      <integer>2</integer>
    </array>
  </array>
<dict>

More Repositories

1

roboto

The Roboto family of fonts
Python
3,796
star
2

noto-emoji

Noto Emoji fonts
Python
3,331
star
3

Inconsolata

Development repo of Inconsolata Fonts by Raph Levien
Rust
1,201
star
4

fontmake

Compile fonts from sources (UFO, Glyphs) to binary (OpenType, TrueType).
Python
763
star
5

morisawa-biz-ud-gothic

Python
615
star
6

compute-shader-101

Sample code for compute shader 101 training
Rust
515
star
7

morisawa-biz-ud-mincho

Python
471
star
8

fontra

A browser-based font editor
JavaScript
463
star
9

roboto-flex

HTML
434
star
10

sfntly

A Library for Using, Editing, and Creating SFNT-based Fonts
Java
432
star
11

amstelvar

a parametric variable font by David Berlow
330
star
12

fontview

Demo app that displays fonts with a free/libre/open-source text rendering stack: FreeType, HarfBuzz and Raqm
C++
321
star
13

spacemono

Original monospace display typeface family
318
star
14

decovar

A multistyle decorative variable font by David Berlow
Python
314
star
15

gftools

Misc tools for working with the Google Fonts library
Python
242
star
16

nanoemoji

A wee tool to build color fonts.
Python
239
star
17

opensans

Open Sans font
Shell
221
star
18

literata

A contemporary serif typeface family for long-form reading
Python
219
star
19

dm-fonts

DM Sans, DM Serif
Shell
190
star
20

rubik

Rubik fonts
Shell
182
star
21

glyphsLib

A bridge from Glyphs source files (.glyphs) to UFOs
Python
181
star
22

korean

Google Fonts Korean showcase
JavaScript
161
star
23

atkinson-hyperlegible

HTML
157
star
24

roboto-classic

Development of a Roboto Variable font
Python
151
star
25

science-gothic

Science Gothic, a libre variable font
Python
145
star
26

picosvg

Helps simplify SVG files. Intended for use as part of a font build.
Python
137
star
27

fontdiff

tool for finding visual differences between two font versions
C++
135
star
28

fontations

Reading and writing font files
Rust
114
star
29

pyfontaine

Python tool to check font files for language/character set support
Python
100
star
30

gf-docs

Documentation for things related to github.com/google/fonts
99
star
31

color-fonts

Experimental color font builds.
Python
96
star
32

googlefonts-project-template

(DEMO) Repository architecture example for a typeface design project
Python
93
star
33

inter-gf-tight

Specialized version of Inter with tighter spacing, for use by Google Workspace
Python
79
star
34

glyphsets

Python
78
star
35

fontdiffenator

Font comparison tool
Python
76
star
36

dm-mono

DM Mono
Shell
73
star
37

lexend

A variable font family designed to aid in reading proficiency.
Shell
72
star
38

zen-marugothic

ZenFonts.jp Maru Gothic
Python
72
star
39

fontcrunch

Tool to optimize TrueType font splines
C++
70
star
40

RobotoMono

Shell
64
star
41

colr-gradients-spec

HTML
63
star
42

cu2qu

Cubic-to-quadratic bezier curve conversion
Python
62
star
43

fontreport

Tool to create PDF files containing glyph images and information about a font.
Python
62
star
44

googlefonts.github.io

Google Fonts documentation
CSS
57
star
45

robotoslab

Roboto Slab Typeface by Google
Python
57
star
46

roboto-serif

55
star
47

tajawal

Distinctive low contrast Arabic and sans serif Latin typeface family
54
star
48

emoji-metadata

Emoji metadata for the construction of pickers
48
star
49

dosis-vf

Fork of Dosis
Makefile
45
star
50

oxidize

Notes on moving tools and libraries to Rust.
45
star
51

zen-kurenaido

ZenFonts.jp Kurenaido
Python
45
star
52

comfortaa

Open-source font by Johan Aakerlund
HTML
44
star
53

diffenator2

A font comparison tool that will not stop until your fonts are exhaustively compared.
Python
43
star
54

ibarrareal

Ibarra Real Fonts
Shell
40
star
55

zen-kakugothic

ZenFonts.jp Kaku Gothic
Python
40
star
56

Gulzar

Nastaliq font
Python
39
star
57

gulim

Python
39
star
58

how-to-hint-variable-fonts

A how-to guide to TrueType hinting variable fonts, with VTT
38
star
59

NunitoSans

Shell
36
star
60

zen-oldmincho

ZenFonts.jp Old Mincho
Python
36
star
61

fontra-pak

A cross-platform bundled Fontra server for local desktop use
Python
34
star
62

TachyFont

Lazily loaded web fonts.
JavaScript
34
star
63

majormono

Python
32
star
64

josefinsans

Google Improvement Project
HTML
31
star
65

shaperglot

Test font files for language support
Python
30
star
66

EQX

A typographically centric font testing tool.
JavaScript
29
star
67

fontbakery-dashboard

A library-scale web dashboard for Font Bakery, no longer developed
JavaScript
28
star
68

axisregistry

A Python API to access data from the Google Fonts variable fonts Axis Registry.
Python
27
star
69

karla

Python
25
star
70

fontmake-rs

Where in we pursue oxidizing (context: https://github.com/googlefonts/oxidize) fontmake.
Rust
24
star
71

chws_tool

Add OpenType chws/vchw features to fonts.
HTML
23
star
72

lang

A python API for evaluating language support in the Google Fonts collection.
Python
23
star
73

caveat

Caveat handwriting fonts
Shell
23
star
74

compreffor

A CFF table subroutinizer for FontTools
Python
23
star
75

kosugi-maru

Kosugi Maru fonts, originally by Motoya
Python
23
star
76

collidoscope

Brute force detection of glyph collisions
Python
22
star
77

zen-antique

ZenFonts.jp Antique
Python
21
star
78

questrial

A fork of John Prince font Questrial from the old Google font directory
Python
21
star
79

chinese

CSS
20
star
80

gf-glyphs-scripts

Scripts for Glyphs
Python
20
star
81

staatliches

Herbert Bayer’s title lettering for the first Bauhaus exhibition catalogue cover of 1923
Python
18
star
82

batang

Python
18
star
83

changa-vf

Variable font fork of the Changa typeface (Latin, Arabic)
Makefile
17
star
84

Roboto-Delta

Roboto as a “parametric” Variable Font
Python
17
star
85

picosvg-rs

A Rust version of picosvg.
Rust
15
star
86

silkscreen

Classic web design pixel font from Jason Kottke, 2001
Python
15
star
87

gfregression

Test local fonts against fonts host on fonts.google.com
Python
14
star
88

fez

Font Engineering made eaZy
Python
14
star
89

mavenproFont

Maven Pro family by Joe Prince
Makefile
14
star
90

BethEllen

Font project repo for the Beth Ellen font by Rod Jelinski
14
star
91

fontquant

Prove and quantify a font’s technical quality
Python
11
star
92

how-to-hint-complex-script-variable-fonts

A guide to hinting complex script variable fonts with Visual TrueType
11
star
93

ufomerge

ufomerge
Python
11
star
94

dynapuff

Fun blobby display font
Python
10
star
95

kosugi

Kosugi fonts, originally by Motoya
Python
10
star
96

zen-dots

Shell
10
star
97

flowify

Turn a font into a flow font
Python
10
star
98

namecheck

Python
9
star
99

ots-python

Python wheels for the OpenType Sanitizer
Python
9
star
100

variable-components-spec

8
star