开发者

How to get width and height of string on the screen?

Lets say I've a string and some font (name, size, etc...).

How to get 开发者_JAVA百科width and height, measured in pixels, of such string displayed on the screen?


The easy answer is Graphics.MeasureString. But it's rather infamous for not being particularly accurate. If you need better accuracy you can check out this article: Using MeasureCharacterRanges to Draw Text.


You didn't specify if you were using WinForms or ASP.NET.

If this is a web site, the answer I gave on this question can be easily distilled to a working solution for your question:

third font in font family is significantly larger

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜