This library provides Python wrappers for the CoreText framework on macOS, enabling Python applications to interact with macOS's advanced text layout and font rendering capabilities. It is part of the larger PyObjC project, which bridges Python and Objective-C/Cocoa. The current version is 12.1, and releases typically align with new macOS SDKs and Python versions.
pip install pyobjc-framework-coretextVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to import and use basic CoreText functions to create and inspect a font object. It checks for the framework's availability and then uses `CTFontDescriptorCreateWithNameAndSize` and `CTFontCreateWithFontDescriptor` to instantiate a font, finally printing its display name.
Upgrade to a supported Python version (e.g., Python 3.10 or newer for PyObjC 12.x) or use an older PyObjC version that supports your Python runtime.
Review custom class implementations inheriting from Objective-C objects, especially those overriding `__new__` and `__init__`. Prefer to perform initialization logic within `__new__` or Objective-C designated initializers when possible, or ensure `__init__` is correctly called in cases where it is supported.
If you are working with Objective-C objects directly, especially custom initializers, carefully review reference counting and object lifecycle. You might need to adjust manual retain/release calls or object ownership in more complex scenarios, although Python's garbage collection usually handles this.
Avoid using PyObjC with Python 3.13's free-threading mode in production environments until this feature is declared stable and fully supported by PyObjC. Stick to the default GIL-enabled mode for now.