Beispiel #1
0
JSize
JXFontManager::GetLineHeight
	(
	const JFontID		fontID,
	const JSize			size,
	const JFontStyle&	style,

	JCoordinate*		ascent,
	JCoordinate*		descent
	)
	const
{
	FontInfo info = itsFontList->GetElement(fontID);
	if (info.xfont.type == kStdType)
		{
		*ascent  = info.xfont.xfstd->ascent;
		*descent = info.xfont.xfstd->descent;
		}
	else
		{
		assert( info.xfont.type == kTrueType );

		if (info.ascent == 0)
			{
			XGlyphInfo g;
			XftTextExtents8(*itsDisplay, info.xfont.xftrue, (FcChar8*) "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789|_", 64, &g);
			info.ascent  = g.y + 1 + size/10;
			info.descent = g.height - g.y;
			itsFontList->SetElement(fontID, info);
			}

		*ascent  = info.ascent;
		*descent = info.descent;
		}

	const JCoordinate underlineHeight = 2 * GetUnderlineThickness(size) * style.underlineCount;
	if (*descent < underlineHeight)
		{
		*descent = underlineHeight;
		}

	return (*ascent + *descent);
}
JSize
JXFontManager::GetLineHeight
	(
	const JFontID		fontID,
	const JSize			size,
	const JFontStyle&	style,

	JCoordinate*		ascent,
	JCoordinate*		descent
	)
	const
{
#ifdef _J_USE_XFT
	XftFont* xftfont = GetXftFont(fontID);
	*ascent  = xftfont->ascent;
	*descent = xftfont->descent;
#else
	XFontStruct* xfont = GetXFontInfo(fontID);
	*ascent  = xfont->ascent;
	*descent = xfont->descent;
#endif

	// Look for underline types
	if (style.underlineType == JFontStyle::plain_Underline)
	{
		const JSize underlineThickness = GetUnderlineThickness(size);
		if (((JSize) *descent) < 2 * underlineThickness * style.underlineCount)
			{
			*descent = 2 * underlineThickness * style.underlineCount;
			}
	}
	else
	{
		// Special underline types always have height 3
		if (((JSize) *descent) < 3)
			*descent = 3;
	}

	return (*ascent + *descent);
}