add get_serial_cache_font_width to calc the whole line ser_cache width

This commit is contained in:
cuu 2022-03-08 00:55:03 -06:00
parent 8eff139781
commit 3237703ec3
3 changed files with 28 additions and 3 deletions

View File

@ -711,7 +711,15 @@ void parse_serial_stream(CONFIG*cfg,uint8_t input_ch){
}
//read utf8 codename
//
a = (ser_cache.idx+1)*current_font.width+(ser_cache.idx)*0+ g_config.margin.width;
if(cfg->font->mode == FONT_MODE_1) {
a = get_serial_cache_font_width(&g_config);
a+= (ser_cache.idx)*0+ g_config.margin.width;
}else {
a = (ser_cache.idx+1)*current_font.width+(ser_cache.idx)*0+ g_config.margin.width;
}
if( a >= MAX_DOTS)//got enough points to print
{
if(cfg->font->mode == FONT_MODE_1){

View File

@ -422,6 +422,24 @@ int glob_file(char*av) {
}
#endif
uint16_t get_serial_cache_font_width(CONFIG*cfg) {
int i;
uint8_t *ch;
uint32_t codename;
int w;
w = 0;
i = 0;
while( i <ser_cache.idx) {
ch = (uint8_t*)&ser_cache.data[i];
codename = utf8_to_utf32(ch);
FT_UInt gi = FT_Get_Char_Index ( cfg->face, codename);
FT_Load_Glyph ( cfg->face, gi, FT_LOAD_NO_BITMAP);
w += cfg->face->glyph->metrics.horiAdvance / 64;
i++;
}
return w+cfg->font->width;
}
//print with freetype font dots glyph
uint8_t print_lines_ft(CONFIG*cfg) {
@ -550,7 +568,6 @@ uint8_t print_lines_ft(CONFIG*cfg) {
break;
}
}
rv = IsPaper();
if( rv == IS_PAPER) {

View File

@ -29,7 +29,7 @@ void print_dots_8bit(CONFIG*cfg,uint8_t *Array, uint8_t characters,uint8_t feed_
uint16_t read_adc(char*);
uint16_t temperature();
int glob_file(char*);
uint16_t get_serial_cache_font_width(CONFIG*);
uint8_t print_lines_ft(CONFIG*);
uint8_t print_lines8(CONFIG*);