예제 #1
0
JFontID
JXFontManager::GetFontID
	(
	const JCharacter*	name,
	const JSize			size,
	const JFontStyle&	style
	)
	const
{
	const JSize count = itsFontList->GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const FontInfo info = itsFontList->GetElement(i);
		if (*(info.name) == name && info.size == size &&
			info.style.bold == style.bold &&
			info.style.italic == style.italic)
			{
			return i;
			}
		}

	// falling through means we need to create a new entry

	JString xFontName, charSet;
	ConvertToXFontName(name, &xFontName, &charSet);

#ifdef _J_USE_XFT
	FontInfo info;
	info.xftfont = GetNewFont(xFontName, charSet, size, style);
	info.exact = kJTrue;

	if (info.xftfont == NULL)
		{
		info.exact = kJFalse;
		info.xftfont = ApproximateFont(xFontName, charSet, size, style);
		}
#else
	FontInfo info;
	info.xfont = GetNewFont(xFontName, charSet, size, style);
	info.exact = kJTrue;
	if (info.xfont == NULL)
		{
		info.exact = kJFalse;
		info.xfont = ApproximateFont(xFontName, charSet, size, style);
		}
#endif

	info.name = new JString(name);
	assert( info.name != NULL );

	info.size  = size;
	info.style = style;

	itsFontList->AppendElement(info);
	return itsFontList->GetElementCount();
}
예제 #2
0
JFontID
JXFontManager::GetFontID
	(
	const JCharacter*	name,
	const JSize			size,
	const JFontStyle&	style
	)
	const
{
	const JSize count = itsFontList->GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const FontInfo info = itsFontList->GetElement(i);
		if (*(info.name) == name && info.size == size &&
			info.style.bold == style.bold &&
			info.style.italic == style.italic)
			{
			return i;
			}
		}

	// falling through means we need to create a new entry

	const JString xFontName = ConvertToXFontName(name);

	FontInfo info;
	if (GetNewFont(xFontName, size, style, &(info.xfont)))
		{
		info.exact = kJTrue;
		}
	else
		{
		info.exact = kJFalse;
		ApproximateFont(xFontName, size, style, &(info.xfont));
		}

	info.name = new JString(name);
	assert( info.name != NULL );

	info.size      = size;
	info.style     = style;
	info.monoWidth = IsMonospace(info.xfont);

	itsFontList->AppendElement(info);
	return itsFontList->GetElementCount();
}