GDI+ MeasureText and DrawString pad space to start and end???

Trips

Well-known member
Joined
Aug 7, 2010
Messages
2,788
When i use GDI+ MeasureText(), it returns the width of the text plus some padding on either end. Also, when i draw the text, it pads the start with space, so the text does not start at exactly the left pixel edge. this makes it impossible
to draw a single word split in half, using two calls. i looked for a flag that says "dont pad" but there isnt one. if you want to see an example look here:
http://karaoke.kjams.com/screenshots/bad_measure.png
in this example, look at the word "believe" in the first line, it is split into 3. but there is extra space around every portion. ive drawn the extent rects to hilight this. and yes im quite sure there are no actual spaces.
<img src="file:///Users/davec/Library/Caches/TemporaryItems/moz-screenshot.png" alt="
<img src="file:///Users/davec/Library/Caches/TemporaryItems/moz-screenshot-1.png" alt="
note ive also actually measured some strings:
at font size 15, the letter "e" is 12 pixels wide. the string "ee" then should be 24 pixels wide, right? but no, its 19. and "eeee" should be 48 pixels? no, its 34. this leads to the belief that the "e"
is really 8 pixels wide, with 1.5 pixels on either side of padding. ish, cuz these are int values.
how do i measure and draw text without this crazy padding?

<
http://kjams.com

View the full article
 
Back
Top