[Gambas-user] Method Paint.DrawText unclear

Claus Dietrich claus.dietrich at freenet.de
Sun Oct 17 17:21:19 CEST 2021


>you just have to imagin that the 4 values you give are a Rectangle where
>you draw a text ... and then the Alignment value tell how to align text in
>the rectangle.
>The text rectangle is not clipped so the text is drawn outside the
>rectangle if this one is too small to contain it. This allow to draw text
>even if you not give the height/width values
>By default the value of alignment is topleft.

Correct. This is what the wiki tries to say, but it is not the whole story:
The following applies as well and wasn't obvious to me:
1. Height can be provided without Width and vice versa. This means, that a rectangle is not mandatory. In this case the Alignment parameter uses the Height or Width value as vertical resp. horizontal orientation value and only an according subset of the alignment parameters apply.
2. As soon as a Height and/or Width value is provided (even zero) the position of the text is offset by the height of the text (y + Height_of_Text). In other words: The upper border of the text is moved to the y-parameter instead of the lower baseline.
3. The Alignment class constants are to be applied.
Regards
Claus



More information about the User mailing list