Posts

Post not yet marked as solved
1 Replies
893 Views
Hello,We have a macOS app (mostly C++, built in Xcode 10) which lets users select fonts and store references to them, by name, in their documents. We currently use Core Text functions to iterate and locate fonts, which mostly works fine. However, some older documents, from older versions of our app, have QuickDraw font names stored in them. I'm trying to convert these QuickDraw names to "real" font names; or more specifically, to idenfity an installed CTFontRef font from a QuickDraw name.I see the function CTFontCreateWithQuickdrawInstance, which seems to be exactly what I need, but I can't seem to get it to return anything but NULL/nil, at least not on Mojave. I've done a lot of searching, but have not been able to find any usage examples.So my question is: Assuming I'm starting out with a std::string in Mac Roman encoding, which contains a valid Quick Draw font name, and that I have installed on my system the same font from which the QuickDraw name was retrieved, in an older version of our app (probably via an ancient call like FMGetFontFamilyName), how can I call CTFontCreateWithQuickdrawInstance to get that font (i.e. to return something other than NULL)?Here's what I have so far: std::string QuickDrawName = "Charcoal"; // actually gotten from a CFStringRef in kCFStringEncodingMacRoman unsigned char pascalName[256] = ""; *pascalName = (unsigned char)QuickDrawName.length(); strcpy((char*)pascalName + 1, QuickDrawName.c_str()); CTFontRef foundFontRef = CTFontCreateWithQuickdrawInstance(pascalName, 0, 0, 0); // always returns NULLWhat am I doing wrong?Thanks,Dan
Posted
by Dan.Korn.
Last updated
.