[Horus] Improved fix for the BOLD | TINSIZE bug (it takes care of all impossible combinations now)
This commit is contained in:
@@ -311,11 +311,9 @@ void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t l
|
||||
#define INCREMENT_POS(delta) \
|
||||
do { if (flags & VERTICAL) y -= delta; else x += delta; } while(0)
|
||||
|
||||
if ((flags & TINSIZE) && (flags & BOLD)) flags &= ~(BOLD); //TINSIZE | BOLD segfault, so preventing it
|
||||
|
||||
int width = getTextWidth(s, len, flags);
|
||||
int height = getFontHeight(flags);
|
||||
int fontindex = FONTSIZE(flags) >> 8;
|
||||
uint32_t fontindex = FONTINDEX(flags);
|
||||
const pm_uchar * font = fontsTable[fontindex];
|
||||
const uint16_t * fontspecs = fontspecsTable[fontindex];
|
||||
BitmapBuffer * fontcache = NULL;
|
||||
@@ -327,7 +325,7 @@ void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t l
|
||||
|
||||
coord_t & pos = (flags & VERTICAL) ? y : x;
|
||||
|
||||
if ((flags&INVERS) && ((~flags & BLINK) || BLINK_ON_PHASE)) {
|
||||
if ((flags & INVERS) && ((~flags & BLINK) || BLINK_ON_PHASE)) {
|
||||
uint16_t fgColor = lcdColorTable[COLOR_IDX(flags)];
|
||||
if (fgColor == lcdColorTable[TEXT_COLOR_INDEX]) {
|
||||
flags = TEXT_INVERTED_COLOR | (flags & 0x0ffff);
|
||||
|
||||
@@ -76,8 +76,15 @@ pm_uchar font_stdsizebold[] = {
|
||||
#include "font_stdsizebold.lbm"
|
||||
};
|
||||
|
||||
const uint16_t * const fontspecsTable[16] = { font_stdsize_specs, font_tinsize_specs, font_smlsize_specs, font_midsize_specs, font_dblsize_specs, font_xxlsize_specs, font_stdsizebold_specs };
|
||||
const uint8_t * const fontsTable[16] = { font_stdsize, font_tinsize, font_smlsize, font_midsize, font_dblsize, font_xxlsize, font_stdsizebold };
|
||||
const uint16_t * const fontspecsTable[16] = {
|
||||
font_stdsize_specs, font_tinsize_specs, font_smlsize_specs, font_midsize_specs, font_dblsize_specs, font_xxlsize_specs, font_stdsize_specs, font_stdsize_specs,
|
||||
font_stdsizebold_specs, font_tinsize_specs, font_smlsize_specs, font_midsize_specs, font_dblsize_specs, font_xxlsize_specs, font_stdsize_specs, font_stdsize_specs
|
||||
};
|
||||
|
||||
const uint8_t * const fontsTable[16] = {
|
||||
font_stdsize, font_tinsize, font_smlsize, font_midsize, font_dblsize, font_xxlsize, font_stdsize, font_stdsize,
|
||||
font_stdsizebold, font_tinsize, font_smlsize, font_midsize, font_dblsize, font_xxlsize, font_stdsize, font_stdsize
|
||||
};
|
||||
|
||||
BitmapBuffer * fontCache[2] = { NULL, NULL };
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ void lcdPutFontPattern(coord_t x, coord_t y, const uint8_t * font, const uint16_
|
||||
|
||||
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
|
||||
{
|
||||
int fontindex = FONTSIZE(flags) >> 8;
|
||||
uint32_t fontindex = FONTINDEX(flags);
|
||||
const pm_uchar * font = fontsTable[fontindex];
|
||||
const uint16_t * fontspecs = fontspecsTable[fontindex];
|
||||
lcdPutFontPattern(x, y, font, fontspecs, getMappedChar(c), flags);
|
||||
@@ -81,15 +81,15 @@ uint8_t getStringInfo(const char *s)
|
||||
return result;
|
||||
}
|
||||
|
||||
int getFontHeight(LcdFlags flags)
|
||||
uint8_t getFontHeight(LcdFlags flags)
|
||||
{
|
||||
static const int heightTable[16] = { 12, 10, 11, 14, 32, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 };
|
||||
return heightTable[FONTSIZE(flags) >> 8];
|
||||
static const uint8_t heightTable[16] = { 12, 10, 11, 14, 32, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 };
|
||||
return heightTable[FONTINDEX(flags)];
|
||||
}
|
||||
|
||||
int getTextWidth(const char * s, int len, LcdFlags flags)
|
||||
{
|
||||
const uint16_t * specs = fontspecsTable[FONTSIZE(flags) >> 8];
|
||||
const uint16_t * specs = fontspecsTable[FONTINDEX(flags)];
|
||||
|
||||
int result = 0;
|
||||
for (int i=0; len==0 || i<len; ++i) {
|
||||
|
||||
@@ -69,20 +69,30 @@ enum FontSizeIndex {
|
||||
MIDSIZE_INDEX,
|
||||
DBLSIZE_INDEX,
|
||||
XXLSIZE_INDEX,
|
||||
BOLDSTDSIZE_INDEX,
|
||||
SPARE6_INDEX,
|
||||
SPARE7_INDEX,
|
||||
STDSIZE_BOLD_INDEX,
|
||||
SPARE9_INDEX,
|
||||
SPAREa_INDEX,
|
||||
SPAREb_INDEX,
|
||||
SPAREc_INDEX,
|
||||
SPAREd_INDEX,
|
||||
SPAREe_INDEX,
|
||||
SPAREf_INDEX,
|
||||
};
|
||||
|
||||
#define FONTSIZE(x) ((x) & 0x0700)
|
||||
#define TINSIZE (TINSIZE_INDEX << 8)
|
||||
#define SMLSIZE (SMLSIZE_INDEX << 8)
|
||||
#define MIDSIZE (MIDSIZE_INDEX << 8)
|
||||
#define DBLSIZE (DBLSIZE_INDEX << 8)
|
||||
#define XXLSIZE (XXLSIZE_INDEX << 8)
|
||||
#define BOLD (BOLDSTDSIZE_INDEX << 8)
|
||||
#define BOLD (STDSIZE_BOLD_INDEX << 8)
|
||||
#define FONTSIZE(flags) ((flags) & 0x0f00)
|
||||
#define FONTINDEX(flags) (FONTSIZE(flags) >> 8)
|
||||
|
||||
#define VERTICAL 0x0800
|
||||
#define TIMEBLINK 0x1000
|
||||
#define TIMEHOUR 0x2000
|
||||
#define VERTICAL 0x4000
|
||||
#define NO_FONTCACHE 0x8000
|
||||
|
||||
#include "colors.h"
|
||||
@@ -241,7 +251,7 @@ inline int getBitmapHeight(const uint8_t * bmp)
|
||||
}
|
||||
|
||||
char getMappedChar(unsigned char c);
|
||||
int getFontHeight(LcdFlags flags);
|
||||
uint8_t getFontHeight(LcdFlags flags);
|
||||
int getTextWidth(const pm_char *s, int len=0, LcdFlags flags=0);
|
||||
|
||||
inline void lcdDrawBitmapPattern(coord_t x, coord_t y, const uint8_t * img, LcdFlags flags=0, coord_t offset=0, coord_t width=0)
|
||||
|
||||
Reference in New Issue
Block a user