use RLE compressed fonts on Horus
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
#include "rle.h"
|
||||
|
||||
#if !defined(BOOT)
|
||||
const uint16_t font_tinsize_specs[] = {
|
||||
@@ -82,17 +83,18 @@ const pm_uchar font_stdsizebold[] = {
|
||||
|
||||
#if !defined(BOOT)
|
||||
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_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,
|
||||
const uint8_t * 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
|
||||
};
|
||||
|
||||
#else
|
||||
const uint16_t * const fontspecsTable[1] = { font_stdsize_specs };
|
||||
const uint8_t * const fontsTable[1] = { font_stdsize };
|
||||
const uint8_t * fontsTable[1] = { font_stdsize };
|
||||
#endif
|
||||
|
||||
BitmapBuffer * fontCache[2] = { NULL, NULL };
|
||||
@@ -117,3 +119,38 @@ void loadFontCache()
|
||||
fontCache[0] = createFontCache(fontsTable[0], TEXT_COLOR, TEXT_BGCOLOR);
|
||||
fontCache[1] = createFontCache(fontsTable[0], TEXT_INVERTED_COLOR, TEXT_INVERTED_BGCOLOR);
|
||||
}
|
||||
|
||||
|
||||
static uint8_t* decompressFont(const uint8_t* font)
|
||||
{
|
||||
uint16_t width = *((uint16_t *)font);
|
||||
uint16_t height = *(((uint16_t *)font)+1);
|
||||
|
||||
size_t font_size = width * height;
|
||||
uint8_t* dec_buf = (uint8_t*)malloc(font_size + 4);
|
||||
|
||||
// copy width / height
|
||||
memcpy(dec_buf,font,4);
|
||||
|
||||
rle_decode_8bit(dec_buf+4, font_size, font+4);
|
||||
return dec_buf;
|
||||
}
|
||||
|
||||
void loadFonts()
|
||||
{
|
||||
static bool fonts_loaded = false;
|
||||
if (fonts_loaded) return;
|
||||
|
||||
#if !defined(BOOT)
|
||||
int i=0;
|
||||
for (; i<9; i++)
|
||||
fontsTable[i] = decompressFont(fontsTable[i]);
|
||||
|
||||
for (; i<16; i++)
|
||||
fontsTable[i] = fontsTable[i-9];
|
||||
#else
|
||||
fontsTable[0] = decompressFont(fontsTable[0]);
|
||||
#endif
|
||||
|
||||
fonts_loaded = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user