Repository navigation
fix(font): restore font query and shaping compatibility - #281
Conversation
There was a problem hiding this comment.
🟢 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_fontinfont.rsthat returns the GNU 9-slot vector (name, file, pixel size, max width, ascent, descent, space width, average width, capability) and preserves thefont-objectwrong-type error for invalid inputs. - Remove the incorrect
expect_fixnumvalidation onfont-shape-gstring's second argument, and re-point thequery-fontregistration 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.
Issue
query-fontis 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-gstringalso incorrectly requires its second argument to be an integer, while GNU callers pass optional values such as nil or symbols.Solution
query-fontfor font objects using the existing font-info and runtime font metric paths.font-objecttype errors for invalid inputs.font-shape-gstring's optional shaping argument.Verification
cargo test -p neovm-core --lib query_font_eval_returns_metrics_with_terminal_frame_selected -- --nocapturepasses.cargo test -p neovm-core --lib vm_font_stub_tail_uses_direct_dispatch -- --nocapturepasses.cargo check -p neovm-corepasses.cargo fmt --all -- --checkpasses.git diff --check upstream/main...HEADpasses.