Last active
March 1, 2019 07:27
-
-
Save shengyang998/c453b0a59f8156520f4f407048643cd9 to your computer and use it in GitHub Desktop.
Chinese font oblique type
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
```swift | |
func modifyTraits(_ traits: UIFontDescriptorSymbolicTraits, enable: Bool) -> UIFont { | |
// FIXME: - Chinese oblique type | |
if newTraits.contains(.traitItalic) && familyDescriptor.postscriptName.hasPrefix(".PingFangSC") { | |
let _c = tanf(Float(15.0 * CGFloat.pi / 180.0)) | |
let matrix = CGAffineTransform(a: 1, b: 0, c: CGFloat(_c), d: 1, tx: 0, ty: 0) | |
let chineseItalicDescriptor = UIFontDescriptor(name: "", matrix: matrix) | |
return UIFont(descriptor: chineseItalicDescriptor, size: pointSize) | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment