Skip to content

feat: 延续 #95,按主字体适配希腊数学字形 - #96

Merged
SXP-Simon merged 1 commit into
mainfrom
feat/greek-handwriting-policy
Dec 1, 2026
Merged

SXP-Simon merged 1 commit into
mainfrom
feat/greek-handwriting-policy

Conversation

@SXP-Simon

@SXP-Simon SXP-Simon commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

问题与变更

延续 #95。九款内置字体里,同一个符号可能有三种情况:主字体自带合适的字形、缺少字形而借用其他字体,或者像随包李国夫手写体那样,自带的希腊字形明显偏印刷体。#95 为所有字体手绘 Ω 和 μ,改善了缺字时的表现,也覆盖了霞鹜文楷等字体已有的字形。

  • 让正文、公式和电路标签共用字形选择。优先采用主字体的可见字形,欧姆和微单位的两种 Unicode 写法允许在主字体内互补。主字体缺字时,沿用 fix: 手绘 Ω 与 μ 以去掉印刷体希腊字母 #95 的笔画采样和 Ω、μ 路径,按所选字体的笔宽、倾斜和字高补绘。
  • 适配 22 种字形及两个单位别名,覆盖项目 Rust 课程样例里的希腊字母,并分别处理 θ/ϑ、φ/ϕ、ε/ϵ、ρ/ϱ。不同的变量在手写时仍然可区分。
  • 只对核对过的随包李国夫字体文件使用笔绘例外。用字体文件指纹识别,同名的其他字体仍可使用自身字形。其余 Unicode 符号继续走现有回退逻辑。
  • 新生成的精调布局使用 Fine6。已有 Fine2–Fine5 精调键按对应历史版本重放。没有保存精调键的普通稿件再次生成时使用新策略。

验证

  • Windows,Rust 1.94.1。已通过 cargo fmt --all -- --check 和 cargo clippy --locked --workspace --all-targets -- -D warnings。
  • cargo test --locked --workspace 已通过,289 项通过,0 项失败,1 项按仓库设置忽略。
  • 回归测试按九款字体核对字形来源,在 18、36、72 三档字号检查可见墨迹、原生字形与四对变体,并覆盖同名字体文件。
  • 从 fix: 手绘 Ω 与 μ 以去掉印刷体希腊字母 #95 合并提交 1881df06 独立生成含局部精调的 kΩμF 页面。回归测试比对重开后的字框、基线与整页原始 RGBA,覆盖 μ 的移动、缩放、旋转与透明度调整。

引擎渲染对照

Windows 上用 #95 与本次引擎分别生成。每款字体的上行为 #95,下行为本次,输入、字号、种子与纸张设置相同。云烟体和李国夫的单位一列保留原来的笔形,霞鹜文楷的单位恢复为字体自带字形。点开原图可逐个查看符号。

九款内置字体的五组公式,分别展示 #95 与本次的真实渲染

检查项

  • 此改动只影响渲染结果,客户端没有新增文案。
  • 用户可见改动已记入 CHANGELOG.md 的「未发布」。

背景:#95 手绘了 Ω 与 μ,课程与电路公式中的其他希腊字形仍可能借用印刷体。

解决手段:统一主字体、单位别名和采样笔绘的选择,为课程样例和成对变体补绘缺字,按精调键重放旧布局。

收益:已有手写字形得到保留,缺字公式的笔迹更一致,旧稿的字框与局部调整可以重放。
@sourcery-ai

sourcery-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

新增希腊字形来源选择与笔绘路径:优先使用主字体可见字形及单位别名,按字体指纹对李国夫字形作例外处理,并为缺字补绘常用希腊字母及变体。

  • crates/handwriting-core/src/render/glyph.rs L166-187 (+5 small edits)
  • crates/handwriting-core/src/render/glyph/pen.rs L404-411 (+5 small edits)
  • crates/handwriting-core/src/render/glyph/pen/greek.rs L1-382
  • crates/handwriting-core/src/render/glyph/pen/sample.rs L47 (removed lines)

引入 Fine6 作为新布局版本,并由渲染器按文档版本配置字形策略,使 Fine2–Fine5 的精调稿继续按历史字形规则重放。

  • crates/handwriting-core/src/fine_edit.rs L163-168 (+7 small edits)
  • crates/handwriting-core/src/render.rs L466, L765

Documentation

更新变更日志和字形画廊示例,说明新字形策略并展示新增希腊字母、变体及内置字体。

  • CHANGELOG.md L9
  • crates/handwriting-core/examples/math_strokes_gallery.rs L9, L15-19

Tests

覆盖 Fine5 精调稿的像素级重放,并检查 Fine4 精调稿仍保留原生字体希腊字形几何。

  • crates/handwriting-core/tests/generation_pipeline.rs L811-866, L882, L905-906

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@SXP-Simon
SXP-Simon marked this pull request as ready for review December 1, 2026 21:15
@sourcery-ai

sourcery-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Sorry @SXP-Simon, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 12 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@SXP-Simon SXP-Simon added the run-ci 手动批准当前 PR 版本的相关 CI 检查 label Dec 1, 2026
@SXP-Simon
SXP-Simon merged commit cc862e1 into main Dec 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci 手动批准当前 PR 版本的相关 CI 检查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant