From 15b7221813a039df3e0690b3e2ed59a0561f2926 Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 7 Mar 2014 01:08:04 +0100 Subject: New, fancy schmancy scrolling working as intended --- host/bdf.c | 6 +++--- host/font.c | 7 ++++--- host/font.h | 1 - host/server.py | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/host/bdf.c b/host/bdf.c index e6ab827..a95ed8b 100644 --- a/host/bdf.c +++ b/host/bdf.c @@ -283,7 +283,7 @@ int framebuffer_render_text(char *s, glyphtable_t *glyph_table, color_t *gbuf, s glyph_t *g = glyph_table->data[c]; /* Is the glyph within the buffer's bounds? */ - if(x+g->width > offx && x < offx+gbufwidth){ + //if(x+g->width > offx && x < offx+gbufwidth){ /* x-offx might be negative down to -g->width+1, but that's ok */ render_glyph(g, gbuf, gbufwidth, x-offx, 0, fg, bg); if(style.strikethrough || style.underline){ @@ -291,7 +291,7 @@ int framebuffer_render_text(char *s, glyphtable_t *glyph_table, color_t *gbuf, s /* g->y usually is a negative index of the glyph's baseline measured from the glyph's bottom */ int uly = gbufheight + g->y; for(int i=0; iwidth; i++){ - if(x+i >= offx){ /* Stay within the frame buffer's bounds */ + if(x+i >= offx && x+i-offx < gbufwidth){ /* Stay within the frame buffer's bounds */ if(style.strikethrough) gbuf[sty*gbufwidth + x + i - offx] = fg; if(style.underline) @@ -299,7 +299,7 @@ int framebuffer_render_text(char *s, glyphtable_t *glyph_table, color_t *gbuf, s } } } - } + //} x += g->width; } return 0; diff --git a/host/font.c b/host/font.c index c1f1d22..59bc2ef 100644 --- a/host/font.c +++ b/host/font.c @@ -18,12 +18,13 @@ void render_glyph(glyph_t *g, color_t *buf, unsigned int bufwidth, int offx, uns } color_t *p = buf + (offy+y)*bufwidth + offx; /* Take care to only render what's within the framebuffer's bounds */ - for(unsigned int x=0; (x < g->width) && (offx+x < bufwidth); x++){ + for(int x=0; (x < g->width) && (offx+x < (int)bufwidth); x++){ if(offx + x >= 0){ color_t c = (data&(1<<(g->width-1))) ? fg : bg; - *p++ = c; - data <<= 1; + *p = c; } + p++; + data <<= 1; } } } diff --git a/host/font.h b/host/font.h index ad7f851..6a6f302 100644 --- a/host/font.h +++ b/host/font.h @@ -29,7 +29,6 @@ glyphtable_t *read_bdf(FILE *f); void free_glyphtable(glyphtable_t *glyph_table); -// Requires buf to point to a buffer at least of size glyph->width*glyph->height. void render_glyph(glyph_t *g, color_t *buf, unsigned int bufwidth, int offx, unsigned int offy, color_t fg, color_t bg); #endif//__FONT_H__ diff --git a/host/server.py b/host/server.py index 679b13b..ef4ce32 100755 --- a/host/server.py +++ b/host/server.py @@ -50,7 +50,7 @@ def render_text(text, offset): printlock = threading.Lock() def printframe(fb): - h,w,_ = fb.shape + w,h,_ = fb.shape printlock.acquire() print('\0337\033[H', end='') print('Rendering frame @{}'.format(time())) @@ -60,7 +60,7 @@ def printframe(fb): def scroll(text): """ Returns whether it could scroll all the text uninterrupted """ - log('Scrolling', text) + #log('Scrolling', text) w,h = compute_text_bounds(text) for i in range(-DISPLAY_WIDTH,w+1): fb = render_text(text, i); -- cgit