GDI+测算文字绘制范围

本文探讨了GDI+中MeasureString函数测算文字绘制范围的特性,指出它计算的是所有字符的外包框而非实际绘制的字符大小。同时,提到了Font::GetHeight()与Font::GetSize()之间的关系可能表示字符间的垂直距离,但此结论缺乏官方文档支持。
摘要由CSDN通过智能技术生成

啥也不罗嗦,上代码:

	Gdiplus::SolidBrush		brush(Gdiplus::Color(124,25,28));


	Gdiplus::RectF bound;
	SIZE sz;

	HDC hDC = gs.GetHDC();
	SetTextCharacterExtra( hDC, 0 );
	SetTextJustification( hDC, 0, 1 );
	gs.ReleaseHDC( hDC );


	gs.SetSmoothingMode( SmoothingModeAntiAlias );
	gs.SetTextRenderingHint( TextRenderingHintAntiAliasGridFit );
	
	int emSize = 20;
	Gdiplus::StringFormat	*strFmt = Gdiplus::StringFormat::GenericTypographic()->Clone();
	FontFamily  fontFamily(L"微软雅黑");
	

	//行间距计算
	REAL linespace = fontFamily.GetLineSpacing(FontStyleRegular);
	REAL ascent	= fontFamily.GetCellAscent(FontStyleRegular);
	REAL descent	= fontFamily.GetCellDescent(FontStyleRegular);
	REAL emheight	= fontFamily.GetEmHeight(FontStyleRegular);
	
	Font    font(&fontFamily, emSize, FontStyleRegular, UnitPixel);
	REAL	ftheight = font.GetHeight(&gs);
	REAL	ftsize	 = font.GetSize();


	INT16 ascentp	
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值