latex3 / unicode-math

XeLaTeX/LuaLaTeX package for using unicode/OpenType maths fonts
http://ctan.org/pkg/unicode-math
LaTeX Project Public License v1.3c
239 stars 28 forks source link

Remap characters for \setminus and \smallsetminus #583

Closed jakubkaczor closed 10 months ago

jakubkaczor commented 2 years ago

Status

READY

Description

STIX Two has been updated. (stipub/stixfonts#179) Therefore, this change achieves Unicode compliance without producing inconsistencies with STIX. This is regarding issue #181.

Todo

Minimal example demonstrating the new/fixed functionality

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}% filename only please!
\begin{document}
\[
  \setminus, \smallsetminus
\]
\end{document}
wspr commented 11 months ago

Sorry for the slow reply. To do this taking into account variations between fonts, wouldn't we need to have a package option or font-loading option to choose whether or not to switch these?

jakubkaczor commented 10 months ago

I am sorry, but after this time I can't remember the entire picture. I believe I based this PR on the following. You once said: “The unicode-math definitions come from the STIX table and match up with the STIX fonts (see below), which are the reference implementation for unicode math fonts”^1. The STIX fonts has been updated, therefore unicode-math has to be updated if STIX is supposed to be a “reference implementation”. I only considered defaults, not a way of handling different fonts.

davidcarlisle commented 10 months ago

RbM2d


\documentclass{article}
\usepackage{fontspec}
\newfontface\lm{lmroman10-regular.otf}
\newfontface\lmm{latinmodern-math.otf}
\newfontface\tgp{texgyrepagella-regular.otf}
\newfontface\tgpm{texgyrepagella-math.otf}
\newfontface\cbia{Cambria}
\newfontface\cbiam{Cambria Math}
\newfontface\sx{Stix Two Text}
\newfontface\sxm{Stix Two Math}
\newfontface\ncm{NewCM10-Book.otf}
\newfontface\ncmm{NewCMMath-Book.otf}
\newfontface\fira{FiraSans-Regular.otf}
\newfontface\firam{FiraMath-Regular.otf}

\usepackage{amssymb}
\begin{document}

{\tiny
U+005C REVERSE SOLIDUS

U+2216 SET MINUS

U+27CD MATHEMATICAL FALLING DIAGONAL

U+29F5 REVERSE SOLIDUS OPERATOR

U+FE68 SMALL REVERSE SOLIDUS

}
\def\x#1 #2 #3:#4\relax{#3}
\newcommand\test[2]{
#1 \expandafter\expandafter\expandafter\x\expandafter\meaning\the\font\relax
&#1  \char"005C   &#1  ^^^^29f5 &#1  ^^^^2216  &#1  ^^^^27cd &#1  ^^^^fe68  \\
#2 \expandafter\expandafter\expandafter\x\expandafter\meaning\the\font\relax
&#2  \char"005C   &#2  ^^^^29f5 &#2  ^^^^2216  &#2  ^^^^27cd &#2  ^^^^fe68  \\[10pt]
}

\begin{tabular}{llllll}
    &005C             &2216         &27CD          &29F5         &FE68        \\
amssymb &$\backslash$&$\setminus$& ? &$\smallsetminus$&?\\[10pt]
\test\lm\lmm
\test\tgp\tgpm
\test\cbia\cbiam
\test\sx\sxm
\test\ncm\ncmm
\test\fira\firam
\end{tabular}

\end{document}

Which is fairly depressing, none of the OTF really has a small set minus apart from NCM but at least U+29F5 is more slanted so that's a better map for smallsetminus in the fonts where it exists. So I think that should be the used were possible but neither is usable as a straight default setting I think the settings need to be guarded by tests to see if the characters exist in the font and set them to something that exists in all cases.

davidcarlisle commented 10 months ago

@wspr perhaps something like this, modify the table as in this PR but at the end make sure both commands point to something

\documentclass{article}

\usepackage{unicode-math}
\AtBeginDocument{%
% from (new) unicode-math-table
%\UnicodeMathSymbol{"02216}{\setminus                 }{\mathbin}{reverse solidus operator}%
%\UnicodeMathSymbol{"029F5}{\smallsetminus            }{\mathbin}{small set minus (cf. reverse solidus)}%
\iffontchar\textfont2 "02216 \else
  \let\setminus \backslash
\fi
\iffontchar\textfont2 "029F5 \else
  \let\smallsetminus\setminus 
\fi
}

%\setmathfont{NewCMMath-Book.otf}
%\setmathfont{FiraMath-Regular.otf}
\setmathfont{Stix Two Math}

\begin{document}

$[\backslash][\setminus][\smallsetminus]$
\end{document}
wspr commented 10 months ago

Many thanks for the contributions and input here. I've taken this on board but implemented it slightly differently — update to come.