diff options
author | Rich Felker <dalias@aerifal.cx> | 2006-10-05 21:10:32 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2006-10-05 21:10:32 +0000 |
commit | cffa2eeb2052df70c52fc720add9fe7e31b314e7 (patch) | |
tree | d4c80a2f080f3419959e54a462f259776bb37ab4 /refresh.c | |
parent | dc6a00a52f6df3c7e66c6535c2489f51fa1fa13a (diff) |
the big UCF-font commit!
still a little bit messy, but it works quite well already
more to come soon.
Diffstat (limited to 'refresh.c')
-rw-r--r-- | refresh.c | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -1,6 +1,7 @@ /* uuterm, Copyright (C) 2006 Rich Felker; licensed under GNU GPL v2 only */ #include "uuterm.h" +#include "ucf.h" static void extract_cell(unsigned *ch, struct uucell *cell) { @@ -19,15 +20,21 @@ static void extract_cell(unsigned *ch, struct uucell *cell) const void *ascii_get_glyph(unsigned); -static const void *lookup_glyph(unsigned *this, int i, unsigned *prev, unsigned *next) +static const void *lookup_glyph(struct ucf *f, int i, unsigned *this, unsigned *prev, unsigned *next, int width, int part) { - return ascii_get_glyph(this[i]); + const unsigned char *a; + static const unsigned c[2] = { 0xfffd, 0 }; + int g = ucf_lookup(f, i, this, prev, next, width); + if (g<0 && !i) g = ucf_lookup(f, i, c, c, c, width); + if (g>=0) return f->glyphs + f->S * (g + part); + return 0; } void uuterm_refresh_row(struct uudisp *d, struct uurow *row, int x1, int x2) { - unsigned ch[4][sizeof(row->cells[0].c)+1]; + unsigned ch[4][sizeof(row->cells[0].c)+1], *chp; int x, i; + int width, part; if (x1) extract_cell(ch[(x1-1)&3], &row->cells[x1-1]); else memset(ch[3], 0, sizeof(ch[3])); @@ -35,9 +42,16 @@ void uuterm_refresh_row(struct uudisp *d, struct uurow *row, int x1, int x2) for (x=x1; x<=x2; x++) { extract_cell(ch[(x+1)&3], &row->cells[x+1]); - for (i=0; i<sizeof(ch[0]) && ch[x&3][i]; i++) { - const void *glyph = lookup_glyph(ch[x&3], i, ch[(x+3)&3], ch[(x+1)&3]); - uudisp_draw_glyph(d, row->idx, x, glyph, row->cells[x].a & 0xff); + if (ch[x&3][0] == UU_FULLWIDTH) { + width = 2; part = 0; chp = ch[(x+1)&3]; + } else if (ch[(x+3)&3][0] == UU_FULLWIDTH) { + width = 2; part = 1; chp = ch[x&3]; + } else { + width = 1; part = 0; chp = ch[x&3]; + } + for (i=0; i<sizeof(ch[0]) && chp[i]; i++) { + const void *glyph = lookup_glyph(d->font, i, chp, ch[(x+3)&3], ch[(x+1)&3], width, part); + if (glyph) uudisp_draw_glyph(d, row->idx, x, glyph, row->cells[x].a & 0xff); } } } |