ソースを参照

* makefont.c: create bitmap font from ttf file.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@443 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 20年前
コミット
51ac3c75ee
3個のファイルの変更73行の追加0行の削除
  1. +1
    -0
      extras/Makefile.am
  2. +7
    -0
      extras/NOTES
  3. +65
    -0
      extras/makefont.c

+ 1
- 0
extras/Makefile.am ファイルの表示

@@ -4,6 +4,7 @@ EXTRA_DIST = \
NOTES \
font_linuxfr.php \
getphpbbcaptcha.py \
makefont.c \
usercp_confirm.php \
$(NULL)


+ 7
- 0
extras/NOTES ファイルの表示

@@ -22,3 +22,10 @@ font_linuxfr.php
This file is used to create the linuxfr font.

Usage: php4 font_linuxfr.php > font_linuxfr.png

makefont.c
----------
This program is used to do a bitmap drawing of a ttf font.

Usage: makefont <font.ttf> <size> <text> <output.bmp>


+ 65
- 0
extras/makefont.c ファイルの表示

@@ -0,0 +1,65 @@
/*
* makefont.c: create a font bitmap from a .ttf file.
* $Id$
*
* Copyright: (c) 2004 Sam Hocevar <sam@zoy.org>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the Do What The Fuck You Want To
* Public License as published by Banlu Kemiyatorn. See
* http://sam.zoy.org/projects/COPYING.WTFPL for more details.
*
* Build example:
* gcc -Wall makefont.c -o makefont `sdl-config --cflags --libs` -lSDL_ttf
*
* Usage:
* makefont <font.ttf> <size> <text> <output.bmp>
*/

#include <stdlib.h>
#include <stdio.h>

#include "SDL.h"
#include "SDL_ttf.h"

int main(int argc, char *argv[])
{
SDL_Color bg = { 0xff, 0xff, 0xff, 0 };
SDL_Color fg = { 0x00, 0x00, 0x00, 0 };
SDL_Surface *text;
TTF_Font *font;

if(argc != 5)
{
fprintf(stderr, "usage: %s <font.ttf> <size> <text> <output.bmp>\n",
argv[0]);
return 1;
}

TTF_Init();
font = TTF_OpenFont(argv[1], atoi(argv[2]));
if(!font)
{
fprintf(stderr, "could not load font %s: %s\n",
argv[1], SDL_GetError());
TTF_Quit();
return 1;
}

TTF_SetFontStyle(font, TTF_STYLE_NORMAL);
text = TTF_RenderUTF8_Shaded(font, argv[3], fg, bg);
if(!text)
{
fprintf(stderr, "text rendering failed: %s\n", SDL_GetError());
TTF_CloseFont(font);
TTF_Quit();
return 1;
}

SDL_SaveBMP(text, argv[4]);
SDL_FreeSurface(text);
TTF_CloseFont(font);
TTF_Quit();

return 0;
}


読み込み中…
キャンセル
保存