Skip to content

Commit

Permalink
add U+FE00, U+FE01 variant selectors for respectively caligraphic and…
Browse files Browse the repository at this point in the history
… script styles
  • Loading branch information
xworld21 committed Oct 22, 2023
1 parent 37248ca commit b51b78a
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 20 deletions.
3 changes: 3 additions & 0 deletions lib/LaTeXML/Post/MathML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ my %default_token_content = (
# Remaps some mathvariants to a simpler subset of Unicode
my %plane1hackable = ( # CONSTANT
script => 'script',
caligraphic => 'caligraphic',
'bold-script' => 'script',
fraktur => 'fraktur',
'bold-fraktur' => 'fraktur',
Expand Down Expand Up @@ -721,6 +722,8 @@ sub stylizeContent {
# Use class (css) to patchup some weak translations
if (!$font) { }
elsif ($font =~ /caligraphic/) {
# caligraphic is not a true mathvariant (see Unicode.pm), reset to script
$variant =~ s/caligraphic/script/;
# Note that this is unlikely to have effect when plane1 chars are used!
$class = ($class ? $class . ' ' : '') . 'ltx_font_mathcaligraphic'; }
elsif ($font =~ /script/) {
Expand Down
98 changes: 79 additions & 19 deletions lib/LaTeXML/Util/Unicode.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,69 @@ my %unicode_map = ( # CONSTANT
'sans-serif-italic' => { makePlane1Map(0x1D608, undef, undef, undef) },
'sans-serif-bold-italic' => { makePlane1Map(0x1D63C, 0x1D790, 0x1D7AA, undef) },
'monospace' => { makePlane1Map(0x1D670, undef, undef, 0x1D7F6) },
'script' => { makePlane1Map(0x1D49C, undef, undef, undef),
B => "\x{212C}", E => "\x{2130}", F => "\x{2131}", H => "\x{210B}", I => "\x{2110}",
L => "\x{2112}", M => "\x{2133}", R => "\x{211B}",
e => "\x{212F}", g => "\x{210A}", o => "\x{2134}" },
# since Unicode 14, capital script characters admit two variant selectors
# - U+FE00 for chancery style (caligraphic)
# - U+FE01 for roundhand style (script)
'script' => { makePlane1Map(0x1D49C, undef, undef, undef),
A => "\x{1D49C}\x{FE01}",
B => "\x{212C}\x{FE01}",
C => "\x{1D49E}\x{FE01}",
D => "\x{1D49F}\x{FE01}",
E => "\x{2130}\x{FE01}",
F => "\x{2131}\x{FE01}",
G => "\x{1D4A2}\x{FE01}",
H => "\x{210B}\x{FE01}",
I => "\x{2110}\x{FE01}",
J => "\x{1D4A5}\x{FE01}",
K => "\x{1D4A6}\x{FE01}",
L => "\x{2112}\x{FE01}",
M => "\x{2133}\x{FE01}",
N => "\x{1D4A9}\x{FE01}",
O => "\x{1D4AA}\x{FE01}",
P => "\x{1D4AB}\x{FE01}",
Q => "\x{1D4AC}\x{FE01}",
R => "\x{211B}\x{FE01}",
S => "\x{1D4AE}\x{FE01}",
T => "\x{1D4AF}\x{FE01}",
U => "\x{1D4B0}\x{FE01}",
V => "\x{1D4B1}\x{FE01}",
W => "\x{1D4B2}\x{FE01}",
X => "\x{1D4B3}\x{FE01}",
Y => "\x{1D4B4}\x{FE01}",
Z => "\x{1D4B5}\x{FE01}",
e => "\x{212F}",
g => "\x{210A}",
o => "\x{2134}" },
'caligraphic' => { makePlane1Map(0x1D49C, undef, undef, undef),
A => "\x{1D49C}\x{FE00}",
B => "\x{212C}\x{FE00}",
C => "\x{1D49E}\x{FE00}",
D => "\x{1D49F}\x{FE00}",
E => "\x{2130}\x{FE00}",
F => "\x{2131}\x{FE00}",
G => "\x{1D4A2}\x{FE00}",
H => "\x{210B}\x{FE00}",
I => "\x{2110}\x{FE00}",
J => "\x{1D4A5}\x{FE00}",
K => "\x{1D4A6}\x{FE00}",
L => "\x{2112}\x{FE00}",
M => "\x{2133}\x{FE00}",
N => "\x{1D4A9}\x{FE00}",
O => "\x{1D4AA}\x{FE00}",
P => "\x{1D4AB}\x{FE00}",
Q => "\x{1D4AC}\x{FE00}",
R => "\x{211B}\x{FE00}",
S => "\x{1D4AE}\x{FE00}",
T => "\x{1D4AF}\x{FE00}",
U => "\x{1D4B0}\x{FE00}",
V => "\x{1D4B1}\x{FE00}",
W => "\x{1D4B2}\x{FE00}",
X => "\x{1D4B3}\x{FE00}",
Y => "\x{1D4B4}\x{FE00}",
Z => "\x{1D4B5}\x{FE00}",
e => "\x{212F}",
g => "\x{210A}",
o => "\x{2134}" },
'bold-script' => { makePlane1Map(0x1D4D0, undef, undef, undef) },
'fraktur' => { makePlane1Map(0x1D504, undef, undef, undef),
C => "\x{212D}", H => "\x{210C}", I => "\x{2111}", R => "\x{211C}", Z => "\x{2128}" },
Expand Down Expand Up @@ -217,25 +276,25 @@ my %mathvariants = ( # CONSTANT
'bold italic' => 'bold-italic',
'doublestruck' => 'double-struck',
'blackboard' => 'double-struck',
'blackboard bold' => 'double-struck', # all collapse
'blackboard upright' => 'double-struck', # all collapse
'blackboard bold upright' => 'double-struck', # all collapse
'blackboard bold' => 'double-struck', # all collapse
'blackboard upright' => 'double-struck', # all collapse
'blackboard bold upright' => 'double-struck', # all collapse
'fraktur' => 'fraktur',
'fraktur italic' => 'fraktur', # all collapse
'fraktur italic' => 'fraktur', # all collapse
'fraktur bold' => 'bold-fraktur',
'script' => 'script',
'script italic' => 'script', # all collapse
'script italic' => 'script', # all collapse
'script bold' => 'bold-script',
'caligraphic' => 'script', # NOTE: TeX caligraphic is NOT script!
'caligraphic bold' => 'bold-script', # collapse
'sansserif' => 'sans-serif',
'sansserif bold' => 'bold-sans-serif',
'sansserif italic' => 'sans-serif-italic',
'sansserif bold italic' => 'sans-serif-bold-italic',
'typewriter' => 'monospace',
'typewriter bold' => 'monospace',
'typewriter italic' => 'monospace',
'typewriter bold italic' => 'monospace',
'caligraphic' => 'caligraphic', # not a true mathvariant, supported via Unicode variation sequences
'caligraphic bold' => 'bold-script', # collapse (NOTE: TeX caligraphic is NOT script!)
'sansserif' => 'sans-serif',
'sansserif bold' => 'bold-sans-serif',
'sansserif italic' => 'sans-serif-italic',
'sansserif bold italic' => 'sans-serif-bold-italic',
'typewriter' => 'monospace',
'typewriter bold' => 'monospace',
'typewriter italic' => 'monospace',
'typewriter bold italic' => 'monospace',
);

# The font differences (from the containing context) have been deciphered
Expand Down Expand Up @@ -310,6 +369,7 @@ C<sans-serif-italic>,
C<sans-serif-bold-italic>,
C<monospace>,
C<script>,
C<caligraphic>,
C<bold-script>,
C<fraktur>,
C<bold-fraktur>,
Expand Down
2 changes: 1 addition & 1 deletion t/daemon/formats/mixedmath.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

<tbody><tr class="ltx_equation ltx_eqn_row ltx_align_baseline">
<td class="ltx_eqn_cell ltx_eqn_center_padleft"/>
<td class="ltx_eqn_cell ltx_align_center"><math xmlns="http://www.w3.org/1998/Math/MathML" id="m8" class="ltx_Math" alttext="\left\langle\Psi\middle|\mathcal{H}\middle|\Phi\right\rangle+\defint{a}{b}{F(x%&#10;)}{x}" display="block"><semantics id="m8a"><mrow id="m8.16" xref="m8.16.cmml"><mrow id="m8.9" xref="m8.9.cmml"><mo id="m8.8" xref="m8.8.cmml">⟨</mo><mi mathvariant="normal" id="m8.5" xref="m8.5.cmml">Ψ</mi><mo id="m8.8a" xref="m8.8.cmml">|</mo><mi class="ltx_font_mathcaligraphic" id="m8.6" xref="m8.6.cmml">ℋ</mi><mo id="m8.8b" xref="m8.8.cmml">|</mo><mi mathvariant="normal" id="m8.7" xref="m8.7.cmml">Φ</mi><mo id="m8.8c" xref="m8.8.cmml">⟩</mo></mrow><mo rspace="0.055em" id="m8.10" xref="m8.10.cmml">+</mo><mrow id="m8.15" xref="m8.15.cmml"><msubsup id="m8.12" xref="m8.15.cmml"><mo id="m8.11" xref="m8.11.cmml">∫</mo><mi id="m8.1" xref="m8.1.cmml">a</mi><mi id="m8.2" xref="m8.2.cmml">b</mi></msubsup><mrow id="m8.14" xref="m8.15.cmml"><mrow id="m8.3b" xref="m8.3.cmml"><mi id="m8.3.1" xref="m8.3.1.cmml">F</mi><mo id="m8.3c" xref="m8.3.cmml">⁡</mo><mrow id="m8.3.3" xref="m8.3.cmml"><mo stretchy="false" id="m8.3" xref="m8.3.cmml">(</mo><mi id="m8.3.2" xref="m8.3.2.cmml">x</mi><mo stretchy="false" id="m8.3a" xref="m8.3.cmml">)</mo></mrow></mrow><mo lspace="0em" id="m8.11a" xref="m8.11.cmml">⁢</mo><mrow id="m8.13" xref="m8.15.cmml"><mo rspace="0em" id="m8.11b" xref="m8.11.cmml">𝑑</mo><mi id="m8.4" xref="m8.4.cmml">x</mi></mrow></mrow></mrow></mrow><annotation-xml encoding="MathML-Content" id="m8b"><apply id="m8.16.cmml" xref="m8.16"><plus id="m8.10.cmml" xref="m8.10"/><apply id="m8.9.cmml" xref="m8.9"><csymbol cd="latexml" id="m8.8.cmml" xref="m8.8">quantum-operator-product</csymbol><ci id="m8.5.cmml" xref="m8.5">Ψ</ci><ci id="m8.6.cmml" xref="m8.6">ℋ</ci><ci id="m8.7.cmml" xref="m8.7">Φ</ci></apply><apply id="m8.15.cmml" xref="m8.15"><int id="m8.11.cmml" xref="m8.11"/><bvar id="m8.15a.cmml" xref="m8.15"><ci id="m8.4.cmml" xref="m8.4">𝑥</ci></bvar><lowlimit id="m8.15b.cmml" xref="m8.15"><ci id="m8.1.cmml" xref="m8.1">𝑎</ci></lowlimit><uplimit id="m8.15c.cmml" xref="m8.15"><ci id="m8.2.cmml" xref="m8.2">𝑏</ci></uplimit><apply id="m8.3.cmml" xref="m8.3b"><ci id="m8.3.1.cmml" xref="m8.3.1">𝐹</ci><ci id="m8.3.2.cmml" xref="m8.3.2">𝑥</ci></apply></apply></apply></annotation-xml></semantics></math></td>
<td class="ltx_eqn_cell ltx_align_center"><math xmlns="http://www.w3.org/1998/Math/MathML" id="m8" class="ltx_Math" alttext="\left\langle\Psi\middle|\mathcal{H}\middle|\Phi\right\rangle+\defint{a}{b}{F(x%&#10;)}{x}" display="block"><semantics id="m8a"><mrow id="m8.16" xref="m8.16.cmml"><mrow id="m8.9" xref="m8.9.cmml"><mo id="m8.8" xref="m8.8.cmml">⟨</mo><mi mathvariant="normal" id="m8.5" xref="m8.5.cmml">Ψ</mi><mo id="m8.8a" xref="m8.8.cmml">|</mo><mi class="ltx_font_mathcaligraphic" id="m8.6" xref="m8.6.cmml">ℋ︀</mi><mo id="m8.8b" xref="m8.8.cmml">|</mo><mi mathvariant="normal" id="m8.7" xref="m8.7.cmml">Φ</mi><mo id="m8.8c" xref="m8.8.cmml">⟩</mo></mrow><mo rspace="0.055em" id="m8.10" xref="m8.10.cmml">+</mo><mrow id="m8.15" xref="m8.15.cmml"><msubsup id="m8.12" xref="m8.15.cmml"><mo id="m8.11" xref="m8.11.cmml">∫</mo><mi id="m8.1" xref="m8.1.cmml">a</mi><mi id="m8.2" xref="m8.2.cmml">b</mi></msubsup><mrow id="m8.14" xref="m8.15.cmml"><mrow id="m8.3b" xref="m8.3.cmml"><mi id="m8.3.1" xref="m8.3.1.cmml">F</mi><mo id="m8.3c" xref="m8.3.cmml">⁡</mo><mrow id="m8.3.3" xref="m8.3.cmml"><mo stretchy="false" id="m8.3" xref="m8.3.cmml">(</mo><mi id="m8.3.2" xref="m8.3.2.cmml">x</mi><mo stretchy="false" id="m8.3a" xref="m8.3.cmml">)</mo></mrow></mrow><mo lspace="0em" id="m8.11a" xref="m8.11.cmml">⁢</mo><mrow id="m8.13" xref="m8.15.cmml"><mo rspace="0em" id="m8.11b" xref="m8.11.cmml">𝑑</mo><mi id="m8.4" xref="m8.4.cmml">x</mi></mrow></mrow></mrow></mrow><annotation-xml encoding="MathML-Content" id="m8b"><apply id="m8.16.cmml" xref="m8.16"><plus id="m8.10.cmml" xref="m8.10"/><apply id="m8.9.cmml" xref="m8.9"><csymbol cd="latexml" id="m8.8.cmml" xref="m8.8">quantum-operator-product</csymbol><ci id="m8.5.cmml" xref="m8.5">Ψ</ci><ci id="m8.6.cmml" xref="m8.6">ℋ︀</ci><ci id="m8.7.cmml" xref="m8.7">Φ</ci></apply><apply id="m8.15.cmml" xref="m8.15"><int id="m8.11.cmml" xref="m8.11"/><bvar id="m8.15a.cmml" xref="m8.15"><ci id="m8.4.cmml" xref="m8.4">𝑥</ci></bvar><lowlimit id="m8.15b.cmml" xref="m8.15"><ci id="m8.1.cmml" xref="m8.1">𝑎</ci></lowlimit><uplimit id="m8.15c.cmml" xref="m8.15"><ci id="m8.2.cmml" xref="m8.2">𝑏</ci></uplimit><apply id="m8.3.cmml" xref="m8.3b"><ci id="m8.3.1.cmml" xref="m8.3.1">𝐹</ci><ci id="m8.3.2.cmml" xref="m8.3.2">𝑥</ci></apply></apply></apply></annotation-xml></semantics></math></td>
<td class="ltx_eqn_cell ltx_eqn_center_padright"/></tr></tbody>
</table>
<table id="S0.Ex9" class="ltx_equation ltx_eqn_table">
Expand Down

0 comments on commit b51b78a

Please sign in to comment.