gdisp: Fix up font decoder types

This commit is contained in:
Joel Bodenmann 2024-09-18 15:56:40 +02:00
parent 26399f7db1
commit 0ce33c469a
5 changed files with 37 additions and 37 deletions

View File

@ -52,7 +52,7 @@
#include <stdint.h>
#define PROGMEM
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const uint16_t *)(addr))
#define pgm_read_word(addr) (*(const gU16 *)(addr))
#endif /* __AVR__ */

View File

@ -32,7 +32,7 @@ gU8 mf_render_character(const struct mf_font_s *font,
mf_pixel_callback_t callback,
void *state)
{
uint8_t width;
gU8 width;
width = font->render_character(font, x0, y0, character, callback, state);
if (!width)
@ -44,10 +44,10 @@ gU8 mf_render_character(const struct mf_font_s *font,
return width;
}
uint8_t mf_character_width(const struct mf_font_s *font,
gU8 mf_character_width(const struct mf_font_s *font,
mf_char character)
{
uint8_t width;
gU8 width;
width = font->character_width(font, character);
if (!width)
@ -60,12 +60,12 @@ uint8_t mf_character_width(const struct mf_font_s *font,
struct whitespace_state
{
uint8_t min_x, min_y;
uint8_t max_x, max_y;
gU8 min_x, min_y;
gU8 max_x, max_y;
};
static void whitespace_callback(int16_t x, int16_t y, uint8_t count,
uint8_t alpha, void *state)
static void whitespace_callback(int16_t x, int16_t y, gU8 count,
gU8 alpha, void *state)
{
struct whitespace_state *s = state;
if (alpha > 7)
@ -80,8 +80,8 @@ static void whitespace_callback(int16_t x, int16_t y, uint8_t count,
MF_EXTERN void mf_character_whitespace(const struct mf_font_s *font,
mf_char character,
uint8_t *left, uint8_t *top,
uint8_t *right, uint8_t *bottom)
gU8 *left, gU8 *top,
gU8 *right, gU8 *bottom)
{
struct whitespace_state state = {255, 255, 0, 0};
mf_render_character(font, 0, 0, character, whitespace_callback, &state);

View File

@ -105,7 +105,7 @@ MF_EXTERN gU8 mf_render_character(const struct mf_font_s *font,
*
* Returns width of the character in pixels.
*/
MF_EXTERN uint8_t mf_character_width(const struct mf_font_s *font,
MF_EXTERN gU8 mf_character_width(const struct mf_font_s *font,
mf_char character);
/* Count the amount of white space at the borders of a character.
@ -124,8 +124,8 @@ MF_EXTERN uint8_t mf_character_width(const struct mf_font_s *font,
*/
MF_EXTERN void mf_character_whitespace(const struct mf_font_s *font,
mf_char character,
uint8_t *left, uint8_t *top,
uint8_t *right, uint8_t *bottom);
gU8 *left, gU8 *top,
gU8 *right, gU8 *bottom);
/* Find a font based on name. The name can be either short name or full name.
* Note: You can pass MF_INCLUDED_FONTS to search among all the included .h

View File

@ -46,7 +46,7 @@ static const gU8 *find_glyph(const struct mf_rlefont_s *font,
index = character - range->first_char;
if (character >= range->first_char && index < range->char_count)
{
uint16_t offset = pgm_read_word(range->glyph_offsets + index);
gU16 offset = pgm_read_word(range->glyph_offsets + index);
return &range->glyph_data[offset];
}
}
@ -108,13 +108,13 @@ static void write_rle_dictentry(const struct mf_rlefont_s *font,
struct renderstate_r *rstate,
gU8 index)
{
uint16_t offset = pgm_read_word(font->dictionary_offsets + index);
uint16_t length = pgm_read_word(font->dictionary_offsets + index + 1) - offset;
uint16_t i;
gU16 offset = pgm_read_word(font->dictionary_offsets + index);
gU16 length = pgm_read_word(font->dictionary_offsets + index + 1) - offset;
gU16 i;
for (i = 0; i < length; i++)
{
uint8_t code = pgm_read_byte(font->dictionary_data + offset + i);
gU8 code = pgm_read_byte(font->dictionary_data + offset + i);
if ((code & RLE_CODEMASK) == RLE_ZEROS)
{
skip_pixels(rstate, code & RLE_VALMASK);
@ -160,9 +160,9 @@ static void write_bin_codeword(const struct mf_rlefont_s *font,
gU8 code)
{
(void)font;
uint8_t bitcount = fillentry_bitcount(code);
uint8_t byte = code - DICT_START7BIT;
uint8_t runlen = 0;
gU8 bitcount = fillentry_bitcount(code);
gU8 byte = code - DICT_START7BIT;
gU8 runlen = 0;
while (bitcount--)
{
@ -191,7 +191,7 @@ static void write_bin_codeword(const struct mf_rlefont_s *font,
/* Decode and write out a reference codeword */
static void write_ref_codeword(const struct mf_rlefont_s *font,
struct renderstate_r *rstate,
uint8_t code)
gU8 code)
{
if (code == 0)
{
@ -223,15 +223,15 @@ static void write_ref_codeword(const struct mf_rlefont_s *font,
/* Decode and write out a reference encoded dictionary entry. */
static void write_ref_dictentry(const struct mf_rlefont_s *font,
struct renderstate_r *rstate,
uint8_t index)
gU8 index)
{
uint16_t offset = pgm_read_word(font->dictionary_offsets + index);
uint16_t length = pgm_read_word(font->dictionary_offsets + index + 1) - offset;
uint16_t i;
gU16 offset = pgm_read_word(font->dictionary_offsets + index);
gU16 length = pgm_read_word(font->dictionary_offsets + index + 1) - offset;
gU16 i;
for (i = 0; i < length; i++)
{
uint8_t code = pgm_read_byte(font->dictionary_data + offset + i);
gU8 code = pgm_read_byte(font->dictionary_data + offset + i);
write_ref_codeword(font, rstate, code);
}
}
@ -239,7 +239,7 @@ static void write_ref_dictentry(const struct mf_rlefont_s *font,
/* Decode and write out an arbitrary glyph codeword */
static void write_glyph_codeword(const struct mf_rlefont_s *font,
struct renderstate_r *rstate,
uint8_t code)
gU8 code)
{
if (code >= DICT_START + font->rle_entry_count &&
code < DICT_START + font->dict_entry_count)
@ -253,14 +253,14 @@ static void write_glyph_codeword(const struct mf_rlefont_s *font,
}
uint8_t mf_rlefont_render_character(const struct mf_font_s *font,
gU8 mf_rlefont_render_character(const struct mf_font_s *font,
int16_t x0, int16_t y0,
uint16_t character,
gU16 character,
mf_pixel_callback_t callback,
void *state)
{
const uint8_t *p;
uint8_t width;
const gU8 *p;
gU8 width;
struct renderstate_r rstate;
rstate.x_begin = x0;
@ -284,10 +284,10 @@ uint8_t mf_rlefont_render_character(const struct mf_font_s *font,
return width;
}
uint8_t mf_rlefont_character_width(const struct mf_font_s *font,
uint16_t character)
gU8 mf_rlefont_character_width(const struct mf_font_s *font,
gU16 character)
{
const uint8_t *p;
const gU8 *p;
p = find_glyph((struct mf_rlefont_s*)font, character);
if (!p)
return 0;

View File

@ -19,8 +19,8 @@ struct mf_scaledfont_s
struct mf_font_s font;
const struct mf_font_s *basefont;
uint8_t x_scale;
uint8_t y_scale;
gU8 x_scale;
gU8 y_scale;
};
MF_EXTERN void mf_scale_font(struct mf_scaledfont_s *newfont,