From d613cc3519af2ecb9ca0be9d6a1d1c5165b30e63 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 10 Jul 2011 15:41:22 +1000 Subject: If requested font can't be created use same font without bold or italic. If that fails, use Monaco. --- cocoa/QuartzTextStyleAttribute.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'cocoa/QuartzTextStyleAttribute.h') diff --git a/cocoa/QuartzTextStyleAttribute.h b/cocoa/QuartzTextStyleAttribute.h index 41582e8ec..3171ca446 100644 --- a/cocoa/QuartzTextStyleAttribute.h +++ b/cocoa/QuartzTextStyleAttribute.h @@ -43,13 +43,28 @@ public: // create a font and then a copy of it with the sym traits CTFontRef iFont = ::CTFontCreateWithName(fontName, size, NULL); fontid = ::CTFontCreateCopyWithSymbolicTraits(iFont, size, NULL, desiredTrait, traitMask); - CFRelease(iFont); + if (fontid) + { + CFRelease(iFont); + } + else + { + // Traits failed so use base font + fontid = iFont; + } } else { // create the font, no traits fontid = ::CTFontCreateWithName(fontName, size, NULL); } + + if (!fontid) + { + // Failed to create requested font so use font always present + fontid = ::CTFontCreateWithName((CFStringRef)@"Monaco", size, NULL); + } + } CTFontRef getFontID() -- cgit v1.2.3