虾兵虾酱 发表于 2023-11-15 17:55:26

求助!LVGL8.3 之 模拟器visual studio使用外部中文字体显示不了

代码:
    LV_FONT_DECLARE(lv_font_SourceHanSansSCVF_16);//引入字库
    lv_obj_t* zh_label = lv_label_create(lv_scr_act());//获取默认屏幕
    lv_obj_set_style_text_font(zh_label, &lv_font_SourceHanSansSCVF_16, LV_STATE_DEFAULT);// 设置风格的字体
   lv_label_set_text(zh_label, "你好,这是思源黑体!");//显示文字
    lv_obj_align(zh_label, LV_ALIGN_TOP_MID, 0, 0);

死在了第三行代码
模拟器报错:
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) {
    if( unicode_letter>__g_xbf_hd.max || unicode_letter<__g_xbf_hd.min ) {
      return NULL;
    }
    uint32_t unicode_offset = sizeof(x_header_t)+(unicode_letter-__g_xbf_hd.min)*4;
    uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4);
    if( p_pos != 0 ) {
      glyph_dsc_t * gdsc = (glyph_dsc_t*)__user_font_getdata(p_pos, sizeof(glyph_dsc_t));
      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   = __g_xbf_hd.bpp;
      return true;
    }
    return false;

报错的位置是生成的.c文件


虾兵虾酱 发表于 2023-11-15 17:59:53

错误提示是:
引发了异常: 读取访问权限冲突。
p_pos 是 nullptr。

阿里兄 发表于 2023-11-15 18:49:27

虾兵虾酱 发表于 2023-11-15 17:59
错误提示是:
引发了异常: 读取访问权限冲突。
p_pos 是 nullptr。

或是你这里换一个判断方法
if( p_pos!=NULL ) {
      glyph_dsc_t * gdsc = (glyph_dsc_t*)__user_font_getdata(p_pos, sizeof(glyph_dsc_t));
      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   = __g_xbf_hd.bpp;
      return true;
    }

虾兵虾酱 发表于 2023-11-15 19:49:50

本帖最后由 虾兵虾酱 于 2023-11-15 20:02 编辑

阿里兄 发表于 2023-11-15 18:49
或是你这里换一个判断方法
换了判断方法,可以编过。但是文字是白色的框,文字还是不显示!!!

虾兵虾酱 发表于 2023-11-15 20:29:41

选择第二种”XBF字体,内部大数组“,可以直接显示文字。 第三种带bin文件为啥不行,目前不知道:'(

阿里兄 发表于 2023-11-17 08:35:59

虾兵虾酱 发表于 2023-11-15 20:29
选择第二种”XBF字体,内部大数组“,可以直接显示文字。 第三种带bin文件为啥不行,目前不知道 ...

这很明显是你驱动没写好。

虾兵虾酱 发表于 2023-11-17 14:35:25

阿里兄 发表于 2023-11-17 08:35
这很明显是你驱动没写好。

弄好了,lvgl的文件系统没弄好
页: [1]
查看完整版本: 求助!LVGL8.3 之 模拟器visual studio使用外部中文字体显示不了