関数を使用して、領域内にレンダリングされるテキストを呼び出しています。関数の基本的な動作は次のとおりです。
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 を使用して文字列の正確なサイズをまったく境界付けずに測定する方法を知っている人はいますか?