Raylib DrawTextEx draws text in poor quality

246 Views Asked by At

Raylib DrawTextEx draws text in poor quality. Text poor quality

#include "raylib.h"

#define SCREEN_WIDTH    400
#define SCREEN_HEIGHT   200
#define TARGET_FPS      60

int main(int argc, char const *argv[])
{
    InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "text");

    const char msg[] = "CutiveMono Regular\n";

    Font font = LoadFont("CutiveMono-Regular.ttf");

    SetTargetFPS(TARGET_FPS);

    while (!WindowShouldClose()) {
        BeginDrawing();

            ClearBackground(WHITE);

            DrawTextEx(font, msg, (Vector2) { 20.0f, 100.0f }, 18, 0, BLACK);

        EndDrawing();
    }

    CloseWindow();

    return 0;
}

I've tried other fonts. I would like to improve the quality of text display.

1

There are 1 best solutions below

0
On

In my experience it can make a difference to load a font with extended parameters and choose a font size.

Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount);

The raylib cheatsheet has some more information on the parameters:

Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set

So basically ignore the last two parameters if you don’t need special characters.