wpf - Width of a letter or an alphabet in a font -


i want know width(units) of particular letter or alphabet in particular font.

for example if type in arial 10 pnts how space take in panel or text box or notepad.

i tend not worry widths, instead leaving wpf format text nicely in whatever control i'm using.

however, think can create formattedtext object using typeface , string "a" (amongst other things), , use minwidth property width in units of 1/96th of inch.

this code started:

formattedtext ft = new formattedtext(     "a",     cultureinfo.getcultureinfo("en-us"),     flowdirection.lefttoright,     new typeface("arial"),     32,     brushes.black); double width = ft.minwidth; 

on system, sets width 21.343. if put em-dash in a is, (as expected) 32.0, size specified em in fifth argument formattedtext constructor.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -