Determine how wide a rendered character is in .NET

后端 未结 7 1404
Happy的楠姐
Happy的楠姐 2021-01-02 01:03

Lets say I render the character \"A\" to the screen with a size 14 font in Arial Regular. Is there a way in C# to calculate how many pixels wide it is?


The wa

7条回答
  •  长发绾君心
    2021-01-02 01:52

    For windows forms you use Graphics.MeasureString, For WPF you use FormattedText.Width and FormattedText.Height.

提交回复
热议问题