-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix bold and italic for custom fonts #5 # Problem Fix for issue #5 If a custom font is specified as the base font, strong and emphasis don't bold and italic respectively. Example: ```Swift let style = StyleSheet.default.duplicate().mutate( block: [ .document: [ .textStyle(.custom(name: .custom("Avenir-Medium"), size: .fixed(18))), .backgroundColor(.white), .textColor(.black) ], ]) ``` There are two underlying bugs. 1. The first is `NS/UIFont.Weight` only works on system fonts regardless of how it's specified. So even though it can be combined in `NS/UIFontDescriptor.FontAttribute` it is ignored. 1. The second bug is how the symbolic traits (which is how italic is done) are modified on a `NS/UIFontDescriptor`. They have to be specified via `withSymbolTraits` builder method, and not manually built up in `NS/UIFontDescriptor.FontAttribute` dictionary. `withSymbolTraits` appears to have some magic logic in it that will actually change the font name based on if bold or italic are requested. # Solution First, remove `NativeFontWeight` as a way to specify bold, as it can't be made to work for anything other than system fonts. Second, change `FontTraits` to an `OptionSet` and add `.bold` as an option (in addition to the existing `.italic`). Italic is specified in the same way as before, but bold is now specified by setting the `.bold` `FontTraits`. Finally, change how `NS/UIFontDescriptor` are constructed to ensure they use `withSymbolTraits` instead of being manually constructed dictionaries. The result is bolds are a bit less dark on iOS, but basically the same on macOS. Also added a snapshot spec for bolding/italicizing a custom font to help with regressions. Several snapshot specs were updated because system updates caused differences in kerning. :-/ * Turn off snapshot specs since Github can't run them on a recent OS
- Loading branch information
1 parent
e8ef002
commit 0020061
Showing
73 changed files
with
93 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.