Ignore:
Timestamp:
Sep 27, 2008, 3:12:46 PM (11 years ago)
Author:
Sam Hocevar
Message:

Starting refactoring to get rid of libcucul. The initial reason for the
split is rendered moot by the plugin system: when enabled, binaries do
not link directly with libX11 or libGL. I hope this is a step towards
more consisteny and clarity.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/font.c

    r2819 r2821  
    11/*
    2  *  libcucul      Canvas for ultrafast compositing of Unicode letters
     2 *  libcaca       Colour ASCII-Art library
    33 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
    44 *                All Rights Reserved
     
    2828#endif
    2929
    30 #include "cucul.h"
    31 #include "cucul_internals.h"
     30#include "caca.h"
     31#include "caca_internals.h"
    3232
    3333/* Internal fonts */
     
    5656};
    5757
    58 struct cucul_font
     58struct caca_font
    5959{
    6060    struct font_header header;
     
    9292 *
    9393 *  This function loads a font and returns a handle to its internal
    94  *  structure. The handle can then be used with cucul_render_canvas()
     94 *  structure. The handle can then be used with caca_render_canvas()
    9595 *  for bitmap output.
    9696 *
     
    100100 *  If \c size is non-zero, the \c size bytes of memory at address \c data
    101101 *  are loaded as a font. This memory are must not be freed by the calling
    102  *  program until the font handle has been freed with cucul_free_font().
     102 *  program until the font handle has been freed with caca_free_font().
    103103 *
    104104 *  If an error occurs, NULL is returned and \b errno is set accordingly:
     
    111111 *  \return A font handle or NULL in case of error.
    112112 */
    113 cucul_font_t *cucul_load_font(void const *data, size_t size)
    114 {
    115     cucul_font_t *f;
     113caca_font_t *caca_load_font(void const *data, size_t size)
     114{
     115    caca_font_t *f;
    116116    int i;
    117117
     
    119119    {
    120120        if(!strcasecmp(data, "Monospace 9"))
    121             return cucul_load_font((char *)&mono9_data, mono9_size);
     121            return caca_load_font((char *)&mono9_data, mono9_size);
    122122        if(!strcasecmp(data, "Monospace Bold 12"))
    123             return cucul_load_font((char *)&monobold12_data, monobold12_size);
     123            return caca_load_font((char *)&monobold12_data, monobold12_size);
    124124
    125125        seterrno(ENOENT);
     
    135135    }
    136136
    137     f = malloc(sizeof(cucul_font_t));
     137    f = malloc(sizeof(caca_font_t));
    138138    if(!f)
    139139    {
     
    302302 *  \return An array of strings.
    303303 */
    304 char const * const * cucul_get_font_list(void)
     304char const * const * caca_get_font_list(void)
    305305{
    306306    static char const * const list[] =
     
    321321 *  This function never fails.
    322322 *
    323  *  \param f The font, as returned by cucul_load_font()
     323 *  \param f The font, as returned by caca_load_font()
    324324 *  \return The standard glyph width.
    325325 */
    326 int cucul_get_font_width(cucul_font_t const *f)
     326int caca_get_font_width(caca_font_t const *f)
    327327{
    328328    return f->header.width;
     
    336336 *  This function never fails.
    337337 *
    338  *  \param f The font, as returned by cucul_load_font()
     338 *  \param f The font, as returned by caca_load_font()
    339339 *  \return The standard glyph height.
    340340 */
    341 int cucul_get_font_height(cucul_font_t const *f)
     341int caca_get_font_height(caca_font_t const *f)
    342342{
    343343    return f->header.height;
     
    361361 *  This function never fails.
    362362 *
    363  *  \param f The font, as returned by cucul_load_font()
     363 *  \param f The font, as returned by caca_load_font()
    364364 *  \return The list of Unicode blocks supported by the font.
    365365 */
    366 uint32_t const *cucul_get_font_blocks(cucul_font_t const *f)
     366uint32_t const *caca_get_font_blocks(caca_font_t const *f)
    367367{
    368368    return (uint32_t const *)f->user_block_list;
     
    371371/** \brief Free a font structure.
    372372 *
    373  *  This function frees all data allocated by cucul_load_font(). The
    374  *  font structure is no longer usable by other libcucul functions. Once
     373 *  This function frees all data allocated by caca_load_font(). The
     374 *  font structure is no longer usable by other libcaca functions. Once
    375375 *  this function has returned, the memory area that was given to
    376  *  cucul_load_font() can be freed.
     376 *  caca_load_font() can be freed.
    377377 *
    378378 *  This function never fails.
    379379 *
    380  *  \param f The font, as returned by cucul_load_font()
     380 *  \param f The font, as returned by caca_load_font()
    381381 *  \return This function always returns 0.
    382382 */
    383 int cucul_free_font(cucul_font_t *f)
     383int caca_free_font(caca_font_t *f)
    384384{
    385385    free(f->glyph_list);
     
    397397 *
    398398 *  The required image width can be computed using
    399  *  cucul_get_canvas_width() and cucul_get_font_width(). The required
    400  *  height can be computed using cucul_get_canvas_height() and
    401  *  cucul_get_font_height().
     399 *  caca_get_canvas_width() and caca_get_font_width(). The required
     400 *  height can be computed using caca_get_canvas_height() and
     401 *  caca_get_font_height().
    402402 *
    403403 *  Glyphs that do not fit in the image buffer are currently not rendered at
     
    408408 *
    409409 *  \param cv The canvas to render
    410  *  \param f The font, as returned by cucul_load_font()
     410 *  \param f The font, as returned by caca_load_font()
    411411 *  \param buf The image buffer
    412412 *  \param width The width (in pixels) of the image buffer
     
    415415 *  \return 0 in case of success, -1 if an error occurred.
    416416 */
    417 int cucul_render_canvas(cucul_canvas_t const *cv, cucul_font_t const *f,
     417int caca_render_canvas(caca_canvas_t const *cv, caca_font_t const *f,
    418418                        void *buf, int width, int height, int pitch)
    419419{
     
    472472                                + ch - f->block_list[b].start];
    473473
    474             cucul_attr_to_argb64(attr, argb);
     474            caca_attr_to_argb64(attr, argb);
    475475
    476476            /* Step 1: unpack glyph */
Note: See TracChangeset for help on using the changeset viewer.