Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

lvfontio doesn't consider ascent/descent

未关闭
#10,850 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
c
领域
embedded-iot

调研方向

Start with the cited header-reading code in shared-module/lvfontio/OnDiskFont.c (lines 110–114) and the dimensions function (lines 568–570), then compare the font metrics described for the 1bpp and higher-bpp files. The issue does not name a test; reproduce the reported clipping and check how candidate sizing affects terminal row spacing. Done means higher-bpp descenders render without clipping while preserving the desired terminal sizing and alignment.

由索引模型根据 Issue 内容生成。

描述

bug displayio

Currently the lvfontio module reads the font_size and ascent out of the font file header. https://github.com/adafruit/circuitpython/blob/fd4226bb6e15884e9fa7f7014d54a4bfaf192db1/shared-module/lvfontio/OnDiskFont.c#L110-L114

and it uses the font_size as the height returned by common_hal_lvfontio_ondiskfont_get_dimensions https://github.com/adafruit/circuitpython/blob/fd4226bb6e15884e9fa7f7014d54a4bfaf192db1/shared-module/lvfontio/OnDiskFont.c#L568-L570

But it seems that font_size may not fully encompass all of the vertical pixels the font requires. I have noticed that >1bpp versions of the same font have a higher ascent value but the same font_size

Loaded 4bpp font from fonts/unifont-16.0.02-en_US_4bb.lvfontbin
Successfully loaded LVGL font
Font metrics:
  Ascent: 15
  Descent: -4
  font_size: 16
  Bounding box: width=0, height=16, x_offset=0, y_offset=-4

Loaded 1bpp font from fonts/unifont-16.0.02-en_US.lvfontbin
Successfully loaded LVGL font
Font metrics:
  Ascent: 14
  Descent: -4
  font_size: 16
  Bounding box: width=0, height=16, x_offset=0, y_offset=-4

This seems to be the root cause of the descenders or bottom row(s) of pixels getting cut off when attempting to set the terminal to use a font that is >1bpp

Default font descenders visible 'y' and 'g' characters:

Image

2bpp version of same font descenders clipped:

Image

adafruit_bitmap_font does not seem to have the same issue, using that and BitmapLabel the descenders are rendered in full.

Codex suggested this patch to resolve it by reading the descent value from the header and using it + ascent to calculate the full size.
lvfontio-descent-header.patch

That does work to stop the bottom from getting clipped, but it means that the tile size for the Terminal is bigger, more space in between rows, and doesn't evenly align or evenly divide into the display size.

Image

In practice it seems like for this font (unifont v16.0.02) that the descent doesn't actually use the full ascent + descent range available at least on standard ASCII glyphs. The 'y' and 'g' each only seem to be missing 1 pixel row which to me looks like it matches the 1px difference in ascent value between the two fonts. When using the ascent + decent calculation it will end up at 18 or 19px for height instead of the 16 that we have now, or the 17 that seem like it would fit everything.

I'm interested in thoughts on whether this is something we want to try to resolve, and if so how best to do it in a way that ideally doesn't change the current default fonts terminal size, but does still allow custom >1bpp fonts to render without clipping.

主要语言
C
星标
4.6k
派生
1.4k
平均合并
1 天 1 小时
30 天内合并 PR
161

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

adafruit/circuitpython 的其他 Issue

查看 adafruit/circuitpython 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。