Changeset 763


Ignore:
Timestamp:
Apr 13, 2006, 6:10:16 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Implemented cucul_get_font_list() to retrieve the list of builtin fonts.
  • Fixed font selection through cucul_font_load().
  • Added a bigger 10x19 bold font.
Location:
libcaca/trunk
Files:
1 added
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/Makefile.am

    r748 r763  
    2727        dither.c \
    2828        font.c \
    29         font_monospace9.h \
     29        font_mono9.h \
     30        font_monobold12.h \
    3031        export_irc.c \
    3132        export_ansi.c \
  • libcaca/trunk/cucul/cucul.h

    r760 r763  
    192192struct cucul_font;
    193193struct cucul_font *cucul_load_font(void const *, unsigned int);
     194char const * const * cucul_get_font_list(void);
    194195unsigned int cucul_get_font_width(struct cucul_font *);
    195196unsigned int cucul_get_font_height(struct cucul_font *);
  • libcaca/trunk/cucul/font.c

    r760 r763  
    3434
    3535/* Internal fonts */
    36 uint8_t const font_monospace9[] =
    37 #include "font_monospace9.h"
    38 ;
    39 
     36#include "font_mono9.h"
     37#include "font_monobold12.h"
     38
     39/* Helper structure for font loading */
    4040struct font_header
    4141{
     
    112112
    113113    if(size == 0)
    114         return cucul_load_font(font_monospace9, 150000); /* FIXME */
     114    {
     115        if(!strcasecmp(data, "Monospace 9"))
     116            return cucul_load_font(mono9_data, mono9_size);
     117        if(!strcasecmp(data, "Monospace Bold 12"))
     118            return cucul_load_font(monobold12_data, monobold12_size);
     119
     120        return NULL;
     121    }
    115122
    116123    f = malloc(sizeof(struct cucul_font));
     
    154161
    155162    return f;
     163}
     164
     165/**
     166 * \brief Get available builtin fonts
     167 *
     168 * Return a list of available builtin fonts. The list is a NULL-terminated
     169 * array of strings.
     170 *
     171 * \return An array of strings.
     172 */
     173char const * const * cucul_get_font_list(void)
     174{
     175    static char const * const list[] =
     176    {
     177        "Monospace 9",
     178        "Monospace Bold 12",
     179        NULL
     180    };
     181
     182    return list;
    156183}
    157184
  • libcaca/trunk/cucul/font_mono9.h

    r759 r763  
    11/* libcucul font file
    22 * "Monospace 9": 96 dpi, 4 bpp, 7x15 glyphs
    3  * Automatically generated by tools/makefont.c */
     3 * Automatically generated by tools/makefont.c:
     4 *   tools/makefont mono9 "Monospace 9" 96 4
     5 */
    46
     7static unsigned int const mono9_size = 98740;
     8static unsigned char const mono9_data[] =
    59/* file: */
    610"CACA" /* caca_header */
     
    812
    913/* font_header: */
    10 "\0\0003\034" /* header_size */
     14"\0\0003\034" /* control_size */
    1115"\0\001N\220" /* data_size */
    1216"\0\001" /* version */
     
    32683272/* U+259E: "▞" */ "\0\006\377\360\000o\377\0\006\377\360\000o\377\0\006\377\360\000o\377\231\230fo\377\220\0\377\371\0\017\377\220\0\377\371\0\017\377\220\0\377\371\0\0\0\0\0\0\0\0\0"
    32693273/* U+259F: "▟" */ "\0\006\377\360\000o\377\0\006\377\360\000o\377\0\006\377\360\000o\377\231\234\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\360\0\0\0\0\0\0\0"
     3274;
  • libcaca/trunk/test/font.c

    r760 r763  
    3434    unsigned char *buf;
    3535    unsigned int x, y, w, h;
     36    char const * const * fonts;
    3637
    3738    /* Create a canvas */
     
    4445
    4546    /* Load a libcucul internal font */
    46     f = cucul_load_font("Monospace 9", 0);
     47    fonts = cucul_get_font_list();
     48    if(fonts[0] == NULL)
     49    {
     50        fprintf(stderr, "error: libcucul was compiled without any fonts\n");
     51        return -1;
     52    }
     53    f = cucul_load_font(fonts[0], 0);
    4754
    4855    /* Create our bitmap buffer (32-bit ARGB) */
Note: See TracChangeset for help on using the changeset viewer.