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

Dmitry Timoshkov dmitry at baikal.ru
Fri Aug 17 00:40:13 CDT 2012

Vincent Povirk <madewokherd at gmail.com> wrote:

> >> >> 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.

Since I have no tests for GdipMeasureCharacterRanges I don't want to break
it inadvertently. If somebody proves that GdipMeasureCharacterRanges should
be affected by extra padding as well, merging the code to gdip_format_string
shouldn't be too hard.


More information about the wine-devel mailing list