Skip to content

[206_19]: Fix Latin Modern Math cannot input "h" in math mode#2865

Merged
da-liii merged 1 commit intoMoganLab:mainfrom
divyansharma001:da/206_19/fix_math_italic_h
Feb 26, 2026
Merged

[206_19]: Fix Latin Modern Math cannot input "h" in math mode#2865
da-liii merged 1 commit intoMoganLab:mainfrom
divyansharma001:da/206_19/fix_math_italic_h

Conversation

@divyansharma001
Copy link
Copy Markdown
Contributor

Fixes #2742

Problem

When the math mode font is set to Latin Modern Math, typing "h" in math mode produces no output.

Root Cause

In smart_font_rep::advance(), lowercase letters are mapped to Unicode Mathematical Italic codepoints via a simple offset: 0x1D44E + (s[0] - 'a'). For 'h', this computes U+1D455 — but U+1D455 is intentionally unassigned in the Unicode standard. The correct math italic small h is at U+210E (PLANCK CONSTANT) in the Letterlike Symbols block. Since Latin Modern Math (and all conforming OpenType Math fonts) has no glyph at U+1D455, the character fails to render.

Fix

  • Add a special case in smart_font_rep::advance() to map 'h' → U+210E instead of the unassigned U+1D455
  • Add the corresponding reverse mapping U+210E → 'h' in init_unicode_substitution() for consistency

How to Test

  1. Set the math mode font to Latin Modern Math
  2. Enter math mode and type "h"
  3. Confirm "h" displays correctly as math italic h

Developer document: devel/206_19.md

Map lowercase 'h' to U+210E (PLANCK CONSTANT) instead of the unassigned
U+1D455 in smart_font_rep::advance(). Add corresponding reverse mapping
in init_unicode_substitution().

Fixes MoganLab#2742
Copilot AI review requested due to automatic review settings February 25, 2026 18:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes math-mode input/rendering of lowercase h when using OpenType math fonts like Latin Modern Math by mapping the character to the correct Unicode code point (U+210E) and ensuring reverse substitution remains consistent.

Changes:

  • Add a Unicode substitution mapping for U+210E (ℎ)'h' under italic-math.
  • Special-case smart_font_rep::advance() to map math italic 'h' to U+210E instead of the unassigned U+1D455.
  • Add a developer note documenting the issue, root cause, and manual test steps.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Graphics/Fonts/smart_font.cpp Implements the forward mapping (h → U+210E) and adds reverse substitution for U+210E in the Unicode substitution table.
devel/206_19.md Documents the bug, rationale (U+1D455 unassigned), and verification steps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@da-liii
Copy link
Copy Markdown
Contributor

da-liii commented Feb 26, 2026

Here is the behavior after the fix:
image

Copy link
Copy Markdown
Contributor

@da-liii da-liii left a comment

Choose a reason for hiding this comment

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

LGTM

@da-liii da-liii merged commit 505e38d into MoganLab:main Feb 26, 2026
7 of 8 checks 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.

数学字体 Latin Modern Math 无法输入"h"

4 participants