Exemplo n.º 1
0
void MCTextLayoutFinalize(void)
{
	while(s_linked_fonts != nil)
		MCTextLayoutLinkedFontDestroy(MCListPopFront(s_linked_fonts));

	while(s_fonts != nil)
		MCTextLayoutFontDestroy(MCListPopFront(s_fonts));
}
Exemplo n.º 2
0
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;
}