[Contents] [TitleIndex] [WordIndex

textDrawing Package

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:

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:

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.

2022-09-08 09:27