{"id":23338,"library":"babelfont","title":"Babelfont","description":"A Python library to load, examine, and save fonts in multiple formats (OpenType, TrueType, UFO, etc.) with a unified object model. Version 3.1.3; released irregularly, with breaking changes in major versions.","status":"active","version":"3.1.3","language":"python","source_language":"en","source_url":"https://github.com/simoncozens/babelfont","tags":["font","typography","ufo","opentype","truetype","fonttools","design"],"install":[{"cmd":"pip install babelfont","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for font data handling","package":"fonttools","optional":false},{"reason":"Required for UFO format support","package":"ufoLib2","optional":false},{"reason":"Used for interpolation optimization (optional performance boost)","package":"ortools","optional":true}],"imports":[{"note":"Correct import for the main class","symbol":"Babelfont","correct":"from babelfont import Babelfont"},{"note":"Convenience function to load fonts","symbol":"load","correct":"from babelfont import load"}],"quickstart":{"code":"from babelfont import load\n\n# Load a font file\nfont = load(\"example.ttf\")\n# Print font name and glyph count\nprint(font.name, len(font.glyphs))\n\n# Access a specific glyph\nglyph = font.glyphs[\"A\"]\nprint(glyph.unicode, glyph.width)\n\n# Save as UFO\nfont.save(\"example.ufo\")","lang":"python","description":"Load a TrueType font, inspect name and glyphs, then export to UFO."},"warnings":[{"fix":"Use from babelfont import Babelfont or the load function.","message":"v3.0 replaced the old Font object with Babelfont class; direct instantiation of Font is removed.","severity":"breaking","affected_versions":">=3.0"},{"fix":"Access glyphs by name: font.glyphs['A']. For iteration, use list(font.glyphs.values()).","message":"The glyphs attribute is now a dict-like mapping, not a list. Indexing with integer may fail.","severity":"breaking","affected_versions":">=3.0"},{"fix":"Disable logging: import logging; logging.getLogger('babelfont').setLevel(logging.ERROR)","message":"Babelfont may emit many log messages; by default it logs to stderr. This clutters output in scripts.","severity":"gotcha","affected_versions":"all"},{"fix":"E.g., use getattr(font, 'variations', None) or font.glyphs['A'].get('width')","message":"When loading fonts, some format-specific attributes might be missing; always check with hasattr or dict access.","severity":"gotcha","affected_versions":"all"},{"fix":"Switch to the default fonttools backend. Set backend explicitly if needed: load('file', backend='fonttools')","message":"The low-level fontforge backend is deprecated and will be removed in v4.0.","severity":"deprecated","affected_versions":">=3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use from babelfont import Babelfont or use the load function.","cause":"In v3.x the main class was renamed to Babelfont; 'Font' was removed.","error":"AttributeError: module 'babelfont' has no attribute 'Font'"},{"fix":"Iterate over glyph names: for glyph_name in font.glyphs: ... or use glyph_obj = font.glyphs[glyph_name].","cause":"Trying to iterate over font.glyphs as a list, but it's a dict-like mapping; integer indices are not valid.","error":"AttributeError: 'int' object has no attribute 'name'"},{"fix":"Check glyph names with list(font.glyphs.keys()) and match exact casing.","cause":"Glyph names are case-sensitive; the glyph does not exist.","error":"KeyError: 'A'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}