里飞网

 找回密码
 立即注册
查看: 10674|回复: 42
打印 上一主题 下一主题

LvglFontTool字体工具V0.5测试版

[复制链接]

0

主题

2

帖子

27

积分

新手上路

Rank: 1

积分
27
楼主
发表于 2022-7-5 15:13:34 | 显示全部楼层
由于LVGL8.1以后字体增加了:uint8_t is_placeholder: 1; /** Glyph is missing. But placeholder will still be displayed */

/** Describes the properties of a glyph.*/
typedef struct {
    const struct _lv_font_t *
        resolved_font; /**< Pointer to a font where the gylph was actually found after handling fallbacks*/
    uint16_t adv_w; /**< The glyph needs this space. Draw the next glyph after this width.*/
    uint16_t box_w; /**< Width of the glyph's bounding box*/
    uint16_t box_h; /**< Height of the glyph's bounding box*/
    int16_t ofs_x;  /**< x offset of the bounding box*/
    int16_t ofs_y;  /**< y offset of the bounding box*/
    uint8_t bpp: 4;  /**< Bit-per-pixel: 1, 2, 4, 8*/
    uint8_t is_placeholder: 1; /** Glyph is missing. But placeholder will still be displayed */
} lv_font_glyph_dsc_t;

会时不时引起这个错误:[Error] (0.291, +0)      lv_font_get_glyph_bitmap: Asserted at expression: font_p != NULL (NULL pointer)        (in lv_font.c line #51)

解决办法字体取模后要增加:dsc_out->is_placeholder = false;

static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) {
    lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;

    if( unicode_letter<fdsc->cmaps[0].range_start || unicode_letter>fdsc->cmaps[0].range_length ) return false;

    int i;
    if( unicode_letter==fdsc->cache->last_letter ){
        i = fdsc->cache->last_glyph_id;
    }
    else{
        i = binsearch(fdsc->cmaps[0].unicode_list, fdsc->cmaps[0].list_length, unicode_letter);
    }
    if( i != -1 ) {
        const lv_font_fmt_txt_glyph_dsc_t * gdsc = &fdsc->glyph_dsc[i];
        fdsc->cache->last_glyph_id = i;
        fdsc->cache->last_letter = unicode_letter;
        dsc_out->adv_w = gdsc->adv_w;
        dsc_out->box_h = gdsc->box_h;
        dsc_out->box_w = gdsc->box_w;
        dsc_out->ofs_x = gdsc->ofs_x;
        dsc_out->ofs_y = gdsc->ofs_y;
        dsc_out->bpp   = fdsc->bpp;
        dsc_out->is_placeholder = false;//add202207
        return true;
    }
    return false;
}
回复

使用道具 举报

0

主题

2

帖子

27

积分

新手上路

Rank: 1

积分
27
沙发
发表于 2022-7-5 17:20:21 | 显示全部楼层
阿里兄 发表于 2022-7-5 16:02
感谢老哥,下次有机会加上区分;这字体结构又修改了,无语了。

不是系统自带的字体,增加了字体:思源黑体。坑锯齿 4,size: 12 ,版本V8.0以上,内部字体。

上位机LvglFontTool字体工具V0.5测试版上面显示框显示是正常的,但是用在下面LVGL显示出来好像变瘦了。

用LvglFontTool字体工具V0.3导出来的文件显示是正常。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|里飞网  

GMT+8, 2024-5-3 01:23 , Processed in 0.084485 second(s), 5 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc. Template By 【未来科技】【 www.wekei.cn 】

快速回复 返回顶部 返回列表