Skip to content

fix(font): restore font query and shaping compatibility - #281

Merged
eval-exec merged 1 commit into
eval-exec:mainfrom
kiennq:pr/font-query-shaping-compat
Aug 26, 2026
Merged

eval-exec merged 1 commit into
eval-exec:mainfrom
kiennq:pr/font-query-shaping-compat

Conversation

@kiennq

@kiennq kiennq commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Issue

query-font is currently a placeholder that always returns nil, so Lisp callers cannot retrieve the font name, file, metrics, or OpenType capability from a resolved font object. font-shape-gstring also incorrectly requires its second argument to be an integer, while GNU callers pass optional values such as nil or symbols.

Solution

  • Implement query-font for font objects using the existing font-info and runtime font metric paths.
  • Return GNU-compatible name, file, pixel size, width, ascent, descent, spacing, and capability slots.
  • Preserve GNU-compatible font-object type errors for invalid inputs.
  • Stop imposing an incorrect fixnum requirement on font-shape-gstring's optional shaping argument.
  • Add focused font query and bytecode dispatch regressions.

Verification

  • cargo test -p neovm-core --lib query_font_eval_returns_metrics_with_terminal_frame_selected -- --nocapture passes.
  • cargo test -p neovm-core --lib vm_font_stub_tail_uses_direct_dispatch -- --nocapture passes.
  • cargo check -p neovm-core passes.
  • cargo fmt --all -- --check passes.
  • git diff --check upstream/main...HEAD passes.
  • Windows validation temporarily applied the separate Unix-signal gating from fix(windows): gate Unix signal handlers #276; that change is not included in this PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The new query-font mapping was verified against the documented GNU contract and helper layouts, the font-shape-gstring fix is correct, and the changes are well-covered by updated tests with no issues found.

Pull request overview

This PR restores GNU-compatible behavior for two font primitives in neovm-core. Previously query-font was a placeholder that always returned nil, preventing Lisp callers from retrieving a resolved font's name, file, metrics, and OpenType capabilities. It also corrects font-shape-gstring, which wrongly rejected non-integer values for its optional shaping/direction argument that GNU callers legitimately pass as nil or symbols. The real query-font now reuses the existing font-info entity-probe and runtime-font metric paths, and is relocated from the pure-dispatch symbols module to the context-aware font module.

Changes:

  • Implement a real builtin_query_font in font.rs that returns the GNU 9-slot vector (name, file, pixel size, max width, ascent, descent, space width, average width, capability) and preserves the font-object wrong-type error for invalid inputs.
  • Remove the incorrect expect_fixnum validation on font-shape-gstring's second argument, and re-point the query-font registration to the new implementation.
  • Add focused regressions (query-font metrics on a terminal frame, plus the bytecode direct-dispatch update) and drop the now-obsolete pure-dispatch placeholder test.
File summaries
File Description
neovm-core/src/emacs_core/font.rs Adds builtin_query_font, mapping the internal font-info vector to GNU's query-font slots with correct type/error handling.
neovm-core/src/emacs_core/builtins/symbols.rs Removes the old placeholder builtin_query_font that always returned nil.
neovm-core/src/emacs_core/builtins/mod.rs Re-points the query-font subr registration to the new context-aware implementation.
neovm-core/src/emacs_core/builtins/stubs.rs Drops the incorrect fixnum requirement on font-shape-gstring's optional argument.
neovm-core/src/emacs_core/font_test.rs Adds a query-font regression covering metrics extraction and the wrong-type error path.
neovm-core/src/emacs_core/bytecode/vm_test.rs Updates the direct-dispatch test to call font-shape-gstring with nil.
neovm-core/src/emacs_core/builtins/tests.rs Removes the obsolete pure-dispatch query-font placeholder assertion and renames the test.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@eval-exec
eval-exec merged commit cb4f826 into eval-exec:main Aug 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants