User Guide

Ruby Component
Here's an example:
The StringFormat object can be replaced by nil in the drawString method call should you wish to go with the default alignment of top-left.
Measuring Text
Sometimes you need to be able to measure how much screen space a block of rendered text will occupy. For this purpose there is the
measureString method:
measureString text, font, stringFormat, location
The input parameters are the same as for the drawString method. However, if the location defines a rectangle then this acts as a maximum
bounding box for the text the idea being that once measured the actual bounding box will be smaller than this one.
The drawString method returns a Ruby Hash containing the following items:
“bounds” - the bounding rectangle that would be occupied by text [x,y,w,h]
“width” - the width of the bounds rectangle
“height” - the height of the bounds rectangle
“chars” - the number of characters that would be drawn
“lines” - the number of rows of text that would be drawn
A Ruby Hash is just like an array, except that you access elements by a reference object instead of an integer index (although you can use
an index too if you wish). The Hash returned by measureString uses strings so for example, if the hash variable was called 'measure' then
to get the width you would use the following expression:
measure[“width”]
String Format Flags
In the previous section on Text we talked about StringFormat flags. This section describes these in full. This information is taken directly from
the Microsoft Developer notes on GDI+.
Flag = 1
Specifies that reading order is right to left. For horizontal text, characters are read from right to left. For vertical text, columns are read from
right to left. By default, horizontal or vertical text is read from left to right.
Flag = 2
Specifies that individual lines of text are drawn vertically on the display device. By default, lines of text are horizontal, each new line below
the previous line.
Flag = 4
123 of 212