Repository navigation
fix(measure-text): apply theme font in compose and lazy-register 851tegakizatsu - #210
Conversation
Summary of ChangesHello @xxMudCloudxx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求旨在解决文本渲染和测量中的字体一致性问题。它确保了在SVG生成过程中,主题中定义的自定义字体能够被正确应用于文本测量,从而避免了因字体不匹配导致的测量偏差。同时,为了支持在服务器端渲染(SSR)环境下对特定外部字体的准确测量,引入了一种按需加载和注册字体字形数据的机制,提升了系统的健壮性和准确性。 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request introduces improvements to text measurement by correctly applying theme fonts in the Compose stage and implementing lazy registration for special fonts like '851tegakizatsu' in SSR environments. The changes enhance rendering accuracy and robustness, especially in non-browser contexts. The unit tests have been updated to cover these new functionalities, ensuring the measury dependency's registerFont method is triggered as expected.
|
ai幻觉有点严重,这12条没有什么实际的建议,其中5-12全部是正面评价("is good"、"is correct"、"is excellent"),不是问题。 |
78836df to
9d36ff3
Compare
|
测试未通过的原因是: 这次我把 因此 |
|
针对上面测试未通过的问题,这里存在一个策略权衡:
请问哪种策略更加符合预期? @Aarebecca |
|
奇怪我再查一下为什么懒注册了 |
非嵌入模式下,SSR 渲染的 SVG ,字体是通过 需要确认下你的渲染环境是否支持 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #210 +/- ##
==========================================
+ Coverage 46.14% 46.21% +0.07%
==========================================
Files 341 341
Lines 27930 27964 +34
Branches 2282 2289 +7
==========================================
+ Hits 12887 12923 +36
+ Misses 15031 15029 -2
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@xxMudCloudxx 建议 rebase 一下 main 分支代码,另外有测试用例需要更新 SVG |
@Aarebecca 我是应该直接rebase main分支后push -f一下,还是直接把你刚刚那推送的3个新commit拉下来。测试用例的话,这次修改只涉及到手写体即ssr的测试11,我前面更新过svg了 |
直接 rebase 后 force push 吧~ |
17acc97 to
29cfd5d
Compare
|
ok了 |
|
#204 那边调整���mearsure-text的FONT_EXTEND_FACTOR,所以pr 204 merge后这边可能会冲突,到时候我再重新更新下 ssr 第11测试的svg |
29cfd5d to
45364f4
Compare



背景 (Background)
在处理文本渲染和尺寸测量的过程中,当前逻辑未能在组合(Compose)阶段正确应用和传递主题配置中的自定义字体参数(如
themeConfig.base.text['font-family']),导致渲染过程中基于默认字体的宽度测量出现偏差。另外,针对额外引用的特殊字体(如851tegakizatsu),在 SSR 等非浏览器环境中需要其字形数据进行降级测量,但在需要时未能自动注册。改动详情 (Change Details)
renderSVG阶段之前,依据themeConfig读取相应的字体配置并使用setDefaultFont变更为当前的默认测量字体,等渲染与测量结束后,再撤销为原默认字体。确保了渲染流与测算端字体指标严格一致。ensureMeasuryFont。在每次执行文本测量前,提取实际所用fontFamily(例如过滤 fallback 序列中的主字体),判断其如果在预定义列表EXTRA_MEASURY_FONTS中且未缓存过,则直接将其字形数据注入到measury,保证准确测量。measury依赖方法(registerFont)可被正常触发。close issure: #209