Hello everyone, I’m Florian and this is my first post on TypeDrawers.
I suspect some of you are using Git to version control your source files. Git can label code-differences for many programming languages (Python, C, Java, …), but it has no built-in support for font-editing software. The labels of a Git diff are not particularly helpful. (I use Glyphs in the following examples, but the technique can be adapted to fit any font-editor.)
![Image: https://us.v-cdn.net/5019405/uploads/editor/8w/oixnlwvmf9no.png]()
Git shows some changed nodes, but not which glyphs these nodes belong to. Teaching Git about the .glyphs-format results in this output:
![Image: https://us.v-cdn.net/5019405/uploads/editor/pp/193jlc5aqoid.png]()
Now the differences are labeled with the name of the glyph, making it much easier to review changes.
Teaching Git about a file-format involves the following two steps:
1. Open the gitattributes file. On macOS, this file is placed at ~/.config/git/attributes (e.g. /Users/Florian/.config/git/attributes). See the Git documentation for other systems. (Create folders as needed and create the file if it does not already exist.) Add the following line to the file:
2. Open the gitconfig file. This file should be placed in your home directory, e.g. /Users/Florian/.gitconfig on macOS. Create it, if it does not already exist. Add the following two lines:Here we define the “glyphs”-difference. The important part is the value of xfuncname. It is a regular expression, which matches a line inside the .glyphs-file. I wrote a regular expression which matches two patterns (separated by “|”):
![]()
With custom glyphs-difference:
![]()
In the above screenshots, I have used the GUI-application Tower, but it works on the command line as well:
![Image: https://us.v-cdn.net/5019405/uploads/editor/zx/at4c5ohavv7u.png]()
Steps 1 and 2 can be applied to any file-format, not just .glyphs files. The main thing you have to change is the xfuncname, which requires a different regular expression for different file-formats. (Some formats might not even need this, UFO for example already splits glyphs into separate files.)
For more information check out the Git documentation, especially the section Defining a custom hunk-header. Note the terminology:
![Image: https://us.v-cdn.net/5019405/uploads/editor/yo/i6a0db31guqb.png]()
I suspect some of you are using Git to version control your source files. Git can label code-differences for many programming languages (Python, C, Java, …), but it has no built-in support for font-editing software. The labels of a Git diff are not particularly helpful. (I use Glyphs in the following examples, but the technique can be adapted to fit any font-editor.)

Git shows some changed nodes, but not which glyphs these nodes belong to. Teaching Git about the .glyphs-format results in this output:

Now the differences are labeled with the name of the glyph, making it much easier to review changes.
Teaching Git about a file-format involves the following two steps:
1. Open the gitattributes file. On macOS, this file is placed at ~/.config/git/attributes (e.g. /Users/Florian/.config/git/attributes). See the Git documentation for other systems. (Create folders as needed and create the file if it does not already exist.) Add the following line to the file:
*.glyphs diff=glyphsThis tells Git to use the “glyphs”-difference for any file ending in “.glyphs”. Now you have to define the “glyphs”-difference.
2. Open the gitconfig file. This file should be placed in your home directory, e.g. /Users/Florian/.gitconfig on macOS. Create it, if it does not already exist. Add the following two lines:
[diff "glyphs"] xfuncname = "^(glyphname = .*|\"@MMK.*\\{)$"
- glyphname = .* — This matches a glyph-name (as shown in the screenshot above).
- \"@MMK.*\\{ — This matches the beginning of a kerning-block. Compare the following Git outputs:

With custom glyphs-difference:

In the above screenshots, I have used the GUI-application Tower, but it works on the command line as well:

Steps 1 and 2 can be applied to any file-format, not just .glyphs files. The main thing you have to change is the xfuncname, which requires a different regular expression for different file-formats. (Some formats might not even need this, UFO for example already splits glyphs into separate files.)
For more information check out the Git documentation, especially the section Defining a custom hunk-header. Note the terminology:
