NSGlyph to CGGlyph in Swift (UInt32 to UInt16)

476 Views Asked by At

How can I go from an NSGlyph to a CGGlyph?

        let ctGlyph = glyph as CGGlyph

I see that:

typealias CGGlyph = CGFontIndex
typealias CGFontIndex = UInt16

typealias NSGlyph = UInt32

So how do I do the typecast?

I tried:

let ctGlyph = glyph as CGGlyph

but it gives me:

error: 'NSGlyph' is not convertible to 'CGGlyph'

1

There are 1 best solutions below

0
On BEST ANSWER

You can't cast, but you can use an initializer:

let ctGlyph = CGGlyph(glyph)