Exemplo n.º 1
0
/**
 * Search for a font in the list and load from disk if not present
 */
struct ami_font_node *ami_font_open(const char *font)
{
	struct nsObject *node;
	struct ami_font_node *nodedata;

	node = (struct nsObject *)FindIName((struct List *)ami_font_list, font);
	if(node)
	{
		nodedata = node->objstruct;
		GetSysTime(&nodedata->lastused);
		return nodedata;
	}

	LOG(("Font cache miss: %s", font));

	nodedata = AllocVec(sizeof(struct ami_font_node), MEMF_PRIVATE | MEMF_CLEAR);
	nodedata->font = OpenOutlineFont(font, &ami_diskfontlib_list, OFF_OPEN);

	if(!nodedata->font)
	{
		LOG(("Requested font not found: %s", font));
		warn_user("CompError", font);
		FreeVec(nodedata);
		return NULL;
	}

	nodedata->bold = (char *)GetTagData(OT_BName, 0, nodedata->font->olf_OTagList);
	if(nodedata->bold)
		LOG(("Bold font defined for %s is %s", font, nodedata->bold));
	else
		LOG(("Warning: No designed bold font defined for %s", font));

	nodedata->italic = (char *)GetTagData(OT_IName, 0, nodedata->font->olf_OTagList);
	if(nodedata->italic)
		LOG(("Italic font defined for %s is %s", font, nodedata->italic));
	else
		LOG(("Warning: No designed italic font defined for %s", font));

	nodedata->bolditalic = (char *)GetTagData(OT_BIName, 0, nodedata->font->olf_OTagList);
	if(nodedata->bolditalic)
		LOG(("Bold-italic font defined for %s is %s", font, nodedata->bolditalic));
	else
		LOG(("Warning: No designed bold-italic font defined for %s", font));

	GetSysTime(&nodedata->lastused);

	node = AddObject(ami_font_list, AMINS_FONT);
	if(node)
	{
		node->objstruct = nodedata;
		node->dtz_Node.ln_Name = strdup(font);
	}

	return nodedata;
}
Exemplo n.º 2
0
struct ami_font_cache_node *ami_font_cache_locate(const char *font)
{
	struct ami_font_cache_node *nodedata = NULL;
	uint32 hash = 0;

#ifdef __amigaos4__
	hash = XXH32(font, strlen(font), 0);
	nodedata = (struct ami_font_cache_node *)FindSkipNode(ami_font_cache_list, (APTR)hash);		
#else
	struct nsObject *node = (struct nsObject *)FindIName((struct List *)ami_font_cache_list, font);
	if(node) nodedata = node->objstruct;
#endif

	if(nodedata) {
		GetSysTime(&nodedata->lastused);
		return nodedata;
	}

	LOG("Font cache miss: %s (%lx)", font, hash);
	return NULL;
}