{"id":23374,"library":"booleanoperations","title":"booleanOperations","description":"Boolean operations on paths (union, intersection, difference, xor) for font glyph contours. Version 0.10.0, released 2024-04-29. Uses pyclipper (Clipper) for computation. Requires Python >=3.9. Maintained by TypeMyType.","status":"active","version":"0.10.0","language":"python","source_language":"en","source_url":"https://github.com/typemytype/booleanOperations","tags":["font","boolean operations","glyph","path","clipper","type design"],"install":[{"cmd":"pip install booleanoperations","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for font data structures (Glyph, Pen, etc.)","package":"fonttools","optional":false},{"reason":"Computational geometry library for boolean operations","package":"pyclipper","optional":false}],"imports":[{"note":"Direct import of the module does not expose the class; must import the class explicitly.","wrong":"import booleanOperations","symbol":"BooleanOperations","correct":"from booleanOperations import BooleanOperations"},{"note":"Manager class for batch operations on glyph objects.","wrong":null,"symbol":"BooleanOperationManager","correct":"from booleanOperations import BooleanOperationManager"}],"quickstart":{"code":"from fontTools.pens.t2Pen import T2Pen\nfrom fontTools.pens.recordingPen import RecordingPen\nfrom fontTools.ttLib import TTFont\nfrom fontTools.pens.pointPen import PointToSegmentPen\nfrom booleanOperations import BooleanOperations\n\n# Load a font, get a glyph\nfont = TTFont('MyFont.otf')\nglyph = font.getGlyphSet()['A']\n\n# Create a rectangle as a closed path\nrect_pen = RecordingPen()\nrect_pen.moveTo((0, 0))\nrect_pen.lineTo((100, 0))\nrect_pen.lineTo((100, 100))\nrect_pen.lineTo((0, 100))\nrect_pen.closePath()\n\n# Get glyph outline\nglyph_pen = RecordingPen()\nglyph.draw(glyph_pen)\n\n# Perform union\nop = BooleanOperations()\nresult_pen = RecordingPen()\nop.union(glyph_pen.value, rect_pen.value, result_pen)\nprint('Union result:', result_pen.value)","lang":"python","description":"Basic union of a glyph outline and a rectangle. Output is a recording pen value."},"warnings":[{"fix":"Upgrade to Python 3.9+ for latest version.","message":"Support for Python 2.7 dropped in v0.9.0. Requires Python >=3.6 (v0.9.0) or >=3.9 (v0.10.0).","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Ensure all input paths are closed (last point equals first).","message":"Open contours (not closed) raise OpenContourError. Only closed paths are supported.","severity":"gotcha","affected_versions":">=0.8.0"},{"fix":"Upgrade to 0.8.2 or later to avoid dropped contours.","message":"Self-intersecting contours with zero area are dropped (may produce unexpected results).","severity":"gotcha","affected_versions":"<0.8.2"},{"fix":"Ensure fonttools is 3.32.0 or higher.","message":"ufoLib dependency removed in v0.8.1; now requires fonttools >=3.32.0.","severity":"breaking","affected_versions":">=0.8.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"pip install booleanoperations; then use 'from booleanOperations import ...'","cause":"Wrong import path; installed package is booleanoperations (lowercase) but import is case-sensitive. Usually import 'from booleanOperations' correct.","error":"ModuleNotFoundError: No module named 'booleanOperations'"},{"fix":"Use 'from booleanOperations import BooleanOperations'","cause":"Imported the module itself (import booleanOperations) instead of the class.","error":"AttributeError: module 'booleanOperations' has no attribute 'BooleanOperations'"},{"fix":"Use correct method names: union, intersection, difference, xor (all lowercase).","cause":"Attempted to use a method that does not exist (e.g., 'booleanOperations.BooleanOperations.XOR' with wrong case).","error":"ValueError: The operation must be one of: union, intersection, difference, xor"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}