source: toilet/trunk/src/figlet.c @ 2414

Last change on this file since 2414 was 2414, checked in by Sam Hocevar, 14 years ago
  • Get rid of all the FIGlet font handling: everything is moving into libcucul.
  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1/*
2 *  TOIlet        The Other Implementation’s letters
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: figlet.c 2414 2008-06-15 14:46:54Z sam $
7 *
8 *  This program is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15/*
16 * This file contains functions for handling FIGlet fonts.
17 */
18
19#include "config.h"
20
21#if defined(HAVE_INTTYPES_H)
22#   include <inttypes.h>
23#endif
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27#include <cucul.h>
28
29#include "toilet.h"
30#include "render.h"
31#include "io.h"
32
33#define STD_GLYPHS (127 - 32)
34#define EXT_GLYPHS (STD_GLYPHS + 7)
35
36static int feed_figlet(context_t *, uint32_t, uint32_t);
37static int flush_figlet(context_t *);
38static int end_figlet(context_t *);
39
40int init_figlet(context_t *cx)
41{
42    char path[2048];
43
44    snprintf(path, 2047, "%s/%s", cx->dir, cx->font);
45    if(cucul_canvas_set_figfont(cx->cv, path))
46        return -1;
47
48    cx->feed = feed_figlet;
49    cx->flush = flush_figlet;
50    cx->end = end_figlet;
51
52    return 0;
53}
54
55static int feed_figlet(context_t *cx, uint32_t ch, uint32_t attr)
56{
57    return cucul_put_figchar(cx->cv, ch);
58}
59
60static int flush_figlet(context_t *cx)
61{
62    return cucul_flush_figlet(cx->cv);
63}
64
65static int end_figlet(context_t *cx)
66{
67    return cucul_canvas_set_figfont(cx->cv, NULL);
68}
69
Note: See TracBrowser for help on using the repository browser.