static bool MCTextLayoutFontWithLink(MCTextLayoutFont *p_base, MCTextLayoutLinkedFontEntry *p_link, MCTextLayoutFont*& r_font) { LOGFONTA t_logfont; t_logfont = p_base -> info; MCMemoryCopy(&t_logfont . lfFaceName, p_link -> face, MCMax(MCCStringLength(p_link -> face) + 1, sizeof(t_logfont . lfFaceName))); MCTextLayoutFont *t_font; t_font = MCTextLayoutFontFind(t_logfont); if (t_font != nil) { r_font = t_font; return true; } HFONT t_hfont; t_hfont = CreateFontIndirectA(&t_logfont); if (t_hfont == nil) return false; bool t_success; t_success = MCTextLayoutFontFromHFONT(t_hfont, t_font); DeleteObject(t_hfont); r_font = t_font; return t_success; }
static bool MCTextLayoutFontFromHFONT(void *p_font, MCTextLayoutFont*& r_font) { bool t_success; t_success = true; // First fetch the HFONT's LOGFONT structure LOGFONTA t_logfont; if (t_success) if (!GetObjectA(p_font, sizeof(LOGFONTA), &t_logfont)) t_success = false; if (t_success) t_logfont . lfHeight = -256; // Now use this to search for an existing layout font MCTextLayoutFont *self; self = nil; if (t_success) { self = MCTextLayoutFontFind(t_logfont); if (self != nil) { r_font = self; return true; } } // Otherwise we must go ahead and create a new font if (t_success) t_success = MCMemoryNew(self); if (t_success) { self -> handle = CreateFontIndirectA(&t_logfont); if (self -> handle == nil) t_success = false; } if (t_success) { MCListPushFront(s_fonts, self); self -> info = t_logfont; // Now see if the font is a linked font for(MCTextLayoutLinkedFont *t_links = s_linked_fonts; t_links != nil; t_links = t_links -> next) if (MCCStringEqualCaseless(t_links -> name, self -> info . lfFaceName)) { self -> linking = t_links; break; } r_font = self; } else MCTextLayoutFontDestroy(self); return t_success; }