latex3 / babel

The babel system for LaTeX, LuaLaTeX and XeLaTeX
LaTeX Project Public License v1.3c
123 stars 34 forks source link

ensureascii issues. #265

Closed gmilde closed 9 months ago

gmilde commented 9 months ago

If I load font encoding T1, T2A, and LGR, the latinencoding is T1 but inside ensureascii, the encoding is T2A -- no matter which order I set T1 and T2A:

\documentclass{article}
\usepackage[T2A,T1,LGR]{fontenc}
% \usepackage[T1,T2A,LGR]{fontenc}
\usepackage[english,polish]{babel}
\makeatletter
\begin{document}
\textlatin{The latinencoding is \latinencoding}

\ensureascii{but inside ensureascii, the font encoding is \cf@encoding
(деиствительно).}

\end{document}

Maybe this has to do with the special status of T1: it is preloaded and fontenc's \@fontenc@load@list is T1,OT1T2A,T1,LGR.

jbezos commented 9 months ago

babel ignores the preloaded encodings and in fact it works for me as expected (the last ASCII encoding wins), but I have to update my TeXLive first.

jbezos commented 9 months ago

Updated TeXLive and still working. Please, copy the file list or the log file.

gmilde commented 9 months ago

I tested again with an up-to-date TeXLive23 and the TeXLive21 from Debian/bookworm. The issue only manifetst with the legacy TeXLive21. With an up-to-date installation, the last ASCII-compatible encoding wins :) Sorry for the noise.

There is, however another problem which persists: Thefont encoding LGI is not detected as non-standard: \documentclass{article}

\usepackage[T1,LGI,OT2]{fontenc} \usepackage[english]{babel} \makeatletter

\begin{document}

default \encodingdefault, active \cf@encoding, \ensureascii{ensureascii \cf@encoding}, \textlatin{latinencoding \latinencoding}.

\LaTeX

\ensureascii{this should be Latin script} \end{document}

gmilde commented 9 months ago

One more non-standard encoding is T3. Note the misleading name!

\documentclass{article}

\usepackage[T1,T3]{fontenc} \usepackage[english]{babel} \makeatletter

\begin{document}

Encodings: default \encodingdefault, active \cf@encoding, \ensureascii{ensureascii \cf@encoding}, \textlatin{latinencoding \latinencoding}.

\LaTeX is toll

\ensureascii{abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ}

\ensureascii{0123456789 .,!?()} \end{document}

gmilde commented 9 months ago

For the documentation: The purpose of \ensureascii is to ensure all characters corresponding to to the "Required glyphs for general text encodings" (encguide.pdf, section 3.1) work.

IOW, ensure a font encoding that has the glyphs at the correct positions, so that all ASCII characters that can be used directly (i.e. without an LICR macro) in LaTeX with OT1 or T1 are safe to use when wrapped with \ensureascii{...}.

jbezos commented 9 months ago

🤔 The odd thing is T3 is in fact being treated as ‘non-ascii’ because of a bug. It should be, as documented, ‘non-text’ (and therefore ignored) because it’s basically a container for IPA symbols and not a character set for a real language to be dealt with by babel, but by the corresponding packages.

gmilde commented 8 months ago

Thank you for the explanation. I am fine with T3.

I suggest adding the LGI encoding to the nonASCII list: LGI is a nonASCII encoding from the ibycus-babel package

\documentclass{article}

% \usepackage[LGI,T1]{fontenc}
\usepackage[english,ibycus]{babel}

\begin{document}
\makeatletter

\textlatin{Compiled with format version \fmtversion{},
patch-level ***@***.***{}.}

\textlatin{Babel Version: \csname ***@***.***\endcsname}.

\ensureascii{ensureascii: ***@***.***},
\textlatin{latinencoding: \latinencoding, language: ibycus}

\medskip

Elleniki: Agapa'me \LaTeX (\textlatin{sic!})

\ensureascii{ensureascii: We love \LaTeX (\textlatin{sic!})}

\textlatin{textlatin: We love \LaTeX}

\foreignlanguage{english}{English: We love \LaTeX}

\end{document}