Jay
Jay

Reputation: 4540

NSGlyph to CGGlyph in Swift (UInt32 to UInt16)

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'

Upvotes: 2

Views: 448

Answers (1)

Nate Cook
Nate Cook

Reputation: 93276

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

let ctGlyph = CGGlyph(glyph)

Upvotes: 4

Related Questions