@@ -226,90 +226,45 @@ int4 MCScreenDC::textwidth(MCFontStruct *f, const char *s, uint2 len, bool p_uni
226226 }
227227}
228228
229- // TD-2013-05-29 [[ DynamicFonts ]]
230- MCVariableValue *s_font_array;
231-
232- // p_path is a fully resolved path
233- Exec_errors MCScreenDC::loadfont (const char *p_path, bool p_load_globally)
229+ // TD-2013-07-01 [[ DynamicFonts ]]
230+ bool MCScreenDC::loadfont (const char *p_path, bool p_globally, void *& r_loaded_font_handle)
234231{
235232 FSRef t_ref;
236233 FSSpec t_fsspec;
237234 OSErr t_os_error;
238235
239236 t_os_error = MCS_pathtoref (p_path, &t_ref); // resolves and converts to UTF8.
240237 if (t_os_error != noErr)
241- return EE_FONT_BADFILEEXP ;
238+ return false ; // EE_FONT_BADFILEEXP;
242239
243240 t_os_error = MCS_fsref_to_fsspec (&t_ref, &t_fsspec);
244241 if (t_os_error != noErr)
245- return EE_FONT_BADFILEEXP ;
242+ return false ; // EE_FONT_BADFILEEXP;
246243
247244 ATSFontContext t_context = kATSFontContextLocal ;
248- if (p_load_globally )
245+ if (p_globally )
249246 t_context = kATSFontContextGlobal ;
250247
251- // create array to store container.
252- if (s_font_array == NULL )
253- {
254- s_font_array = new MCVariableValue;
255- if (s_font_array == NULL )
256- return EE_FONT_CANTLOAD ;
257- }
258-
259248 ATSFontContainerRef t_container = NULL ;
260-
249+
261250 // Note: ATSFontActivateFromFileReference should be used from 10.5 onward.
262251 // ATSFontActivateFromFileSpecification deprecated in 10.5.
263252 t_os_error = ATSFontActivateFromFileSpecification (&t_fsspec, t_context, kATSFontFormatUnspecified , NULL , kATSOptionFlagsDefault , &t_container);
264253 if (t_os_error != noErr)
265- return EE_FONT_CANTLOAD ;
266-
267- // Add font to list of fonts
268- MCVariableValue *t_font;
269- uint32_t index = 1 ;
270- if (s_font_array -> is_array ())
271- index = s_font_array -> get_array () -> getnfilled () + 1 ;
272-
273- MCExecPoint *t_ep = new MCExecPoint ();
274-
275- s_font_array -> lookup_index (*t_ep, index, t_font);
254+ return false ; // EE_FONT_CANTLOAD;
276255
277- t_ep -> setcstring (p_path);
278- t_font -> store_element (*t_ep, " name" );
256+ // TODO: store t_container in r_loaded_font_handle
279257
280- // s_font_map . insert(make_pair(std::string(t_resolved_path), t_container));
281-
282- return EE_UNDEFINED ;
258+ return true ;
283259}
284260
285261
286- Exec_errors MCScreenDC::unloadfont (const char *p_path, bool p_load_globally )
262+ bool MCScreenDC::unloadfont (const char *p_path, bool p_globally, void *r_loaded_font_handle )
287263{
288- /* const char *t_error;
289- t_error = NULL;
290-
291- // Get resolved path for storage in t_container (should this be UTF8 version of path?)
292- char *t_resolved_path;
293- t_resolved_path = MCS_resolvepath(p_filename);
294-
295- ATSFontContainerRef t_container;
296- t_container = NULL;
264+ OSStatus t_status;
265+ t_status = ATSFontDeactivate ((ATSFontContainerRef)r_loaded_font_handle, NULL , kATSOptionFlagsDefault );
297266
298- if (t_error == NULL)
299- {
300- t_container = s_font_map[t_resolved_path];
301- if (t_container == NULL)
302- t_error = "couldn't unload font";
303- }
304-
305- if (t_error == NULL)
306- {
307- OSStatus t_status;
308- t_status = ATSFontDeactivate(t_container, NULL, kATSOptionFlagsDefault);
309- s_font_map . erase(t_resolved_path);
310- }
311- */
312- return EE_UNDEFINED ;
267+ return (t_status == noErr);
313268}
314269
315270//
0 commit comments