Skip to main content

Coverage Status Python Versions PyPI Version

ufoNormalizer

Provides a standard formatting so that there are meaningful diffs in version control rather than formatting noise.

Examples of formatting applied by ufoNormalizer include:

  • Changing floating-point numbers to integers where it doesn't alter the value (e.g. x="95.0" becomes x="95" )
  • Rounding floating-point numbers to 10 digits
  • Formatting XML with tabs rather than spaces

Usage in RoboFont

RoboFont comes with ufoNormalizer pre-installed, and you can set a preference to normalize UFOs on save.

Simply open the Scripting Window and run the following code:

from mojo.UI import setDefault, getDefault

setDefault("shouldNormalizeOnSave", True)

print("shouldNormalizeOnSave is set to " + str(getDefault("shouldNormalizeOnSave")))

Advanced usage

Installation

Install these tools using the pip package hosted on PyPI:

pip install --upgrade ufonormalizer

Command line

Use on the command line:

ufonormalizer <path>/font.ufo

To view all arguments, run:

ufonormalizer --help

Note: if you are working on a UFO within RoboFont and run ufoNormalizer on that UFO, RoboFont will notify you that the UFO has been updated externally. Simply accept this by selecting "Update."

Automating via Git hooks

Beyond basic command-line usage, ufoNormalizer can be used in an automated manner.

Of course, you can automate it to run from a shell script or a Python script. One useful possibility is using it within a Git hook.

Git hooks are scripts that Git executes before or after events such as: commit, push, and receive. Git hooks are a built-in feature - no need to download anything. Git hooks are run locally. – from Git Hooks

It's easy to set up a git hook that will normalize ufos in a project immediately before each commit, ensuring that you only ever commit clean UFO data.

In a Git project, navigate to /.git/hooks and replace pre-commit.sample with the following code, then remove the file extension:

#!/bin/sh

# A hook script to verify what is about to be committed.
# Called by "git commit" with no arguments.
#
# Uses bash syntax to call arguments as needed.
#
# To enable this hook, save this to <your_project>/.git/hooks/pre-commit (with no file extension)

set -e

for ufo in ./*.ufo; do
    ufonormalizer "$ufo"
done

Now, each time you commit, all .ufos in your Git project will be normalized before being recorded by Git.

Because this hook is setup within the immediate project, this configuration will only apply to the immediate project. You will need to update each project to use this Git hook if you wish to normalize UFOs elsewhere. If you want this hook to be added to all future git projects, you can configure a global git template. However, this approach probably doesn't make sense if you also work on projects that don't involve UFO files.

Release files for ufonormalizer 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ufonormalizer 0.6.3
File Size Uploaded
ufonormalizer-0.6.3.tar.gz 33.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ufonormalizer 0.6.3
File Interpreter ABI Platform
ufonormalizer-0.6.3-py3-none-any.whl Python 3 none any Details

Total release size: 51.6 kB

Release files / ufonormalizer-0.6.3.tar.gz

Download URL ufonormalizer-0.6.3.tar.gz
Size 33.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c3271097aba9d290594b75c2b432cf681088b74fe3eb334ca4319324e2bddd4e
BLAKE2b-256 checksum
How to use checksums
f267557823860d2bc7a340ce4772261e35c969e2243621ec32fae62801a4ba6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.21

Release files / ufonormalizer-0.6.3-py3-none-any.whl

Download URL ufonormalizer-0.6.3-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
09015963e0fec72ca96f2128bcace869990dead40e8f4872a02a014d2a2f024f
BLAKE2b-256 checksum
How to use checksums
e95bb6751a54387344cb7cef779a231df68dea77b7adbbab924f5e4f2056cedb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.21

Release history Release notifications | RSS feed

This release

0.6.3 This release

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page