Terms: origin and bbox

Each text object has an origin, which is normally its bottom left corner. A bbox (bounding box) is an invisible rectangular box around the text.

There are two kind of text objects: height-specified and bbox-specified.

For a height-specified text the stroke pen used for the text object specifies text height. Height includes font's descender and ascender; in other words, it's the distance between the highest point of the tallest glyph in the font and the lowest point of the most ascending glyph in the font. Text width is calculated depending on the text string. Bbox is also calculated, using pen's text hight and the calculated text width.

In a bbox-specified text object the origin corner of the bbox and the diagonal corner are specified, so that the width and height of the bbox are known. Text string is rendered with a scale so that it fits into the box. Since bbox's aspect rarely matches the aspect of the text, and text scaling will always be the same in x and y direction, this means the text will be smaller than the box in either height or width (but not both).

Single line text alignment

Note: mirroring a text object will mirror the bounding box, affecting the place of the origin within the bbox, but does not mirror the actual pixels of the rendered text (so the text is always readable, regardless of mirroring).

In case of height-specified text, either the start or the end of the rendered text is always the origin. If text string is edited to grow longer, new characters are appended, text width and the bbox width grows.

Since the bbox is always calculated to fit the rendered text, there can be no extra room around the text, thus the hailgn property doesn't play a role. Whether such text grows left or right depends on the x-mirror state of the text:

Below is an example of a text "Hello" expanded to "Hello world!". The origin is marked with two arrows, showing positive x and y direction for text growth (in case of single line text only the horizontal direction is of interest). On the left side is the non-mirrored case, on the right side is the x-mirrored case.

In case of bbox-specified text, if text scaling bumps first into height constraint of the bbox, there will be empty space left between text width and bbox width. The allocation of this empty space is controlled by the halign property of the text object:

Below is an example of a bbox specified text with the box wider than the text. The origin is marked with two arrows, showing positive x and y direction for text growth and the opposite corner of the bbox is marked with two lines. On the left side is the non-mirrored case, on the right side is the x-mirrored case. Copies of the quote from top to bottom uses different halign values, following the order of the list above.

Multiple line text alignment

Not yet implemented.