Cannot have font "STHeitiTC-Light" display with correct line height in iOS9

UIFont(name: "STHeitiTC-Medium", size: fontSize)!

Using this font, the line line height become very tall. Can apple include old fonts in iOS9?

Replies

Run the following code in iOS8 and iOS9, the font was substituted in iOS9. The line height was taller a lot. The font displayed become very small.

Make the font substitution closer to iOS8 or even no substitute font was used.


var chineseFont = "STHeitiTC-Medium"

for i in [20, 10, 8] {

let *** = UIFont(name: chineseFont, size: CGFloat(i))!

print("\(chineseFont) \(***) fontSize:\(i) lineHeight:\(***.lineHeight) pointSize:\(***.pointSize) ascender:\(***.ascender) descender:\(***.descender) capHeight:\(***.capHeight)")

}

iOS9

  1. STHeitiTC-Medium 20 <UICTFont: 0x7f81795cfd50> font-family: "PingFangTC-Medium"; font-weight: normal; font-style: normal; font-size: 20.00pt fontSize:20.0 lineHeight:28.0 pointSize:20.0 ascender:21.2 descender:-6.8 capHeight:17.2)
  2. STHeitiTC-Medium 10 <UICTFont: 0x7f81795c7720> font-family: "PingFangTC-Medium"; font-weight: normal; font-style: normal; font-size: 10.00pt fontSize:10.0 lineHeight:14.0 pointSize:10.0 ascender:10.6 descender:-3.4 capHeight:8.6)
  3. STHeitiTC-Medium 8 <UICTFont: 0x7f8179614cf0> font-family: "PingFangTC-Medium"; font-weight: normal; font-style: normal; font-size: 8.00pt fontSize:8.0 lineHeight:11.2 pointSize:8.0 ascender:8.48 descender:-2.72 capHeight:6.88)

iOS8

  1. STHeitiTC-Medium 20 <UICTFont: 0x7fc802438c40> font-family: "STHeitiTC-Medium"; font-weight: bold; font-style: normal; font-size: 20.00pt fontSize:20 lineHeight:20.0 pointSize:20.0 ascender:17.2 descender:-2.8 capHeight:14.36
  2. STHeitiTC-Medium <UICTFont: 0x7fc8027b88f0> font-family: "STHeitiTC-Medium"; font-weight: bold; font-style: normal; font-size: 10.00pt fontSize:10 lineHeight:10.0 pointSize:10.0 ascender:8.6 descender:-1.4 capHeight:7.18
  3. STHeitiTC-Medium <UICTFont: 0x7fc8027b82c0> font-family: "STHeitiTC-Medium"; font-weight: bold; font-style: normal; font-size: 8.00pt fontSize:8 lineHeight:8.0 pointSize:8.0 ascender:6.88 descender:-1.12 capHeight:5.744

Was there ever any response for this? My app was using this font exclusively, and now it looks all strange in ios 9.

It seems that the font family HeitiTC is removed from iOS 9, and the system just chose the other available Chinese font to adapt which caused your layout to appear strangely. You can use the following snippet to check if it's still available on your device:

for (NSString *fontFamily in [UIFont familyNames]) {
     NSLog(@"Family: %@", fontFamily);
     for (NSString *fontName in [UIFont fontNamesForFamilyName: family]) {
          NSLog(@"  %@", fontName");
     }
}

What I did was to include a copy of the font file in my app bundle, and it worked like a charm 🙂

Here's a tutorial of how to add custom fonts into your app:

http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/