Skip to content

Add bold symbol support#159

Open
AshtonSBradley wants to merge 1 commit into
Kolaru:masterfrom
AshtonSBradley:asb/bold-symbol-greek
Open

Add bold symbol support#159
AshtonSBradley wants to merge 1 commit into
Kolaru:masterfrom
AshtonSBradley:asb/bold-symbol-greek

Conversation

@AshtonSBradley
Copy link
Copy Markdown
Contributor

Summary

  • Fixes Unexpected error while parsing \boldsymbol #107 by adding parser and layout support for \boldsymbol{...}.
  • Adds \bm{...} as an alias for the same bold-symbol layout path.
  • Partially addresses Bold greek letters #124 by letting \mathbf{...} and \boldsymbol{...} use bold font glyphs for any special math symbol whose selected bold font provides a glyph.
  • Adds a generated bold-symbol reference group derived from the font family’s special-character table.

Explanation

Previously, \boldsymbol{\nabla} failed at parse time because \boldsymbol was not registered as a command. This PR registers \boldsymbol and \bm as one-argument commands and lays them out by reusing the existing :bf font modifier path.

The font lookup change keeps the existing NewComputerModern special glyph table for unmodified math symbols, preserving current layout behavior. When a font modifier such as \mathbf or \boldsymbol is active, MathTeXEngine now tries the requested modified font first and falls back to the special glyph table only if that font does not contain the character.

This is a general font-selection rule, not a hard-coded list of supported symbols. The regression test checks every NewComputerModern special math symbol that actually has a glyph in the selected bold font, through both the \mathbf/:bf path and the \boldsymbol path. The reference examples are generated from FontFamily().special_chars using the same glyph-availability check.

For NewComputerModern this means bold Greek letters such as ε, ϵ, α, and ω use NewCM10-Bold. The bundled bold font does not contain , so \boldsymbol{\nabla} now parses and renders, but falls back to the regular math glyph for nabla.

Tests

  • julia --project=@runic -m Runic --check src/parser/commands_registration.jl src/engine/fonts.jl src/engine/layout.jl src/engine/texelements.jl test/parser.jl test/layout.jl reference/references.jl reference/data/bold_symbols.jl
    • Passed after applying Runic to the changed Julia files.
  • git diff --check
    • Passed.
  • julia --project=. test/runtests.jl
    • Passed: TeXExpr 1, Parser 130, Fonts 5, Layout 289, Generate elements 4.
  • Rendered the generated bold-symbol reference group locally:
    • length(BOLD_SYMBOLS) = 10
    • no failed expressions

Notes

  • No new dependencies are added.
  • No public API is exported or removed.
  • Runic reformatted touched files, including some pre-existing formatting in test/parser.jl.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 60.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.13%. Comparing base (efdbaab) to head (fb7420f).
⚠️ Report is 37 commits behind head on master.

Files with missing lines Patch % Lines
src/engine/fonts.jl 40.00% 3 Missing ⚠️
src/engine/texelements.jl 50.00% 3 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #159      +/-   ##
==========================================
+ Coverage   79.93%   84.13%   +4.19%     
==========================================
  Files          10       10              
  Lines         658      914     +256     
==========================================
+ Hits          526      769     +243     
- Misses        132      145      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Unexpected error while parsing \boldsymbol

2 participants