Переглянути джерело

* Fixed cucul_render_glyph(). There is no way this could have ever possibly

worked properly.
tags/v0.99.beta14
Sam Hocevar sam 18 роки тому
джерело
коміт
7165793ff9
3 змінених файлів з 24 додано та 28 видалено
  1. +2
    -6
      caca/driver_gl.c
  2. +1
    -2
      cucul/cucul.h
  3. +21
    -20
      cucul/font.c

+ 2
- 6
caca/driver_gl.c Переглянути файл

@@ -569,9 +569,7 @@ void gl_generate_glyph(uint32_t c, uint32_t tid, caca_display_t *dp) {
uint8_t *glyph8 = calloc(dp->drv.p->font_width*dp->drv.p->font_height, 1);
uint8_t *glyph32 = calloc(16*16*4, 1);

cucul_render_glyph(dp->drv.p->f, c,
glyph8, dp->drv.p->font_width, dp->drv.p->font_height);

cucul_render_glyph(dp->drv.p->f, c, glyph8, dp->drv.p->font_width);

/* Convert resulting 8bbp glyph to 32bits, 16x16*/
for(s=0;s<(dp->drv.p->font_height<=16?dp->drv.p->font_height:16);s++) {
@@ -603,9 +601,7 @@ void gl_generate_unicode_glyph(uint32_t c, uint32_t tid, caca_display_t *dp) {
uint8_t *glyph8 = calloc(dp->drv.p->font_width*dp->drv.p->font_height, 1);
uint8_t *glyph32 = calloc(16*16*4, 1);

cucul_render_glyph(dp->drv.p->f, c,
glyph8, dp->drv.p->font_width, dp->drv.p->font_height);

cucul_render_glyph(dp->drv.p->f, c, glyph8, dp->drv.p->font_width);

/* Convert resulting 8bbp glyph to 32bits, 16x16*/
for(s=0;s<(dp->drv.p->font_height<=16?dp->drv.p->font_height:16);s++) {


+ 1
- 2
cucul/cucul.h Переглянути файл

@@ -208,8 +208,7 @@ unsigned int cucul_get_font_width(cucul_font_t *);
unsigned int cucul_get_font_height(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, unsigned int);
int cucul_render_glyph(cucul_font_t *, unsigned int, void *, unsigned int);
int cucul_free_font(cucul_font_t *);
/* @} */



+ 21
- 20
cucul/font.c Переглянути файл

@@ -447,34 +447,26 @@ int cucul_render_canvas(cucul_canvas_t *cv, cucul_font_t *f,

/** \brief Render the given character onto given buffer
*
* This function renders the given character on an image buffer using a specific
* font. The pixel format is fixed (8 bits per pixel).
* 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 width can be computed using
* cucul_get_canvas_width() and cucul_get_font_width(). The required
* height can be computed using cucul_get_canvas_height() and
* cucul_get_font_height().
*
* Glyphs that do not fit in the image buffer are currently not rendered at
* all. They may be cropped instead in future versions.
* 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 width The width (in pixels) of the image buffer
* \param height The height (in pixels) of the image buffer
* \return This function return 1 if glyph is succesfully renderer, 0 otherwise
* \param pitch The pitch of the image buffer
* \return This function always returns 0.
*/
int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buffer,
unsigned int width, unsigned int height)
int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buf,
unsigned int stride)
{
unsigned int b;
unsigned int b, y;
struct glyph_info *g;
uint8_t *glyph = buffer;


uint8_t *glyph;

/* Find the Unicode block where our glyph lies */
for(b = 0; b < f->header.blocks; b++)
@@ -493,6 +485,9 @@ int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buffer,
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];

@@ -515,10 +510,16 @@ int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buffer,
g->width * g->height);
break;
}
return 1;
}

/* 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


Завантаження…
Відмінити
Зберегти