ok ok - they look ugly, but handle bitmap fonts! :(

SVN revision: 16542
This commit is contained in:
Carsten Haitzler 2005-09-05 08:01:15 +00:00
parent d6be56204c
commit 3c0b9cc34d
3 changed files with 163 additions and 26 deletions

View File

@ -1633,7 +1633,40 @@ _layout_text_append(Ctxt *c, Evas_Object_Textblock_Format *fmt, Evas_Object_Text
if (wrap > 0)
{
twrap = wrap;
evas_common_font_utf8_get_prev((unsigned char *)str, &twrap);
ch = evas_common_font_utf8_get_prev((unsigned char *)str, &twrap);
//
/* the text intersects the wrap point on a whitespace char */
if (_is_white(ch))
{
_layout_item_text_cutoff(c, it, wrap);
twrap = wrap;
ch = evas_common_font_utf8_get_next((unsigned char *)str, &twrap);
str = str + twrap;
}
/* intersects a word */
else
{
/* walk back to start of word */
twrap = _layout_word_start(str, wrap);
if (twrap != 0)
{
wrap = twrap;
ch = evas_common_font_utf8_get_prev((unsigned char *)str, &twrap);
_layout_item_text_cutoff(c, it, twrap);
str = str + wrap;
}
else
{
empty_item = 1;
if (it->text) free(it->text);
_format_free(c->obj, it->format);
free(it);
twrap = _layout_word_end(str, wrap);
ch = evas_common_font_utf8_get_next((unsigned char *)str, &twrap);
str = str + twrap;
}
}
#if 0
ch = evas_common_font_utf8_get_prev((unsigned char *)str, &twrap);
while (_is_white(ch) && (twrap >= 0))
ch = evas_common_font_utf8_get_prev((unsigned char *)str, &twrap);
@ -1673,6 +1706,7 @@ _layout_text_append(Ctxt *c, Evas_Object_Textblock_Format *fmt, Evas_Object_Text
_layout_item_text_cutoff(c, it, twrap);
str = str + wrap;
}
#endif
}
else
{

View File

@ -167,8 +167,11 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
w = fg->glyph_out->bitmap.width;
if (j < w) j = w;
h = fg->glyph_out->bitmap.rows;
if ((fg->glyph_out->bitmap.pixel_mode == ft_pixel_mode_grays) &&
(fg->glyph_out->bitmap.num_grays == 256))
/*
if ((fg->glyph_out->bitmap.pixel_mode == ft_pixel_mode_grays)
&& (fg->glyph_out->bitmap.num_grays == 256)
)
*/
{
if ((j > 0) && (chr_x + w > ext_x))
{
@ -184,34 +187,93 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
}
else
{
for (i = 0; i < h; i++)
if (fg->glyph_out->bitmap.num_grays == 256)
{
int dx, dy;
int in_x, in_w;
in_x = 0;
in_w = 0;
dx = chr_x;
dy = y - (chr_y - i - y);
if ((dx < (ext_x + ext_w)) &&
(dy >= (ext_y)) &&
(dy < (ext_y + ext_h)))
for (i = 0; i < h; i++)
{
if (dx + w > (ext_x + ext_w))
in_w += (dx + w) - (ext_x + ext_w);
if (dx < ext_x)
int dx, dy;
int in_x, in_w;
in_x = 0;
in_w = 0;
dx = chr_x;
dy = y - (chr_y - i - y);
if ((dx < (ext_x + ext_w)) &&
(dy >= (ext_y)) &&
(dy < (ext_y + ext_h)))
{
in_w += ext_x - dx;
in_x = ext_x - dx;
dx = ext_x;
if (dx + w > (ext_x + ext_w))
in_w += (dx + w) - (ext_x + ext_w);
if (dx < ext_x)
{
in_w += ext_x - dx;
in_x = ext_x - dx;
dx = ext_x;
}
if (in_w < w)
{
func(data + (i * j) + in_x,
im + (dy * im_w) + dx,
w - in_w,
dc->col.col);
}
}
if (in_w < w)
}
}
else if (fg->glyph_out->bitmap.num_grays == 0)
{
DATA8 *tmpbuf = NULL, *dp, *tp, bits;
int bi, bj;
const DATA8 bitrepl[2] = {0x0, 0xff};
tmpbuf = malloc(w);
if (tmpbuf)
{
for (i = 0; i < h; i++)
{
func(data + (i * j) + in_x,
im + (dy * im_w) + dx,
w - in_w,
dc->col.col);
int dx, dy;
int in_x, in_w, end;
in_x = 0;
in_w = 0;
dx = chr_x;
dy = y - (chr_y - i - y);
tp = tmpbuf;
dp = data + (i * fg->glyph_out->bitmap.pitch);
for (bi = 0; bi < w; bi += 8)
{
bits = *dp;
if ((w - bi) < 8) end = w - bi;
else end = 8;
for (bj = 0; bj < end; bj++)
{
*tp = bitrepl[(bits >> (7 - bj)) & 0x1];
tp++;
}
dp++;
}
if ((dx < (ext_x + ext_w)) &&
(dy >= (ext_y)) &&
(dy < (ext_y + ext_h)))
{
if (dx + w > (ext_x + ext_w))
in_w += (dx + w) - (ext_x + ext_w);
if (dx < ext_x)
{
in_w += ext_x - dx;
in_x = ext_x - dx;
dx = ext_x;
}
if (in_w < w)
{
func(tmpbuf + in_x,
im + (dy * im_w) + dx,
w - in_w,
dc->col.col);
}
}
}
free(tmpbuf);
}
}
}

View File

@ -33,6 +33,7 @@ evas_gl_font_texture_new(Evas_GL_Context *gc, RGBA_Font_Glyph *fg)
free(ft);
return NULL;
}
if (fg->glyph_out->bitmap.num_grays == 256)
{
int x, y;
DATA8 *p1, *p2;
@ -49,7 +50,47 @@ evas_gl_font_texture_new(Evas_GL_Context *gc, RGBA_Font_Glyph *fg)
}
}
}
else if (fg->glyph_out->bitmap.num_grays == 0)
{
DATA8 *tmpbuf = NULL, *dp, *tp, bits;
int bi, bj, end;
const DATA8 bitrepl[2] = {0x0, 0xff};
tmpbuf = malloc(w);
if (tmpbuf)
{
int x, y;
DATA8 *p1, *p2;
for (y = 0; y < h; y++)
{
p1 = tmpbuf;
p2 = ndata + (nw * y);
tp = tmpbuf;
dp = data + (y * fg->glyph_out->bitmap.pitch);
for (bi = 0; bi < w; bi += 8)
{
bits = *dp;
if ((w - bi) < 8) end = w - bi;
else end = 8;
for (bj = 0; bj < end; bj++)
{
*tp = bitrepl[(bits >> (7 - bj)) & 0x1];
tp++;
}
dp++;
}
for (x = 0; x < w; x++)
{
*p2 = *p1;
p1++;
p2++;
}
}
free(tmpbuf);
}
}
/* where in pool texture does this live */
ft->w = w;
ft->h = h;