如果粗体字体文件不可用,是否可以增加字体的粗体?

Is it possible to increase the boldness of the font if the bold font file is not available?

我在 iOS 应用程序中使用自定义字体。我已经为常规变体添加了字体文件。但是,我没有加粗的字体文件。

是否可以在没有粗体字体文件的情况下增加字体的粗体度?

您可以使用具有负 strokeWidth 属性的 NSAttributedString

let range = NSRange(location:  0, length: attributedString.length
attributedString.addAttribute(.strokeWidth, value: NSNumber(value: -3.0), range: range))