How to get width of a truetype font character in 1200ths of an inch with Python? -


i can height , width of character in pixels pil (see below), (unless i'm mistaken) pixel size depends on screen's dpi, can vary. instead i'd calculate width of character in absolute units inches, or 1200ths of inch ("wordperfect units").

>>> # getting pixels width pil >>> font = imagefont.truetype('/blah/fonts/times.ttf' , 12) >>> font.getsize('a') (5, 14) 

my reason wanting create word-wrapping function writing binary word perfect documents. word perfect requires soft linebreak codes inserted @ valid points throughout text, or file corrupt , unopenable. question add them variable width fonts.

i realize don't understand relationship between pixels , screen resolution , font sizes. going wrong?


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -