From cf27356102808bb9c4a2ccfb0327b9cf66d538f5 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 12 May 2011 02:23:07 +0200 Subject: [PATCH] renderer now works with >8px fonts and proportional width fonts --- lcd/render.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lcd/render.c b/lcd/render.c index 3ad9692..4df0823 100644 --- a/lcd/render.c +++ b/lcd/render.c @@ -12,26 +12,29 @@ int DoChar(int sx, int sy, char c){ int x; int y; + /* how many bytes is it high? */ + char height=(font->u8Height-1)/8+1; + /* "real" coordinates. Our physical display is upside down */ int rx=RESX-sx-1; int ry=RESY-sy-font->u8Height; - - /* how many bytes is it high? */ - char height=(font->u8Height-1)/8+1; +// int ry=RESY-sy-height*8; /* Does this font provide this character? */ if(cu8FirstChar || c>font->u8LastChar) c=font->u8FirstChar+1; // error /* starting offset into character source data */ - int off,width; + int off,width,blank; if(font->u8Width==0){ off=font->charInfo[c-font->u8FirstChar].offset; width=font->charInfo[c-font->u8FirstChar].widthBits; // width=(font->charInfo[c-font->u8FirstChar].offset-off)/8; + blank=1; }else{ off=(c-font->u8FirstChar)*font->u8Width*height; width=font->u8Width; + blank=0; }; /* raw character data */ @@ -56,19 +59,14 @@ int DoChar(int sx, int sy, char c){ if(y==0){ mask=mask>>(yoff); } else if(y==height){ - if(font->u8Height==6) - mask=252; - if(font->u8Height==10) - mask=192; - if(font->u8Height==16) - mask=255; + mask=mask<<((8-(font->u8Height%8))%8); mask=mask<<(8-yoff); }; if(font_direction==FONT_DIR_LTR) flip(mask); - for(x=0;xu8Width;x++){ + for(x=0;x