开发者

Portable way of determining font properties (mono and standard .net)

开发者 https://www.devze.com 2023-01-16 04:42 出处:网络
Does anyone know a way t开发者_开发技巧o determine if a font is monospace and the width and height of a single character (only relevant if it is monospace).

Does anyone know a way t开发者_开发技巧o determine if a font is monospace and the width and height of a single character (only relevant if it is monospace). The important requirement is that it works with mono and microsoft implementations of .net .

Thanks


First thing you need to choose which GUI Toolkit you are targeting.

Fonts aren't abstracted in a toolkit-independent way, AFAIK.

For WinForms, TextRenderer.MeasureText method used with "iii" and "www" strings can help you guess if the font is monospaced and which is the probable 'fixed' width of a char cell, bu it may not work right for very small point sizes...

0

精彩评论

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