NSGlyph到Swift中的CGGlyph(UInt32到UInt16)

时间:2014-11-12 19:53:44

标签: ios macos swift core-text

如何从NSGlyph转到CGGlyph?

        let ctGlyph = glyph as CGGlyph

我明白了:

typealias CGGlyph = CGFontIndex
typealias CGFontIndex = UInt16

typealias NSGlyph = UInt32

那么如何进行类型转换?

我试过了:

let ctGlyph = glyph as CGGlyph

但它给了我:

  

错误:' NSGlyph'不能转换为' CGGlyph'

1 个答案:

答案 0 :(得分:3)

您无法投射,但您可以使用初始值设定项:

let ctGlyph = CGGlyph(glyph)