Changeset 1294 for libcaca


Ignore:
Timestamp:
Nov 6, 2006, 12:04:37 PM (17 years ago)
Author:
Sam Hocevar
Message:
  • Use cucul_get_font_blocks() instead of hardcoding the glyph list.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/test/font2tga.c

    r1267 r1294  
    2727#define WIDTH 64
    2828
    29 /* Copied from makefont.c */
    30 static unsigned int const blocklist[] =
    31 {
    32     0x0000, 0x0080, /* Basic latin: A, B, C, a, b, c */
    33     0x0080, 0x0100, /* Latin-1 Supplement: Ä, Ç, å, ß */
    34     0x0100, 0x0180, /* Latin Extended-A: Ā č Ō œ */
    35     0x0180, 0x0250, /* Latin Extended-B: Ǝ Ƹ */
    36     0x0250, 0x02b0, /* IPA Extensions: ɐ ɔ ɘ ʌ ʍ */
    37     0x0370, 0x0400, /* Greek and Coptic: Λ α β */
    38     0x0400, 0x0500, /* Cyrillic: И Я */
    39     0x0530, 0x0590, /* Armenian: Ո */
    40     0x1d00, 0x1d80, /* Phonetic Extensions: ᴉ ᵷ */
    41     0x2000, 0x2070, /* General Punctuation: ‘’ “” */
    42     0x2100, 0x2150, /* Letterlike Symbols: Ⅎ */
    43     0x2200, 0x2300, /* Mathematical Operators: √ ∞ ∙ */
    44     0x2300, 0x2400, /* Miscellaneous Technical: ⌐ ⌂ ⌠ ⌡ */
    45     0x2500, 0x2580, /* Box Drawing: ═ ║ ╗ ╔ ╩ */
    46     0x2580, 0x25a0, /* Block Elements: ▛ ▞ ░ ▒ ▓ */
    47     0, 0
    48 };
    49 
    5029int main(int argc, char *argv[])
    5130{
     31    unsigned long int const *blocks;
     32    cucul_font_t *f;
     33    char const * const * fonts;
    5234    cucul_canvas_t *cv;
    5335    cucul_buffer_t *buffer;
    5436    unsigned int i, j, x, y, glyphs;
    5537
    56     for(i = 0, glyphs = 0; blocklist[i + 1]; i += 2)
    57         glyphs += blocklist[i + 1] - blocklist[i];
     38    fonts = cucul_get_font_list();
     39    f = cucul_load_font(fonts[0], 0);
     40    blocks = cucul_get_font_blocks(f);
     41
     42    for(i = 0, glyphs = 0; blocks[i + 1]; i += 2)
     43        glyphs += blocks[i + 1] - blocks[i];
    5844
    5945    /* Create a canvas */
     
    6450    x = y = 0;
    6551
    66     for(i = 0; blocklist[i + 1]; i += 2)
     52    for(i = 0; blocks[i + 1]; i += 2)
    6753    {
    68         for(j = blocklist[i]; j < blocklist[i + 1]; j++)
     54        for(j = blocks[i]; j < blocks[i + 1]; j++)
    6955        {
    7056            cucul_putchar(cv, x, y, j);
     
    7763        }
    7864    }
     65
     66    cucul_free_font(f);
    7967
    8068    buffer = cucul_export_canvas(cv, "tga");
Note: See TracChangeset for help on using the changeset viewer.