Italic Font not work for Chinese/Japanese/Korean on iOS 7

后端 未结 3 1141
情深已故
情深已故 2021-02-11 10:59

I want to set Italic Font Style in UITextView, but Italic Font just not work for Chinese/Japanese/Korean on iOS 7.Could anyone help?

3条回答
  •  一生所求
    2021-02-11 11:35

    Because there are no italic styled Chinese fonts on iOS, you need to use affine transformation to slant the normal styled Chinese font.

    The code below gives a 15° slant to Heiti SC Medium:

    CGAffineTransform matrix = CGAffineTransformMake(1, 0, tanf(15 * (CGFloat)M_PI / 180), 1, 0, 0);
    UIFontDescriptor *desc = [UIFontDescriptor fontDescriptorWithName:@"Heiti SC Medium" matrix:matrix];
    textView.font = [UIFont fontWithDescriptor:desc size:17];
    

    Real effect:

    enter image description here

提交回复
热议问题