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

Last change on this file since 2420 was 2420, checked in by Sam Hocevar, 15 years ago
  • Get rid of io.c/io.h: IO functions are now in libcucul.
  • Property svn:keywords set to Id
File size: 1.6 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 2420 2008-06-15 15:02:23Z 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
32#define STD_GLYPHS (127 - 32)
33#define EXT_GLYPHS (STD_GLYPHS + 7)
34
35static int feed_figlet(context_t *, uint32_t, uint32_t);
36static int flush_figlet(context_t *);
37static int end_figlet(context_t *);
38
39int init_figlet(context_t *cx)
40{
41    char path[2048];
42
43    snprintf(path, 2047, "%s/%s", cx->dir, cx->font);
44    if(cucul_canvas_set_figfont(cx->cv, path))
45        return -1;
46
47    cx->feed = feed_figlet;
48    cx->flush = flush_figlet;
49    cx->end = end_figlet;
50
51    return 0;
52}
53
54static int feed_figlet(context_t *cx, uint32_t ch, uint32_t attr)
55{
56    return cucul_put_figchar(cx->cv, ch);
57}
58
59static int flush_figlet(context_t *cx)
60{
61    int ret = cucul_flush_figlet(cx->cv);
62    cx->torender = cx->cv;
63    cx->cv = cucul_create_canvas(0, 0);
64    return ret;
65}
66
67static int end_figlet(context_t *cx)
68{
69    return cucul_canvas_set_figfont(cx->cv, NULL);
70}
71
Note: See TracBrowser for help on using the repository browser.