view src/dmtext_ttf.c @ 2576:812b16ee49db

I had been living under apparent false impression that "realfft.c" on which the FFT implementation in DMLIB was basically copied from was released in public domain at some point, but it could very well be that it never was. Correct license is (or seems to be) GNU GPL. Thus I removing the code from DMLIB, and profusely apologize to the author, Philip Van Baren. It was never my intention to distribute code based on his original work under a more liberal license than originally intended.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 Mar 2022 16:32:50 +0200
parents b91d54a37b6b
children
line wrap: on
line source

/*
 * DMLib
 * -- Bitmap and TTF text & font support
 * Programmed and designed by Matti 'ccr' Hamalainen
 * (C) Copyright 2012 Tecnic Software productions (TNSP)
 */
#include "dmtext.h"


void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font,
    SDL_Color col, const int xc, const int yc, const char *fmt)
{
    SDL_Surface *text = TTF_RenderText_Blended(font, fmt, col);
    if (text != NULL)
    {
        SDL_Rect rect;
        rect.x = xc;
        rect.y = yc;
        rect.w = text->w;
        rect.h = text->h;
        SDL_BlitSurface(text, NULL, screen, &rect);
        SDL_FreeSurface(text);
    }
}


void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font,
    SDL_Color col, const int xc, const int yc, const char *fmt, va_list ap)
{
    char *tmp = dm_strdup_vprintf(fmt, ap);
    if (tmp != NULL)
    {
        dmDrawTTFTextConst(screen, font, col, xc, yc, tmp);
        dmFree(tmp);
    }
}


void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font,
    SDL_Color col, const int xc, const int yc, const char *fmt, ...)
{
    va_list ap;

    va_start(ap, fmt);
    dmDrawTTFTextVA(screen, font, col, xc, yc, fmt, ap);
    va_end(ap);
}