Ignore:
Timestamp:
Jan 10, 2005, 2:21:50 PM (17 years ago)
Author:
Sam Hocevar
Message:
  • src/common.h: new font structure.
  • src/slashdot.c: use new font structure, removed FACTOR.
  • extras/makefont.c: we add spaces in the string ourselves.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pwntcha/trunk/extras/makefont.c

    r443 r446  
    1818#include <stdlib.h>
    1919#include <stdio.h>
     20#include <string.h>
    2021
    2122#include "SDL.h"
     
    2425int main(int argc, char *argv[])
    2526{
     27    unsigned char *text;
    2628    SDL_Color bg = { 0xff, 0xff, 0xff, 0 };
    2729    SDL_Color fg = { 0x00, 0x00, 0x00, 0 };
    28     SDL_Surface *text;
     30    SDL_Surface *surface;
    2931    TTF_Font *font;
     32    int i;
    3033
    3134    if(argc != 5)
     
    3639    }
    3740
     41    /* Load font */
    3842    TTF_Init();
    3943    font = TTF_OpenFont(argv[1], atoi(argv[2]));
     
    4650    }
    4751
     52    /* Add spaces to string */
     53    text = malloc(2 * strlen(argv[3]) * sizeof(char));
     54    for(i = 0; argv[3][i]; i++)
     55    {
     56        text[i * 2] = argv[3][i];
     57        text[i * 2 + 1] = ' ';
     58    }
     59    text[i * 2 - 1] = '\0';
     60
     61    /* Render text to surface */
    4862    TTF_SetFontStyle(font, TTF_STYLE_NORMAL);
    49     text = TTF_RenderUTF8_Shaded(font, argv[3], fg, bg);
    50     if(!text)
     63    surface = TTF_RenderUTF8_Shaded(font, argv[3], fg, bg);
     64    if(!surface)
    5165    {
    52         fprintf(stderr, "text rendering failed: %s\n", SDL_GetError());
     66        fprintf(stderr, "surface rendering failed: %s\n", SDL_GetError());
    5367        TTF_CloseFont(font);
    5468        TTF_Quit();
     
    5670    }
    5771
    58     SDL_SaveBMP(text, argv[4]);
    59     SDL_FreeSurface(text);
     72    /* Clean up surface */
     73
     74    /* Save surface and free everything */
     75    SDL_SaveBMP(surface, argv[4]);
     76    SDL_FreeSurface(surface);
    6077    TTF_CloseFont(font);
    6178    TTF_Quit();
Note: See TracChangeset for help on using the changeset viewer.