Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search paths for fonts on Apple platforms #50

Open
waywardmonkeys opened this issue May 1, 2024 · 1 comment · May be fixed by #71
Open

Search paths for fonts on Apple platforms #50

waywardmonkeys opened this issue May 1, 2024 · 1 comment · May be fixed by #71

Comments

@waywardmonkeys
Copy link
Contributor

Currently, the CoreText source is searching in "/System/Library/Fonts/" for fonts, but it should probably be searching in more than that.

Fonts can be found in:

  • The user's home directory library, but this one is tricky.
  • "/Library/Fonts"
  • "/System/Library/Fonts"
  • "/Network/Library/Fonts"

The user's home directory might be tricky due to sandboxing and so we shouldn't just put together the paths ourselves, but use the system APIs for this instead. (In sandboxed applications, one doesn't have direct access to ~/Library/ but has access to something in ~/Library/Containers/<application id>/data/Library which contains a symlink to the Fonts directory.)

I think the right thing to do would be to use NSSearchPathForDirectoriesInDomains (https://developer.apple.com/documentation/foundation/1414224-nssearchpathfordirectoriesindoma?language=objc) with NSLibraryDirectory or (NSAllLibrariesDirectory, I don't know which) and a mask of NSAllDomainsMask. We should be able to get this from objc2_foundation (https://docs.rs/objc2-foundation/latest/objc2_foundation/fn.NSSearchPathForDirectoriesInDomains.html)

And finally ... there are ALSO fonts in /System/Library/Fonts/Supplemental which should be scanned.

@waywardmonkeys
Copy link
Contributor Author

Ends up: /System/Library/Fonts/Supplemental is already scanned while scanning /System/Library/Fonts ... but the rest remains true!

waywardmonkeys added a commit to waywardmonkeys/parley that referenced this issue Jun 2, 2024
Use the Foundation API to get the list of "Library" directories
and look in each of them for a "Fonts" directory.

This handles the need to search a variety of paths on macOS
to find fonts in the various standard locations like "~/Library/Fonts",
"/System/Library/Fonts", "/Library/Fonts", "/Network/Library/Fonts",
etc.

Fixes linebender#50.
waywardmonkeys added a commit to waywardmonkeys/parley that referenced this issue Jun 2, 2024
Use the Foundation API to get the list of "Library" directories
and look in each of them for a "Fonts" directory.

This handles the need to search a variety of paths on macOS
to find fonts in the various standard locations like "~/Library/Fonts",
"/System/Library/Fonts", "/Library/Fonts", "/Network/Library/Fonts",
etc.

Fixes linebender#50.
waywardmonkeys added a commit to waywardmonkeys/parley that referenced this issue Jun 2, 2024
Use the Foundation API to get the list of "Library" directories
and look in each of them for a "Fonts" directory.

This handles the need to search a variety of paths on macOS
to find fonts in the various standard locations like "~/Library/Fonts",
"/System/Library/Fonts", "/Library/Fonts", "/Network/Library/Fonts",
etc.

Fixes linebender#50.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant