Introduction to Bézier Curve 06 “Glyphs API”

API, in which font editor and the rendering engine are operated from the programming language, can be thought of as a format. In particular, I would like to introduce Glyphs API, which is used in font development.

Developed by Georg Seifert, a German type designer and software developer, it has been a popular font creation application over the last several years. In Glyphs API, the operation of Glyphs can be performed by Python. This is convenient for automation and operation for an entire collection of glyphs.

In Glyphs API, as an example, the following is conducted to access the glyph outline. Open the Macro Panel by selecting “Window > Macro Panel” in the menu bar. Then, execute below:

# Access the font currently open
font = Glyphs.font

# Access the glyph ‘A’
glyph = font.glyphs[‘A’]

# Access the master layer (normally the first layer)
layer = glyph.layers[0]

# Processing for each path within the glyph
for i, path in enumerate(layer.paths):
   print(f”—— {i} Number of Path ——“)

   # Display the node coordinate and type included in the path
   for node in path.nodes:
       print(f”({node.x}, {node.y}) {node.type})

 

ノードを表しているのは GSNode オブジェクトです。

Each node is represented by GSNode object.

The following is a sample of the execution result. The ‘zero’ path displays the circumference of A, and the first path displays the shape of a triangle cut inside A.

—— ‘Zero’ Path ——
(95.0, 259.0) – line
(298.0, 259.0) – line
(360.0, -20.0) – line
(380.0, -20.0) – line
(209.0, 748.0) – line
(185.0, 748.0) – line
(15.0, -20.0) – line
(34.0, -20.0) – line
—— First Path ——
(294.0, 277.0) – line
(99.0, 277.0) – line
(196.0, 723.0) – line

This is a format similar to Point in GLIF, as in the previous article.

If you would like more detailed specifications regarding GSNode, please refer to the document below:

https://docu.glyphsapp.com/#GSNode

(LN)

Series archive Type Engineering / Introduction to Bézier Curve