Laguna1989/JamTemplateCpp

sfml text align for multiline text

Opened this issue · 1 comments

Multiline text defintion:

  • jt::Text
  • contains at least one "\n"

This behaves differently for SFML (code) and SDL (code) builds due to differences between the implementations. SFML considers the full text box, while SDL considers each line (which results in the proper result)

Possible solution

  • Change the SFML implementation class to contain a vector of sf::Text objects instead of only one. One sf::Text per line.
  • Text needs to be split on linebreaks.
  • Make the doUpdate() function set the position of the individual sf::Text objects depending on the width of the longest line and the m_textAlign value.
  • Make the doDraw() functions (including flash and shadwo) draw those multiple sf::Text objects.

Please check

  • Adapt the Scroll/MoveCam demo to contain multiline text with different alignments
  • Check that all unit tests pass
  • Check that new code branches are tested. This might require some additions to the text_test and potentially the drawable_impl_test
  • Check/Adapt the state_menu if needed.

textalign right is already fixed. Mulitline text not yet fully supported.