How do I get an NSFont object from a CGFont or CTFont object?
Asked Answered
C

1

10

I am dealing with loading a TTF from Resource only. This question helped me answer part 1. But now I need a NSFont from a CGFont or CTFont.

This is for a Mac only application.

Corrinnecorrival answered 9/2, 2011 at 8:30 Comment(0)
S
16

How to get an NSFont from a CGFont

Use CTFontCreateWithGraphicsFont.

How to get an NSFont from a CTFont

Do nothing. You already have one. NSFont and CTFont are toll-free bridged, so a CTFont is an NSFont and vice versa.

Suziesuzuki answered 9/2, 2011 at 19:5 Comment(2)
I thought toll-free bridged means only you can send messages of the other class to each other. Now I assume it also means you can use it directly as a substitute in place of the other.Corrinnecorrival
Too bad Xcode still doesn't hint at this very well. If at all.Spirograph

© 2022 - 2024 — McMap. All rights reserved.