I started testing SDL stuff today in C and when I put a font this effect happened around, also something similar happened with the image borders when I made it smaller.
Here is my code and a video proof:
#include <SDL.h>
#include <SDL_ttf.h>
#include <stdbool.h>
#include <stdio.h>
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
TTF_Font *font = NULL;
SDL_Surface *surface = NULL;
SDL_Texture *texture = NULL;
int main(void)
{
bool isRunning = true;
SDL_Event event;
int x = 1280/2, y = 800/2;
SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();
window = SDL_CreateWindow(
"Test SDL",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
1280, 800,
0);
renderer = SDL_CreateRenderer(window,-1,0);
font = TTF_OpenFont("../resources/OpenSans-Regular.ttf", 42);
SDL_Color white = {255, 255, 255};
surface = TTF_RenderText_Solid(font, "Testing Font", white);
texture = SDL_CreateTextureFromSurface(renderer, surface);
int textW = 0;
int textH = 0;
SDL_QueryTexture(texture, NULL, NULL, &textW, &textH);
SDL_Rect dsrect = {x-150, y-150, textW, textH};
while (isRunning)
{
SDL_PollEvent(&event);
switch (event.type)
{
case SDL_QUIT:
isRunning = false;
break;
}
SDL_RenderCopy(renderer, texture, NULL, &dsrect);
SDL_RenderPresent(renderer);
}
SDL_DestroyTexture(texture);
SDL_FreeSurface(surface);
TTF_CloseFont(font);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
TTF_Quit();
SDL_Quit();
return 0;
}