This package contains class which render matrices of Strings.
The entry point for drawing a text object is Scilab is the drawTextContent method of the TextContentDrawerGL class. This function, only switch to pixel coordinates and call the drawTextContentPix method which draw in pixels coordinates. It's needed to draw in pixel coordinates because the text must always face the user.
There are 3 ways of drawing text (relative to the text_box_mode properties), normal, centered or filled. The first two ones are similar since the font size is specified by the user and are using the same drawing methods inside the FixedFontTextDrawerGL. When the text is in fill mode, the font size is calcuted in order to fit the given text_box.
However the drawing process is quite similar:
1) Compute the size of each strings contained in the matrix (using the StringMatrixGL class).
2) Using the sizes compute a set of cells in which each string will fit by creating a TextGrid instance.
- 3) Move the cells using the position and the rotation angles (using OpenGL routines if possible).
- 4) Render the text box if needed.
- 5) Render the String inside thait cells using the righ text renderer.
- 6) Retrieve the bounding box of the drawn strings.
For the rendering point (4), there are actually 3 ways of positionning the strings inside their cells. Each of the way is defined by a TextAlignementStrategy. There is one for aligning the String on the left of the cell, one on the right and one centered the string in the middle of the cell.
The text box is also rendered here for speed reasons. In the first implementations, it was rendered using strategies, but to limit the overhead from object creation, it has directly been added inside the class. It also prevent from carrying the bounding box from class to class.
The process for filled text is the following:
- 1) Compute the size of each strings contained in the matrix using the font size used in the previous draw.
2) Create a TextGrid using the previous data.
- 3) Compare the the bounding box obtained with the previous font with the requested one.
- 4) If they are different then use a new font.
- 5) Render the strings and their box with the new font.
The computation of the bounding box is not needed here since it's given by the user.
Note that using logical operator with strings does not work. Apparenlty, it because current implementation use some OpenGL state variables which arenot compatible with logical op. However, it alredy did not work in Scilab 4 and previous version.
Getting bounding box
The entry points for getting the bounding box is getScreenBoundingBox method. It retrieve the bounding box in pixels of the String matrix.
For fixed font drawing getting the bounding box is similar of the rendering. It needs the creation of the TextGrid, then get its extrem bounds and them place them using the position and the extrem fonts.
For filled text, only the positionning of the box is needed since the bounding box size is given by the user.
Note that when using Scilab functions to get the text bounding box, this function is only called when needed. A copy of the lastly computed bounding box (which might be still valid if nothing changed) is actually stored in the C handle.