Lets say I've a string and some font (name, size, etc...).
How to get 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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.