Registry / devops / defcon

defcon

JSON →
library0.12.2pypypi✓ verified 85d ago

defcon provides a set of flexibly object-oriented Python classes for representing and manipulating UFO font data. It is used in font tooling like fontmake and is the recommended Python layer for UFO font development. Current version 0.12.2, with active development on GitHub.

pip install defcon
INSTALL
IMPORT
SIG · DEFCON
D
defcon
devopspythonv0.12.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Font
from defcon import Font
import defcon; defcon.Font()
Direct import of submodules is correct, not package attribute access.

Opens a UFO file, reads font info, and adds a new glyph.

from defcon import Font from defcon.objects.glyph import Glyph # Open a UFO font font = Font('MyFont.ufo') print(font.info.unitsPerEm) # Create a new glyph glyph = Glyph() glyph.name = 'A' font.insertGlyph(glyph, name='A') # Save (if needed: font.save())
Debug
Known issues
breakingdefcon 0.12.0 dropped support for Python 2 and older UFO versions.
fix
Upgrade to Python 3.9+ and ensure your UFO files conform to UFO 3.
affects: >=0.12.0
gotchaModifying a Font object does not automatically save to disk; you must call .save() explicitly.
fix
Always call font.save() after making changes if persistence is desired.
affects: all
gotchaGlyph objects are not automatically anchored to a Font; insert them via font.insertGlyph() or font.glyphs.append(). Direct assignment may lose data.
fix
Use font.insertGlyph(glyph) or append to font.glyphs list to properly register the glyph.
affects: all
Errors
Common errors & fixes
AttributeError: module 'defcon' has no attribute 'Glyph'
Defcon's top-level exports changed; Glyph is no longer directly on defcon.
fix
Use from defcon.objects.glyph import Glyph or from defcon import Glyph (if available). In recent versions, import from defcon.objects.
TypeError: 'NoneType' object is not iterable when iterating font.glyphs
Font object not properly initialized or file path invalid.
fix
Ensure the UFO path exists and is a valid .ufo directory. Check that the font was loaded successfully.
defcon.errors.UFOError: File format not supported
UFO file is corrupt or uses an older version not supported by defcon.
fix
Use a UFO 3 compliant source. If upgrading from UFO 2, convert via ufoLib or ufo2ft.
Upgrade
Version history
0.12.2latest on PyPI · released Jul 16, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
defcon — pip install defcon · libregistry