Why can't this logic go in gdip_format_string?
Vincent Povirk madewokherd@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).
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.
Vincent Povirk madewokherd@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.
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.
Vincent Povirk madewokherd@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.
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.
Well, I'm saying you'll break it if you only change the other two functions and leave this one alone. It's more important for DrawString, MeasureString, and MeasureCharacterRanges to be consistent with each other than with Windows. Applications won't typically rely on specific measurements, but they WILL rely on the measurements from MeasureCharacterRanges and MeasureString to match the actual result from DrawString.
It should be obvious that changing the way DrawString lays out the text, or changing the measurements of some text, without a corresponding change in the other functions, will make the measurements WRONG, even if they happen to pass your tests and match the results on Windows. If you want to change the layout for only some of the string functions, you're going to need some very strong justification for that.