I'm trying to make something that behaves very similarly to a font manager, but I simply can't find any documentation on how I can, for example, add an OpenType font to the list NSFontManager provides. I see even Font Book shows fonts activated through a font manager app, so I want to understand what's happening under the hood. What libraries are being called?
Thank you!
It took me quite some time, but here's the way to go.
CTFontManagerRegisterFontURLs does exactly what I was looking for on macOS. Also, session 227 from 2019's WWDC has more info on it, albeit focused on iOS.
Apple has an old archived article entitled Mac OS X: Font locations and their purposes which has a section on manually managing fonts:
[...] You may install fonts by double-clicking them and following the on screen prompts in the Font Book application, or by manually copying or dragging font files to any of the standard Fonts folders in Mac OS X.
The folder in which a font is located determines who can access and use the font. For example: If a user manually installs a new font at
~/Library/Fonts/
, the font is available only to that user. If a root or admin user installs the same font at/Network/Library/Fonts/
, all network users can use the fonts (assuming that the network administrator has set up computers for this type of sharing).Changes to fonts take effect when an application is opened or a user logs in to the account or computer on which the changes occurred. Duplicate fonts are resolved based on the order of precedence defined for the standard Fonts folders and are described from highest to lowest priority below.
I tested this using an empty font I created (Awfulcode-Regular.otf
) and TextEdit and found the changes to be instant. I therefor conjecture that any delay is actually introduced by specific apps rather than macOS itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With