Changeset 4135 for toilet


Ignore:
Timestamp:
Dec 16, 2009, 1:37:44 AM (10 years ago)
Author:
Sam Hocevar
Message:

New ASCII fonts based on a simple translation of the Monospace ones.

Location:
toilet/trunk
Files:
6 added
11 edited

Legend:

Unmodified
Added
Removed
  • toilet/trunk/Makefile.am

    r1409 r4135  
    66AUTOMAKE_OPTIONS = dist-bzip2
    77
     8CACA2TLF = $(top_builddir)/tools/caca2tlf
     9FONTDIR = $(top_builddir)/fonts
     10
    811fonts: tools/caca2tlf FORCE
    9         $(top_builddir)/tools/caca2tlf "Monospace 9" | zip \
    10             > $(top_builddir)/fonts/bigmono9.tlf
    11         $(top_builddir)/tools/caca2tlf "Monospace Bold 12" | zip \
    12             > $(top_builddir)/fonts/bigmono12.tlf
    13         $(top_builddir)/tools/caca2tlf --half "Monospace 9" | zip \
    14             > $(top_builddir)/fonts/mono9.tlf
    15         $(top_builddir)/tools/caca2tlf --half "Monospace Bold 12" | zip \
    16             > $(top_builddir)/fonts/mono12.tlf
    17         $(top_builddir)/tools/caca2tlf --quarter "Monospace 9" | zip \
    18             > $(top_builddir)/fonts/smmono9.tlf
    19         $(top_builddir)/tools/caca2tlf --quarter "Monospace Bold 12" | zip \
    20             > $(top_builddir)/fonts/smmono12.tlf
     12        $(CACA2TLF) -u "Monospace 9" | zip > $(FONTDIR)/bigmono9.tlf
     13        $(CACA2TLF) -u "Monospace Bold 12" | zip > $(FONTDIR)/bigmono12.tlf
     14        $(CACA2TLF) -h -u "Monospace 9" | zip > $(FONTDIR)/mono9.tlf
     15        $(CACA2TLF) -h -u "Monospace Bold 12" | zip > $(FONTDIR)/mono12.tlf
     16        $(CACA2TLF) -q -u "Monospace 9" | zip > $(FONTDIR)/smmono9.tlf
     17        $(CACA2TLF) -q -u "Monospace Bold 12" | zip > $(FONTDIR)/smmono12.tlf
     18        $(CACA2TLF) -a "Monospace 9" | zip > $(FONTDIR)/bigascii9.tlf
     19        $(CACA2TLF) -a "Monospace Bold 12" | zip > $(FONTDIR)/bigascii12.tlf
     20        $(CACA2TLF) -h -a "Monospace 9" | zip > $(FONTDIR)/ascii9.tlf
     21        $(CACA2TLF) -h -a "Monospace Bold 12" | zip > $(FONTDIR)/ascii12.tlf
     22        $(CACA2TLF) -q -a "Monospace 9" | zip > $(FONTDIR)/smascii9.tlf
     23        $(CACA2TLF) -q -a "Monospace Bold 12" | zip > $(FONTDIR)/smascii12.tlf
    2124
    2225webhost = poulet.zoy.org
  • toilet/trunk/fonts/Makefile.am

    r3552 r4135  
    11
    22allfonts = wideterm.tlf circle.tlf emboss.tlf emboss2.tlf future.tlf \
     3           ascii9.tlf smascii9.tlf bigascii9.tlf \
     4           ascii12.tlf smascii12.tlf bigascii12.tlf \
    35           mono9.tlf smmono9.tlf bigmono9.tlf \
    46           mono12.tlf smmono12.tlf bigmono12.tlf \
  • toilet/trunk/fonts/letter.tlf

    r3552 r4135  
    1 tlf2a 6 5 8 -1 13 0 0 0
     1tlf2a 6 5 8 -1 17 0 0 0
    22===============================================================================
    33  This is letter.tlf, or “Letter”, Copyright (c) 2008 Francesco Poli
     
    66                font creation
    77
    8   This font is free software; you can redistribute it and/or modify it under
     8  This font is free software. It comes without any warranty, to the extent
     9permitted by applicable law. You can redistribute it and/or modify it under
    910the terms of the Do What The Fuck You Want To Public License, Version 2,
    1011as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more
     
    1213
    1314  Missing characters: many...
     15
     16  This font is part of TOIlet’s official distribution. More information
     17on the TOIlet website at http://caca.zoy.org/wiki/toilet
    1418===============================================================================
    1519     @
  • toilet/trunk/src/main.c

    r4134 r4135  
    5151
    5252    cx->export = "utf8";
    53     cx->font = "smblock";
     53    cx->font = "ascii9";
    5454    cx->dir = FONTDIR;
    5555
  • toilet/trunk/tools/caca2tlf.c

    r4134 r4135  
    2828
    2929enum mode { GRAY, HALFBLOCKS, QUARTERBLOCKS } mode;
     30enum charset { ASCII, UTF8 } charset;
    3031
    3132static void list_fonts(void);
     
    4041int main(int argc, char *argv[])
    4142{
    42     char *fontname, *extraflag;
     43    char *flag1, *flag2;
    4344    unsigned int b, i;
    4445
    4546    if(argc < 2)
    4647    {
    47         fprintf(stderr, "Usage: %s [--half|--quarter] <font>\n", argv[0]);
     48        fprintf(stderr,
     49                "Usage: %s [--half|--quarter] [--ascii|--utf8] <font>\n",
     50                argv[0]);
    4851        list_fonts();
    4952        return -1;
    5053    }
    5154
    52     if(!strcmp(argv[1], "--half") && argc >= 3)
    53     {
    54         extraflag = "--half ";
     55    if((!strcmp(argv[1], "--half") || !strcmp(argv[1], "-h")) && argc > 2)
     56    {
     57        flag1 = "--half ";
    5558        mode = HALFBLOCKS;
    56         fontname = argv[2];
    57     }
    58     else if(!strcmp(argv[1], "--quarter") && argc >= 3)
    59     {
    60         extraflag = "--quarter ";
     59        argv++; argc--;
     60    }
     61    else if((!strcmp(argv[1], "--quarter") || !strcmp(argv[1], "-q")) && argc > 2)
     62    {
     63        flag1 = "--quarter ";
    6164        mode = QUARTERBLOCKS;
    62         fontname = argv[2];
     65        argv++; argc--;
    6366    }
    6467    else
    6568    {
    66         extraflag = "";
     69        flag1 = "";
    6770        mode = GRAY;
    68         fontname = argv[1];
    69     }
    70 
    71     f = caca_load_font(fontname, 0);
    72 
     71    }
     72
     73    if((!strcmp(argv[1], "--ascii") || !strcmp(argv[1], "-a")) && argc > 2)
     74    {
     75        flag2 = "--ascii ";
     76        charset = ASCII;
     77        argv++; argc--;
     78    }
     79    else if((!strcmp(argv[1], "--utf8") || !strcmp(argv[1], "-u")) && argc > 2)
     80    {
     81        flag2 = "--utf8 ";
     82        charset = UTF8;
     83        argv++; argc--;
     84    }
     85    else
     86    {
     87        flag2 = "";
     88        charset = ASCII;
     89    }
     90
     91    f = caca_load_font(argv[1], 0);
    7392    if(!f)
    7493    {
     
    112131                                       "==================================\n");
    113132    printf("  This font was automatically generated using:\n");
    114     printf("   %% caca2tlf %s\"%s\"\n", extraflag, fontname);
     133    printf("   %% caca2tlf %s%s\"%s\"\n", flag1, flag2, argv[1]);
    115134    printf("=============================================="
    116135                                       "==================================\n");
     
    170189static void add_char(unsigned long int ch)
    171190{
     191    static char const * chars[][16] =
     192    {
     193        { "#", "$", ":", ".", " " },
     194        { " ", "\"", "m", "#" },
     195        { " ", "`", "'", "\"", ",", "[", "/", "P",
     196          ".", "\\", "]", "T", "m", "b", "d", "W" },
     197        { "█", "▓", "▒", "░", " " },
     198        { " ", "▀", "▄", "█" },
     199        { " ", "▘", "▝", "▀", "▖", "▌", "▞", "▛",
     200          "▗", "▚", "▐", "▜", "▄", "▙", "▟", "█" }
     201    };
     202
     203    char const **str;
    172204    void *buf;
    173205    size_t len;
    174206    unsigned int x, y, myw, mygw;
     207    int off = 0;
    175208    int full = caca_utf32_is_fullwidth(ch);
    176209
     
    183216
    184217    caca_set_canvas_size(out, (full ? fgw : gw) + 2, gh);
     218    caca_clear_canvas(out);
     219
     220    switch(charset)
     221    {
     222    case ASCII:
     223        off = 0;
     224        break;
     225    case UTF8:
     226        off = 3;
     227        break;
     228    }
    185229
    186230    switch(mode)
    187231    {
    188232    case GRAY:
     233        str = chars[off];
    189234        for(y = 0; y < h; y++)
    190235            for(x = 0; x < myw; x++)
     
    193238
    194239            if(c >= 0xa0)
    195                 caca_put_str(out, x, y, "█");
     240                caca_put_str(out, x, y, str[0]);
    196241            else if(c >= 0x80)
    197                 caca_put_str(out, x, y, "▓");
     242                caca_put_str(out, x, y, str[1]);
    198243            else if(c >= 0x40)
    199                 caca_put_str(out, x, y, "▒");
     244                caca_put_str(out, x, y, str[2]);
    200245            else if(c >= 0x20)
    201                 caca_put_str(out, x, y, "░");
     246                caca_put_str(out, x, y, str[3]);
    202247            else
    203                 caca_put_char(out, x, y, ' ');
     248                caca_put_str(out, x, y, str[4]);
    204249        }
    205250        break;
    206251    case HALFBLOCKS:
     252        str = chars[off + 1];
    207253        for(y = 0; y < gh; y++)
    208254            for(x = 0; x < mygw; x++)
    209255        {
    210             static char const *str[] = { " ", "▀", "▄", "█" };
    211 
    212256            uint8_t p1 = image[4 * (x + y * 2 * iw) + 2];
    213257            uint8_t p2 = image[4 * (x + (y * 2 + 1) * iw) + 2];
     
    217261        break;
    218262    case QUARTERBLOCKS:
     263        str = chars[off + 2];
    219264        for(y = 0; y < gh; y++)
    220265            for(x = 0; x < mygw; x++)
    221266        {
    222             static char const *str[] =
    223             {
    224                 " ", "▘", "▝", "▀", "▖", "▌", "▞", "▛",
    225                 "▗", "▚", "▐", "▜", "▄", "▙", "▟", "█"
    226             };
    227 
    228267            uint8_t p1 = image[4 * (x * 2 + y * 2 * iw) + 2];
    229268            uint8_t p2 = image[4 * (x * 2 + 1 + y * 2 * iw) + 2];
Note: See TracChangeset for help on using the changeset viewer.