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

Initial implementation of Cocoa and iOS font loading. #1399

Merged
merged 14 commits into from
Oct 19, 2023

Conversation

freakboy3742
Copy link
Member

@freakboy3742 freakboy3742 commented Jan 7, 2022

Add font registration to Cocoa and iOS backends.

This supports most use of custom fonts. The only piece missing are variant fonts - fonts where a single font file contains the details for multiple weights/variants. The Endor font is an example of this. Cocoa and iOS will render the font, but not with bold/italic variations, even if the font allows it. Fonts that are non-variant (e.g., the Roboto fonts) aren't affected by this.

My inclination is to say this is complete as a fix for #1837; document the lack of support for variant fonts as a platform detail, and open a ticket to address the missing feature once this lands.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@freakboy3742 freakboy3742 mentioned this pull request Jan 7, 2022
4 tasks
@freakboy3742 freakboy3742 changed the title Initial implementation of Cococa font loading. Initial implementation of Cocoa font loading. Apr 7, 2023
@freakboy3742 freakboy3742 added the macOS The issue relates to Apple macOS support. label May 3, 2023
@mhsmith mhsmith changed the title Initial implementation of Cocoa font loading. Initial implementation of Cocoa and iOS font loading. Oct 3, 2023
@mhsmith mhsmith added the iOS The issue relates to Apple iOS mobile support. label Oct 3, 2023
@mhsmith
Copy link
Member

mhsmith commented Oct 7, 2023

Cocoa uses the internal font name (how the file describes the font) rather than allowing for an externally registered name.

GTK may have the same issue, though it hasn't been a problem for the tests so far. If necessary, we could find the internal name using the same library as the Android tests:

font = TTFont(family.getFont(0).getFile().getPath())
assert font["name"].getDebugName(1) == expected

@freakboy3742
Copy link
Member Author

@mhsmith I've taken a swing at getting this working with fonttools - and it mostly works on both iOS and Cocoa. There's still an issue with fonts like Endor that support multiple weights/variants from a single file.

I still think it should be possible to get this working without needing fonttools, but a working solution based on a third party package is a better option than something not working at all.

@freakboy3742
Copy link
Member Author

The macOS build is currently failing because of an issue with binary merging; beeware/briefcase#1483 should address the problem.

@freakboy3742 freakboy3742 marked this pull request as ready for review October 10, 2023 13:44
@freakboy3742 freakboy3742 requested a review from mhsmith October 10, 2023 13:53
@mhsmith mhsmith merged commit 7a46d41 into beeware:main Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS The issue relates to Apple iOS mobile support. macOS The issue relates to Apple macOS support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for custom fonts on remaining platforms
2 participants