Skip to content

Instantly share code, notes, and snippets.

@shengyang998
Last active March 1, 2019 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shengyang998/c453b0a59f8156520f4f407048643cd9 to your computer and use it in GitHub Desktop.
Save shengyang998/c453b0a59f8156520f4f407048643cd9 to your computer and use it in GitHub Desktop.
Chinese font oblique type
```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