Pārlūkot izejas kodu

* Added font2tga, a test program that exports our font in a known format.

tags/v0.99.beta14
Sam Hocevar sam pirms 18 gadiem
vecāks
revīzija
fdc8b45b72
2 mainītis faili ar 94 papildinājumiem un 1 dzēšanām
  1. +4
    -1
      test/Makefile.am
  2. +90
    -0
      test/font2tga.c

+ 4
- 1
test/Makefile.am Parādīt failu

@@ -2,7 +2,7 @@

AM_CPPFLAGS = -I$(top_srcdir)/cucul -I$(top_srcdir)/caca -DDATADIR=\"$(pkgdatadir)\"

noinst_PROGRAMS = colors demo dithering event export font frames gamma hsv spritedit text transform truecolor unicode import
noinst_PROGRAMS = colors demo dithering event export font frames gamma hsv spritedit font2tga text transform truecolor unicode import

colors_SOURCES = colors.c
colors_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@
@@ -22,6 +22,9 @@ export_LDADD = ../cucul/libcucul.la
font_SOURCES = font.c
font_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@

font2tga_SOURCES = font2tga.c
font2tga_LDADD = ../cucul/libcucul.la

frames_SOURCES = frames.c
frames_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@



+ 90
- 0
test/font2tga.c Parādīt failu

@@ -0,0 +1,90 @@
/*
* font2tga libcucul font test program
* Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* 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, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#endif

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

#include "cucul.h"
#include "cucul_internals.h"

#define WIDTH 64

/* Copied from makefont.c */
static unsigned int const blocklist[] =
{
0x0000, 0x0080, /* Basic latin: A, B, C, a, b, c */
0x0080, 0x0100, /* Latin-1 Supplement: Ä, Ç, å, ß */
0x0100, 0x0180, /* Latin Extended-A: Ā č Ō œ */
0x0180, 0x0250, /* Latin Extended-B: Ǝ Ƹ */
0x0250, 0x02b0, /* IPA Extensions: ɐ ɔ ɘ ʌ ʍ */
0x0370, 0x0400, /* Greek and Coptic: Λ α β */
0x0400, 0x0500, /* Cyrillic: И Я */
0x0530, 0x0590, /* Armenian: Ո */
0x1d00, 0x1d80, /* Phonetic Extensions: ᴉ ᵷ */
0x2000, 0x2070, /* General Punctuation: ‘’ “” */
0x2100, 0x2150, /* Letterlike Symbols: Ⅎ */
0x2200, 0x2300, /* Mathematical Operators: √ ∞ ∙ */
0x2300, 0x2400, /* Miscellaneous Technical: ⌐ ⌂ ⌠ ⌡ */
0x2500, 0x2580, /* Box Drawing: ═ ║ ╗ ╔ ╩ */
0x2580, 0x25a0, /* Block Elements: ▛ ▞ ░ ▒ ▓ */
0, 0
};

int main(int argc, char *argv[])
{
cucul_canvas_t *cv;
cucul_buffer_t *buffer;
unsigned int i, j, x, y, glyphs;

for(i = 0, glyphs = 0; blocklist[i + 1]; i += 2)
glyphs += blocklist[i + 1] - blocklist[i];

/* Create a canvas */
cv = cucul_create_canvas(WIDTH, (glyphs + WIDTH - 1) / WIDTH);
cucul_set_color(cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_WHITE);

/* Put all glyphs on the canvas */
x = y = 0;

for(i = 0; blocklist[i + 1]; i += 2)
{
for(j = blocklist[i]; j < blocklist[i + 1]; j++)
{
_cucul_putchar32(cv, x, y, j);

if(++x == WIDTH)
{
x = 0;
y++;
}
}
}

buffer = cucul_export_canvas(cv, "tga");
fwrite(cucul_get_buffer_data(buffer),
cucul_get_buffer_size(buffer), 1, stdout);
cucul_free_buffer(buffer);

/* Free everything */
cucul_free_canvas(cv);

return 0;
}


Notiek ielāde…
Atcelt
Saglabāt