add a fallback font system to render CJK text in the \text command

This commit is contained in:
Nicolas Guillot
2025-10-01 14:11:00 +02:00
parent b67cc8fd38
commit 11f57f7c6e
6 changed files with 347 additions and 13 deletions

View File

@@ -438,8 +438,15 @@ public struct MTMathListBuilder {
} else {
atom = MTMathAtomFactory.atom(forCharacter: char)
if atom == nil {
// Not a recognized character
continue
// Not a recognized character in standard math mode
// In text mode (spacesAllowed && roman style), accept any Unicode character for fallback font support
// This enables Chinese, Japanese, Korean, emoji, etc. in \text{} commands
if spacesAllowed && currentFontStyle == .roman {
atom = MTMathAtom(type: .ordinary, value: String(char))
} else {
// In math mode or non-text commands, skip unrecognized characters
continue
}
}
}