我正在使用一个函数来调用要在一个区域内呈现的一段文本。该功能的基本工作是:
Dim measureSize as Size
Do
myFont = new Font(myFont.Name, myFont.Size - 1, FontStyle.Regular, GraphicsUnit.Document)
'Initial font size is set insanely high for the moment, during testing.
'Low initial font size is not the problem.
measureSize = g.MeasureString(myString, myFont)
Loop until (measuredSize.width < desiredSize.width AND measuredSize.height < desiredSize.height)
这样做的问题是 MeasureString 在它正在绘制的字符串周围添加了很多空白,并且最终的字体被渲染得太小了。
我确定我记得一些参数可以用来从 MeasureString 方法中删除所有填充,但是我的搜索目前没有出现任何结果。
有谁知道如何使用 MeasureString 来测量字符串的精确大小而没有任何边界?