[latex3-commits] [git/LaTeX3-latex3-latex2e] gh404: Support \textnonbreakinghyphen, \textfiguredash and \texthorizontalbar by approximation in OT1 T1 and TU (if missing) (4915a35c)

Frank Mittelbach frank.mittelbach at latex-project.org
Fri Feb 19 11:50:23 CET 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh404
Link       : https://github.com/latex3/latex2e/commit/4915a35c4eeb57b3672367e560a6239d6a866a27

>---------------------------------------------------------------

commit 4915a35c4eeb57b3672367e560a6239d6a866a27
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Fri Feb 19 11:50:23 2021 +0100

    Support \textnonbreakinghyphen, \textfiguredash and \texthorizontalbar by approximation in OT1 T1 and TU (if missing)


>---------------------------------------------------------------

4915a35c4eeb57b3672367e560a6239d6a866a27
 base/changes.txt                      |  6 ++++
 base/doc/ltnews33.tex                 | 26 ++++++++++++++
 base/ltoutenc.dtx                     | 37 +++++++++++++++++--
 base/testfiles/github-0404.luatex.tlg | 12 +++++++
 base/testfiles/github-0404.lvt        | 68 +++++++++++++++++++++++++++++++++++
 base/testfiles/github-0404.tlg        | 16 +++++++++
 base/testfiles/github-0404.xetex.tlg  | 12 +++++++
 7 files changed, 175 insertions(+), 2 deletions(-)

diff --git a/base/changes.txt b/base/changes.txt
index 4c886c32..e83dbd06 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,12 @@ completeness or accuracy and it contains some references to files that
 are not part of the distribution.
 ================================================================================
 
+2021-02-19  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
+
+	* ltoutenc.dtx (subsection{Definitions for the TU encoding}):
+	Add \textnonbreakinghyphen, \textfiguredash and \texthorizontalbar
+	to OT1, T1 and TU encoding (gh/404)
+
 2021-02-17  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
 
 	* ltoutenc.dtx (subsection{Definitions for the TS1 encoding}):
diff --git a/base/doc/ltnews33.tex b/base/doc/ltnews33.tex
index 650135ea..5dda449d 100644
--- a/base/doc/ltnews33.tex
+++ b/base/doc/ltnews33.tex
@@ -375,6 +375,32 @@ up.
 
 
 
+\subsection{Provide more ``dashes'' in encodings \texttt{OT1}, \texttt{T1} and \texttt{TU}}
+
+When pasting in text from external sources one sometimes encounters the Unicode characters
+%
+\texttt{"2011} (non-breaking hyphen),
+\texttt{"2012} (figure dash) and
+\texttt{"2015} (horizontal bar)
+%
+in addition to the common \texttt{"2013} (en-dash) and \texttt{"2014}
+(em-dash). In the past the first three characters produced an error
+message when used with \pdfTeX{}. Now they typeset an approximation
+(as they are unavailable in \texttt{OT1} or \texttt{T1} encoded fonts
+used by \pdfTeX{}), e.g., the figure dash is approximated by an en-dash.
+
+In Unicode engines they either work (if contained in the selected
+Unicode font) or typeset nothing and produce a ``Missing character''
+warning in the log file.
+
+However, what works in all engines now, is to access the characters
+via the command names \cs{textnonbreakinghyphen}, \cs{textfiguredash}
+and \cs{texthorizontalbar}, respectively.
+%
+\githubissue{404}
+
+
+
 \subsection{\ldots}
 
 \emph{to be written}
diff --git a/base/ltoutenc.dtx b/base/ltoutenc.dtx
index 43ebc9f1..08b0fb62 100644
--- a/base/ltoutenc.dtx
+++ b/base/ltoutenc.dtx
@@ -1717,6 +1717,15 @@
 \DeclareTextSymbol{\textemdash}{OT1}{124}
 \DeclareTextSymbol{\textendash}{OT1}{123}
 %    \end{macrocode}
+%    
+% \changes{v2.0u}{2021/02/19}{Add \cs{textnonbreakinghyphen}, \cs{textfiguredash}
+%      and \cs{texthorizontalbar} (gh/404)}
+%    \begin{macrocode}
+\DeclareTextCommand{\textnonbreakinghyphen}{OT1}{\mbox{-}\hskip\z@}
+\DeclareTextCommand{\textfiguredash}       {OT1}{\textendash}
+\DeclareTextCommand{\texthorizontalbar}    {OT1}{\textemdash\textemdash}
+%    \end{macrocode}
+%
 %    Using the ligatures helps with OT1 fonts that have
 %    |\textexclamdown| and |\textquestiondown| in unusual positions.
 % \changes{v1.95}{2002/06/17}{Definition of \cs{textexclamdown} changed (pr/3368)}
@@ -2045,6 +2054,17 @@
 \DeclareTextSymbol{\textdollar}{T1}{`\$}
 \DeclareTextSymbol{\textemdash}{T1}{22}
 \DeclareTextSymbol{\textendash}{T1}{21}
+%    \end{macrocode}
+%
+% \changes{v2.0u}{2021/02/19}{Add \cs{textnonbreakinghyphen}, \cs{textfiguredash}
+%      and \cs{texthorizontalbar} (gh/404)}
+%    \begin{macrocode}
+\DeclareTextCommand{\textnonbreakinghyphen}{T1}{\mbox{-}\hskip\z@}
+\DeclareTextCommand{\textfiguredash}       {T1}{\textendash}
+\DeclareTextCommand{\texthorizontalbar}    {T1}{\textemdash\textemdash}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 \DeclareTextSymbol{\textexclamdown}{T1}{189}
 \DeclareTextSymbol{\textgreater}{T1}{`\>}
 %\DeclareTextSymbol{\texthyphenchar}{T1}{127}
@@ -3135,10 +3155,23 @@
 %      and \cs{texthorizontalbar} (gh/404)}
 %    \begin{macrocode}
 \DeclareTextSymbol{\textnonbreakinghyphen} \UnicodeEncodingName{"2011}
-\DeclareTextSymbol{\textfiguredash}      \UnicodeEncodingName{"2012}
+%\DeclareTextSymbol{\textfiguredash}      \UnicodeEncodingName{"2012}
 \DeclareTextSymbol{\textendash}          \UnicodeEncodingName{"2013}
 \DeclareTextSymbol{\textemdash}          \UnicodeEncodingName{"2014}
-\DeclareTextSymbol{\texthorizontalbar}   \UnicodeEncodingName{"2015}
+%\DeclareTextSymbol{\texthorizontalbar}   \UnicodeEncodingName{"2015}
+%    \end{macrocode}
+%    Unfortunately many fonts do not implement \texttt{"2012} and/or
+%    \texttt{"2015} (including the \LaTeX{} default fonts for Unicode
+%    engines) so we provide some approximations if the glyph is
+%    missing, like we do for \texttt{OT1} and \texttt{T1}.
+%    \begin{macrocode}
+\DeclareTextCommand{\textfiguredash}     \UnicodeEncodingName
+     {\iffontchar\font "2012 \char "2012 \else \char "2013 \fi}
+\DeclareTextCommand{\texthorizontalbar}     \UnicodeEncodingName
+     {\iffontchar\font "2015 \char "2015 \else \char "2014 \char "2014 \fi}
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
 \DeclareTextSymbol{\textbardbl}          \UnicodeEncodingName{"2016}
 \DeclareTextSymbol{\textquoteleft}       \UnicodeEncodingName{"2018}
 \DeclareTextSymbol{\textquoteright}      \UnicodeEncodingName{"2019}
diff --git a/base/testfiles/github-0404.luatex.tlg b/base/testfiles/github-0404.luatex.tlg
new file mode 100644
index 00000000..ecbcf558
--- /dev/null
+++ b/base/testfiles/github-0404.luatex.tlg
@@ -0,0 +1,12 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+============= TU ====================
+\textnonbreakinghyphen = 3.33pt
+\textfiguredash = 5.0pt
+\texthorizontalbar = 20.0pt
+\textendash = 5.0pt
+\textemdash = 10.0pt
+[1
+Missing character: There is no ‒ (U+2012) in font [lmroman10-regular]:+tlig;!
+Missing character: There is no ― (U+2015) in font [lmroman10-regular]:+tlig;!
+] (github-0404.aux)
diff --git a/base/testfiles/github-0404.lvt b/base/testfiles/github-0404.lvt
new file mode 100644
index 00000000..deb3b6b3
--- /dev/null
+++ b/base/testfiles/github-0404.lvt
@@ -0,0 +1,68 @@
+\documentclass{article}
+
+\input{test2e}
+
+
+\newlength{\len}
+
+
+
+%%% easier input
+\newcommand{\entry}[1]{%
+	\settowidth{\len}{#1}%
+	\typeout{\string#1 = \the\len}%
+%	#1 = \the\len\par
+}
+
+%\showoutput
+
+\begin{document}
+
+
+\START
+
+\ifx\Umathcode\undefined % testing pdftex engine
+
+\typeout{============= OT1 ===================}
+
+\entry\textnonbreakinghyphen
+\entry\textfiguredash
+\entry\texthorizontalbar
+\entry\textendash 
+\entry\textemdash
+
+1 ‑ 2 ‒ 3 ― !
+
+
+\typeout{============= T1 ====================}
+
+\fontencoding{T1}\selectfont
+
+\entry\textnonbreakinghyphen
+\entry\textfiguredash
+\entry\texthorizontalbar
+\entry\textendash 
+\entry\textemdash
+
+1 ‑ 2 ‒ 3 ― !
+
+\else    % testing TU in unicode engines
+
+\typeout{============= TU ====================}
+
+\OMIT % hid font loading info because the test suite uses CM if possible
+\fontencoding{TU}\selectfont
+\TIMO
+
+\entry\textnonbreakinghyphen
+\entry\textfiguredash
+\entry\texthorizontalbar
+\entry\textendash 
+\entry\textemdash
+
+1 ‑ 2 ‒ 3 ― !
+
+\fi
+
+%\END
+\end{document}
diff --git a/base/testfiles/github-0404.tlg b/base/testfiles/github-0404.tlg
new file mode 100644
index 00000000..3ff5b21f
--- /dev/null
+++ b/base/testfiles/github-0404.tlg
@@ -0,0 +1,16 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+============= OT1 ===================
+\textnonbreakinghyphen = 3.33333pt
+\textfiguredash = 5.00002pt
+\texthorizontalbar = 20.00003pt
+\textendash = 5.00002pt
+\textemdash = 10.00002pt
+============= T1 ====================
+\textnonbreakinghyphen = 3.33252pt
+\textfiguredash = 4.99878pt
+\texthorizontalbar = 19.99512pt
+\textendash = 4.99878pt
+\textemdash = 9.99756pt
+[1
+] (github-0404.aux)
diff --git a/base/testfiles/github-0404.xetex.tlg b/base/testfiles/github-0404.xetex.tlg
new file mode 100644
index 00000000..6b6e7d45
--- /dev/null
+++ b/base/testfiles/github-0404.xetex.tlg
@@ -0,0 +1,12 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+============= TU ====================
+\textnonbreakinghyphen = 3.33pt
+\textfiguredash = 5.0pt
+\texthorizontalbar = 20.0pt
+\textendash = 5.0pt
+\textemdash = 10.0pt
+Missing character: There is no ‒ in font [lmroman10-regular]:mapping=tex-text;!
+Missing character: There is no ― in font [lmroman10-regular]:mapping=tex-text;!
+[1
+] (github-0404.aux)





More information about the latex3-commits mailing list.