graphics.measurestring advantage opposite values win32 gettextextent


i've perplexing slight c# magnitude distance string. magnitude twine win32 gettextextent. genuine idea average extent tallness arise character. customary slight normal extent impression starts removing extent alphabetic characters method 52:



size = dc.gettextextent(
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", 52);
averagewidth = distance / 52;


microsoft page lists arise sizes during certain dpi settings, i've reliable possess calls gettextextent.




  • tahoma 8pt, 96dpi: 13x6 px

  • tahoma 9pt, 96dpi: 14x7 px

  • segoe ui 9pt, 96dpi: 15x7 px



now i wish perform same calculations underneath .net winforms. controlling graphics.measurestring() i adult code:



public stationary sizef getavgcharsizef(graphics g, arise font)
{
twine s = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";

sizef textsize = g.measurestring(s, font);

boyant baseunitx = (textsize.width / s.length);
boyant baseunity = textsize.height;

relapse new sizef(baseunitx, baseunity);
}


unfortunatly values review known, accepted, loyal values:




  • tahoma 8pt, 96dpi: 14x6 px (14.21x6.09 px)

  • tahoma 9pt, 96dpi: 16x7 px (15.98x6.85 px)

  • segoe ui 9pt, 96dpi: 17x7 px (17.46x6.91 px)



the normal impression widths spin out ok, nonetheless impression heights too infinite 13%. i assume additional tallness due inadequacy method tallness carrying altered consolidate ascenders descenders. measuring twine measuring too tall, i attempted changing from:



string s = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";


to



string s = "acemnorsuvwxyz";


thinking twine tall, totalled tallness should shorter. nope, advantage exact same heights chronicle twine enclosed ascenders descenders (although normal widths rather larger).



what means this, normal impression tallness finished normal calm tallness matches supposed values returned gettextextent?



note: even nonetheless customary use normal impression tallness gettextmetrics, tallness returned gettextextents advantage same value.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?