The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_ttf
donrevan


Joined: 10 Nov 2013
Posts: 1
Hey,

I have a little problem.
I'm trying to render text using SDL_ttf, rendering single line text works fine but if I try to render multiline text it fails.
See theese images:
single line

multi line

You can see that the multiline one is basicly not using more height and tries to fit it.
Here's the code I use:
Code:

void RefreshSurface()
{
    SDL_Surface *pSurface;
   
    /* Render the text. */
    if(!m_bMultiline)
    {
        pSurface = TTF_RenderText_Blended(_Font(), m_szText, m_color);
    } else {
        pSurface = TTF_RenderText_Blended_Wrapped(_Font(), m_szText, m_color, m_iWidth);
    }

    /* See if rendering text failed. */
    if(!pSurface)
    {
        DTL_Assert(!"TTF_RenderText failed");
        return;
    }

    /* Delete the old texture. */
    if(m_pTexture)
    {
        SDL_DestroyTexture(m_pTexture);
    }

    /* Get a new. */
    m_pTexture = SDL_CreateTextureFromSurface(g_Renderer.Renderer(), pSurface);
    SDL_FreeSurface(pSurface);
}

m_bMultiline is set only for multiline text but even if I render single line text with m_bMultiline set to true everything works fine. There has to be a problem with multiline text rendering in the RenderText wrapped function I think but probably I just forget something.
If somebody has a idea I would really like to try it out because I'm already trying to fix this for a while with no luck.

Thanks in advance