@@ -217,19 +217,23 @@ void *coretext_font_create_with_name_size_and_style(MCStringRef p_name, uint32_t
217217 return (void *)t_font;
218218}
219219
220- void coretext_font_destroy (void *p_font)
220+ bool coretext_font_destroy (void *p_font)
221221{
222222 if (p_font != NULL )
223223 CFRelease ((CTFontRef) p_font);
224+
225+ return true ;
224226}
225227
226- void coretext_font_get_metrics (void *p_font, float & r_ascent, float & r_descent)
228+ bool coretext_font_get_metrics (void *p_font, float & r_ascent, float & r_descent)
227229{
228230 r_ascent = CTFontGetAscent ((CTFontRef) p_font);
229231 r_descent = CTFontGetDescent ((CTFontRef) p_font);
232+
233+ return true ;
230234}
231235
232- void coretext_get_font_names (MCListRef &r_names)
236+ bool coretext_get_font_names (MCListRef &r_names)
233237{
234238 CTFontCollectionRef t_fonts;
235239 t_fonts = CTFontCollectionCreateFromAvailableFonts (NULL );
@@ -241,8 +245,10 @@ void coretext_get_font_names(MCListRef &r_names)
241245 MCListCreateMutable (' \n ' , &t_names);
242246
243247 char t_cstring_font_name[256 ];
248+ bool t_success;
249+ t_success = true ;
244250
245- for (CFIndex i = 0 ; i < CFArrayGetCount (t_descriptors); i++)
251+ for (CFIndex i = 0 ; t_success && i < CFArrayGetCount (t_descriptors); i++)
246252 {
247253 CTFontDescriptorRef t_font;
248254 t_font = (CTFontDescriptorRef)CFArrayGetValueAtIndex (t_descriptors, i);
@@ -252,7 +258,7 @@ void coretext_get_font_names(MCListRef &r_names)
252258
253259 if (t_font_name != NULL && CFStringGetCString (t_font_name, t_cstring_font_name, 256 , kCFStringEncodingMacRoman ) &&
254260 t_cstring_font_name[0 ] != ' %' && t_cstring_font_name[0 ] != ' .' )
255- /* UNCHECKED */ MCListAppendCString (*t_names, t_cstring_font_name);
261+ t_success = MCListAppendCString (*t_names, t_cstring_font_name);
256262
257263 if (t_font_name != NULL )
258264 CFRelease (t_font_name);
@@ -263,38 +269,46 @@ void coretext_get_font_names(MCListRef &r_names)
263269 if (t_fonts != NULL )
264270 CFRelease (t_fonts);
265271
266- /* UNCHECKED */ MCListCopy (*t_names, r_names);
272+ if (t_success)
273+ t_success = MCListCopy (*t_names, r_names);
274+ return t_success;
267275}
268276
269- void core_text_get_font_styles (MCStringRef p_name, uint32_t p_size, MCListRef &r_styles)
277+ bool core_text_get_font_styles (MCStringRef p_name, uint32_t p_size, MCListRef &r_styles)
270278{
271279 CTFontRef t_font_family;
272280 t_font_family = (CTFontRef)coretext_font_create_with_name_and_size (p_name, p_size);
273281
274282 MCAutoListRef t_styles;
275283 /* UNCHECKED */ MCListCreateMutable (' \n ' , &t_styles);
284+
285+ bool t_success;
286+ t_success = true ;
276287
277288 if (t_font_family != NULL )
278289 {
279290 CTFontSymbolicTraits t_traits;
280291 t_traits = CTFontGetSymbolicTraits (t_font_family);
281292
282- /* UNCHECKED */ MCListAppendCString (*t_styles, " plain" );
293+ t_success = MCListAppendCString (*t_styles, " plain" );
283294
284- if (t_traits & kCTFontBoldTrait )
285- /* UNCHECKED */ MCListAppendCString (*t_styles, " bold" );
295+ if (t_success && t_traits & kCTFontBoldTrait )
296+ t_success = MCListAppendCString (*t_styles, " bold" );
286297
287- if (t_traits & kCTFontItalicTrait )
288- /* UNCHECKED */ MCListAppendCString (*t_styles, " italic" );
298+ if (t_success && t_traits & kCTFontItalicTrait )
299+ t_success = MCListAppendCString (*t_styles, " italic" );
289300
290- if (t_traits & kCTFontBoldTrait && t_traits & kCTFontItalicTrait )
291- /* UNCHECKED */ MCListAppendCString (*t_styles, " bold-italic" );
301+ if (t_success && t_traits & kCTFontBoldTrait && t_traits & kCTFontItalicTrait )
302+ t_success = MCListAppendCString (*t_styles, " bold-italic" );
292303 }
293304
294305 if (t_font_family != NULL )
295306 CFRelease (t_font_family);
296307
297- /* UNCHECKED */ MCListCopy (*t_styles, r_styles);
308+ if (t_success)
309+ t_success = MCListCopy (*t_styles, r_styles);
310+
311+ return t_success;
298312}
299313
300314bool coretext_font_load_from_path (MCStringRef p_path, bool p_globally)
0 commit comments