Skip to main content
fixed code formatting
Source Link
user35344
user35344

SDL TTF Character Why am I hitting a small character limit won't let me renderwhen rendering with SDL_TTF?

This is my first post, so please go easy on me. :) I'mI'm making a text based game using SDL2 and SDL TTFSDL_TTF. I just started working with TTF, and I've noticed there is some kind of character limit regarding how much text you can render at a time! I can only render about 15 characters, after that, (16 characters or higher) the screen is just blank.

I really want to render large bodies of text (multiple sentences at a time) so how do I overcome this issue? For rendering text, I have this function:

void drawDialog(const char* content) {
    //Draws a dialog box with set text

//drawSprite("assets/dialog.png", horizontalWindowRes / 2, verticalWindowRes / 2, 256);
TTF_Font* font = TTF_OpenFont("assets/times.ttf", 900);
    SDL_Color textColor = { 255, 255, 255 };
    SDL_Surface* message = TTF_RenderText_Solid(font, content, textColor);
    SDL_Texture* tex;

    SDL_Rect destRect;

    destRect.x = 50;
    destRect.y = 730;

    destRect.w = 200;
    destRect.h = 30;

    tex = SDL_CreateTextureFromSurface(renderer, message);
    SDL_FreeSurface(message);
    SDL_RenderCopy(renderer, tex, NULL, &destRect);
    SDL_RenderPresent(renderer);
}

}

So, any advice for overcoming this limit? Any help would be greatly appreciated!

SDL TTF Character limit won't let me render

This is my first post, so please go easy on me. :) I'm making a text based game using SDL2 and SDL TTF. I just started working with TTF, and I've noticed there is some kind of character limit regarding how much text you can render at a time! I can only render about 15 characters, after that, (16 characters or higher) the screen is just blank.

I really want to render large bodies of text (multiple sentences at a time) so how do I overcome this issue? For rendering text, I have this function:

void drawDialog(const char* content) {
//Draws a dialog box with set text

//drawSprite("assets/dialog.png", horizontalWindowRes / 2, verticalWindowRes / 2, 256);
TTF_Font* font = TTF_OpenFont("assets/times.ttf", 900);
SDL_Color textColor = { 255, 255, 255 };
SDL_Surface* message = TTF_RenderText_Solid(font, content, textColor);
SDL_Texture* tex;

SDL_Rect destRect;

destRect.x = 50;
destRect.y = 730;

destRect.w = 200;
destRect.h = 30;

tex = SDL_CreateTextureFromSurface(renderer, message);
SDL_FreeSurface(message);
SDL_RenderCopy(renderer, tex, NULL, &destRect);
SDL_RenderPresent(renderer);

}

So, any advice for overcoming this limit? Any help would be greatly appreciated!

Why am I hitting a small character limit when rendering with SDL_TTF?

I'm making a text based game using SDL2 and SDL_TTF. I just started working with TTF, and I've noticed there is some kind of character limit regarding how much text you can render at a time! I can only render about 15 characters, after that, (16 characters or higher) the screen is just blank.

I really want to render large bodies of text (multiple sentences at a time) so how do I overcome this issue? For rendering text, I have this function:

void drawDialog(const char* content) {
    //Draws a dialog box with set text

    TTF_Font* font = TTF_OpenFont("assets/times.ttf", 900);
    SDL_Color textColor = { 255, 255, 255 };
    SDL_Surface* message = TTF_RenderText_Solid(font, content, textColor);
    SDL_Texture* tex;

    SDL_Rect destRect;

    destRect.x = 50;
    destRect.y = 730;

    destRect.w = 200;
    destRect.h = 30;

    tex = SDL_CreateTextureFromSurface(renderer, message);
    SDL_FreeSurface(message);
    SDL_RenderCopy(renderer, tex, NULL, &destRect);
    SDL_RenderPresent(renderer);
}

So, any advice for overcoming this limit? Any help would be greatly appreciated!

Source Link

SDL TTF Character limit won't let me render

This is my first post, so please go easy on me. :) I'm making a text based game using SDL2 and SDL TTF. I just started working with TTF, and I've noticed there is some kind of character limit regarding how much text you can render at a time! I can only render about 15 characters, after that, (16 characters or higher) the screen is just blank.

I really want to render large bodies of text (multiple sentences at a time) so how do I overcome this issue? For rendering text, I have this function:

void drawDialog(const char* content) {
//Draws a dialog box with set text

//drawSprite("assets/dialog.png", horizontalWindowRes / 2, verticalWindowRes / 2, 256);
TTF_Font* font = TTF_OpenFont("assets/times.ttf", 900);
SDL_Color textColor = { 255, 255, 255 };
SDL_Surface* message = TTF_RenderText_Solid(font, content, textColor);
SDL_Texture* tex;

SDL_Rect destRect;

destRect.x = 50;
destRect.y = 730;

destRect.w = 200;
destRect.h = 30;

tex = SDL_CreateTextureFromSurface(renderer, message);
SDL_FreeSurface(message);
SDL_RenderCopy(renderer, tex, NULL, &destRect);
SDL_RenderPresent(renderer);

}

So, any advice for overcoming this limit? Any help would be greatly appreciated!