CTFont/NSFont Bridging is broken

Originator:motownavi
Number:rdar://15341349 Date Originated:29-Oct-2013
Status:Open Resolved:
Product:Mac OS X Product Version:Mac OS X 10.9, 13A603
Classification:Other Bug Reproducible:Always
 
"Toll-free bridging" means that you can cast from one type to another and have it behave as if it were of the other type. This is not the case with NSFont and CTFont, which the documentation claims are bridged.

To reproduce:

/* build with cc test.m -framework Cocoa -o test */

#include <Cocoa/Cocoa.h>

int main() {
  CFTypeID ct_font_type_id = CTFontGetTypeID();
  NSLog(@"CTFontGetTypeID is %lu", ct_font_type_id);

  NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
  CTFontRef ct_font = (CTFontRef)font;
  CFTypeID type_id = CFGetTypeID(ct_font);
  NSLog(@"CFGetTypeID for system font is %lu", type_id);
  assert(type_id == ct_font_type_id);
}

Expected:

The type ids match.

Actual results:

~/b/ctfont> ./test
2013-10-29 11:07:58.792 test[91007:507] CTFontGetTypeID is 256
2013-10-29 11:07:58.802 test[91007:507] CFGetTypeID for system font is 1
Assertion failed: (type_id == ct_font_type_id), function main, file test.m, line 13.
fish: Job 1, './test' terminated by signal SIGABRT (Abort)

Mac OS X 10.9, 13A603.

I don't know if this is a regression.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!