[08/10] gdiplus: GdipMeasureString/GdipDrawString should add extra space around the text.

Vincent Povirk madewokherd at gmail.com
Fri Aug 17 00:27:33 CDT 2012

>> >> Why can't this logic go in gdip_format_string?
>> >
>> > Because not all of its callers should be affected (GdipMeasureCharacterRanges
>> > is one of them).
>> How not? If the padding is there when drawing the whole string, it
>> affects the positions of individual characters.
> Many sources on the net suggest using GdipMeasureCharacterRanges to avoid
> extra padding added by GdipMeasureString.

My understanding is that MeasureCharacterRanges does not include the
padding in its measurements, because it measures individual
characters, but it still accounts for the padding. That means that if
you measure a character range with padding applied, the resulting
rectangle will be shifted by the amount of the padding, but the
padding will be outside the rectangle.

This makes it possible to avoid the padding when drawing effects such
as a background highlight behind some text. Returning a measurement
that doesn't reflect reality as you suggest would not be a useful
behavior, as the measurement would simply lead to drawing something in
the wrong place.

More information about the wine-devel mailing list