Parcourir la source

* Got rid of cucul_render_glyph(). Ahahahaha.

tags/v0.99.beta14
Sam Hocevar sam il y a 18 ans
Parent
révision
9044384d02
2 fichiers modifiés avec 0 ajouts et 77 suppressions
  1. +0
    -1
      cucul/cucul.h
  2. +0
    -76
      cucul/font.c

+ 0
- 1
cucul/cucul.h Voir le fichier

@@ -209,7 +209,6 @@ unsigned int cucul_get_font_height(cucul_font_t *);
unsigned long int const *cucul_get_font_blocks(cucul_font_t *);
int cucul_render_canvas(cucul_canvas_t *, cucul_font_t *, void *,
unsigned int, unsigned int, unsigned int);
int cucul_render_glyph(cucul_font_t *, unsigned int, void *, unsigned int);
int cucul_free_font(cucul_font_t *);
/* @} */



+ 0
- 76
cucul/font.c Voir le fichier

@@ -493,82 +493,6 @@ int cucul_render_canvas(cucul_canvas_t *cv, cucul_font_t *f,
return 0;
}

/** \brief Render a single glyph onto an image buffer
*
* This function renders the given character on an image buffer using a
* specific font. The pixel format is fixed (8 bits per pixel).
*
* The required buffer size can be computed using cucul_get_font_width()
* and cucul_get_font_height().
*
* This function never fails.
*
* \param f The font, as returned by cucul_load_font()
* \param ch The character to render
* \param buf The image buffer
* \param stride width of the destination buffer
* \return This function always returns 0.
*/
int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buf,
unsigned int stride)
{
unsigned int b, y;
struct glyph_info *g;
uint8_t *glyph = NULL;

/* Find the Unicode block where our glyph lies */
for(b = 0; b < f->header.blocks; b++)
{
if(ch < f->block_list[b].start)
{
b = f->header.blocks;
break;
}
if(ch < f->block_list[b].stop) {
break;
}
}

/* Glyph not in font? Skip it. */
if(b == f->header.blocks)
return 0;

if(f->header.bpp != 8)
glyph = malloc(f->header.width * f->header.height);

g = &f->glyph_list[f->block_list[b].index
+ ch - f->block_list[b].start];

/* Step 1: unpack glyph */
switch(f->header.bpp)
{
case 8:
glyph = f->font_data + g->data_offset;
break;
case 4:
unpack_glyph4(glyph, f->font_data + g->data_offset,
g->width * g->height);
break;
case 2:
unpack_glyph2(glyph, f->font_data + g->data_offset,
g->width * g->height);
break;
case 1:
unpack_glyph1(glyph, f->font_data + g->data_offset,
g->width * g->height);
break;
}

/* Step 2: render glyph */
for(y = 0; y < g->height; y++)
memcpy((uint8_t*)buf + y * stride, glyph + y * g->width, g->width);

if(f->header.bpp != 8)
free(glyph);

return 0;
}

/*
* The libcaca font format, version 1
* ----------------------------------


Chargement…
Annuler
Enregistrer