Skip to content

Allow font creation to fail and fallback to a safe font#5

Merged
chriseidhof merged 1 commit intoobjcio:mainfrom
onevcat:fix/optional-font
Jul 5, 2023
Merged

Allow font creation to fail and fallback to a safe font#5
chriseidhof merged 1 commit intoobjcio:mainfrom
onevcat:fix/optional-font

Conversation

@onevcat
Copy link
Copy Markdown
Member

@onevcat onevcat commented Jul 4, 2023

For some languages (such as CJK), there is no "italic" version of the font. For these fonts, if the traits contains .italic, NSFont.init(descriptor:size:) will fail to create the font and return nil.

I understand that it can be an "author error" to use a font without italic version, but use *some word* to make text italic. But I guess a hard crash for this error is too strict. Unless modifying every italic case in the original text, I won't be able to use a new font, which is not ideal and painful.

@onevcat
Copy link
Copy Markdown
Member Author

onevcat commented Jul 4, 2023

截屏2023-07-05 0 04 18

@onevcat onevcat force-pushed the fix/optional-font branch from 11a7cb0 to 487e399 Compare July 5, 2023 01:41
@chriseidhof
Copy link
Copy Markdown
Contributor

This makes sense, thank you!

@chriseidhof chriseidhof merged commit 4ebe6de into objcio:main Jul 5, 2023
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 this pull request may close these issues.

2 participants