New, fancy schmancy scrolling working as intended

This commit is contained in:
jaseg 2014-03-07 01:08:04 +01:00
parent d16223fd25
commit 15b7221813
4 changed files with 9 additions and 9 deletions

View file

@ -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; i<g->width; 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;

View file

@ -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;
}
}
}

View file

@ -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__

View file

@ -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);