I am trying to convert code that uses NSFont to code that uses CTFont (trying to make it cross-platform for macOS and iOS).
to According to the documentation, and this post, I shouldn't have to do anything to make it work because there is a toll-free bridge between CTFontRef and NSFont.
Later, I am getting the error
error: cannot initialize a parameter of type 'NSFont * _Nonnull' with an lvalue of type 'CTFontRef' (aka 'const __CTFont *')
convertedFont = [fontManager convertFont:convertedFont toNotHaveTrait:NSBoldFontMask];
^~~~~~~~~~~~~
OLD CODE: (keeping NSFontManager for now)
NSFontManager *fontManager = [NSFontManager sharedFontManager];
// NSFont *font = static_cast<NSFont *>(inProperties[theKey]);
// NSFontTraitMask fontTraits = [fontManager traitsOfFont:font];
// NSFont *convertedFont = font;
NEW CODE:
CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)inProperties);
CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, 0, NULL);
CFRelease(descriptor);
CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(font);
CTFontRef convertedFont = font;