Bug report with text justification


#1

Hi Jules,

I’ve found a nasty bug that eats up spaces while rendering text where it shouldn’t.
Step to reproduce :

  1. Open the jucer
  2. Create a dumb component, and go to graphics
  3. Create a rectangle such that it is X=0, Y=0, W = 400, H=200
  4. Then create a text such that it is X=400, Y=0
  5. In the text properties, set layout bottom/center/top left
  6. As text, enter " as specified here " (with both first and last space)
    The text will not render the first space (while it should).

My code use simple graphics::drawText method, which in turns call justifyGlyphs.

This is very disappointing, as if I convert the text to path, and then render it, it’s ok.

Looking as the code, I think it’s getBoundingBox in glypharrangement that cause the issue, specifically because it is not called with includeWhitespace as true.

Please note that the bug also happens when justifying on the right (whitespace are trimmed while they should only be trimmed with “center” and “justify” mode, I think)

If I change the code glypharrangement.cpp:1053 to:

        getBoundingBox (startIndex, num, left, top, right, bottom, !(justification.testFlags (Justification::horizontallyJustified) || justification.testFlags (Justification::horizontallyCentred)));

it works correctly (at least, consistently with other word processors).


#2

ah - right, thanks for that. And yes, your fix looks exactly right to me.


#3