latex3 / babel

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

Tibetan line breaks #291

Open BenjaminGalliot opened 3 months ago

BenjaminGalliot commented 3 months ago

Hello,

(Related to https://github.com/latex3/babel/issues/250 but I can’t reopen this issue, so I moved messages here.)

I've noticed another problem , involving Tibetan word breaks especially when there is another language on the same line.

This affects both XeLaTeX and LuaLaTeX, but with variations...

Changing the geometry (the margins) or even deactivating it is interesting.

It seems that LuaLaTeX has some general difficulties cutting Tibetan (but this is more or less visible depending on the geometry configuration).

The behavior seems to be improved with XeLaTeX if language changes are made with selectlanguage and not with foreignlanguage.

I am using the latest version of Texlive 2024 (updated 2 days ago).

Here is the MWE:

\documentclass{article}

\RequirePackage{babel}
\RequirePackage[top=1cm, bottom=1cm, left=3cm, right=2cm]{geometry} % toggle comment
\RequirePackage{lipsum}

\babelprovide[import=bo]{tibetan}
\babelprovide[import=fr]{french}

\babelfont[french]{rm}{EB Garamond}
\babelfont[french]{sf}{EB Garamond}
\babelfont[french]{tt}{EB Garamond}

\babelfont[tibetan]{rm}{Jomolhari}
\babelfont[tibetan]{sf}{Jomolhari}
\babelfont[tibetan]{tt}{Jomolhari}

\setlength{\parindent}{0cm}

\begin{document}

\lipsum[1]

\subsubsection*{Everything foreignlanguage}

\foreignlanguage{tibetan}{དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།}

\medskip

\foreignlanguage{tibetan}{དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།}

\medskip

\foreignlanguage{tibetan}{དེང་སང་ \foreignlanguage{french}{TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ \foreignlanguage{french}{TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ \foreignlanguage{french}{TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ \foreignlanguage{french}{TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།}

\subsubsection*{Tibetan selectlanguage, Latin foreignlanguage}

\selectlanguage{tibetan}

དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།

\medskip

དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།

\medskip

དེང་སང་ \foreignlanguage{french}{TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ \foreignlanguage{french}{TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ \foreignlanguage{french}{TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ \foreignlanguage{french}{TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།

\subsubsection*{Tibetan foreignlanguage, Latin selectlanguage}

\foreignlanguage{tibetan}{
དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།

\medskip

དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།}

\medskip

\foreignlanguage{tibetan}{དེང་སང་ {\selectlanguage{french}TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ {\selectlanguage{french}TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ {\selectlanguage{french}TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ {\selectlanguage{french}TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།}

\subsubsection*{Everything selectlanguage}

\selectlanguage{tibetan}

དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།

\medskip

དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ TB ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།

\medskip

དེང་སང་ {\selectlanguage{french}TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ {\selectlanguage{french}TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ {\selectlanguage{french}TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད། དེང་སང་ {\selectlanguage{french}TB} ན་ཚ་ན་ནའང་སྨན་ཡག་པོ་བཟས་ན་གློ་བ་བཀོག་དགོས་མ་རེད།

\end{document}

Here are the screenshots:

LuaLaTeX: lualatex

XeLaTeX: xelatex

The other issue concerns LuaLaTeX, with a line break problem when adding a parenthesis.

The MWE:

\documentclass{article}

\RequirePackage{babel}
\RequirePackage{multicol}

\babelprovide[import=bo]{tibetan}
\babelprovide[import=fr]{french}

\babelfont[french]{rm}{EB Garamond}
\babelfont[french]{sf}{EB Garamond}
\babelfont[french]{tt}{EB Garamond}

\babelfont[tibetan]{rm}{Jomolhari}
\babelfont[tibetan]{sf}{Jomolhari}
\babelfont[tibetan]{tt}{Jomolhari}

\setlength{\parindent}{0cm}

\begin{document}

\selectlanguage{tibetan}

\begin{multicols}{2}

་་་་་་་་་་་་་་་་་་་་་་་་་་་་་་་་་་་་་་་སྐད་(ཆེན་པོ་)བརྒྱབ་པ།ངས་སྐད་བརྒྱབ་པ་ཡིན། ཡིན་ནའང་ཁོང་གིས་གོ་མ་སོང་།སྐད་(ཆེན་པོ་)བརྒྱབ་པ།ངས་སྐད་བརྒྱབ་པ་ཡིན། ཡིན་ནའང་ཁོང་གིས་གོ་མ་སོང་།སྐད་(ཆེན་པོ་)བརྒྱབ་པ།ངས་སྐད་བརྒྱབ་པ་ཡིན། ཡིན་ནའང་ཁོང་གིས་གོ་མ་སོང་།སྐད་(ཆེན་པོ་)བརྒྱབ་པ།ངས་སྐད་བརྒྱབ་པ་ཡིན། ཡིན་ནའང་ཁོང་གིས་གོ་མ་སོང་།

\end{multicols}

\end{document}

With LuaLaTeX: lualatex2

With XeLaTeX: xelatex2

As you can see in LuaLaTeX, a tsheg followed by a closing parenthesis will break the line right between them, instead of breaking the line after the closing parenthesis, as can be seen in XeLaTeX…

Another question: is there a simple way to prevent a single syllable from being alone on its line (beginning – in the case where the line incorporates other languages just before – or end)?

A last one: བོུ། seems to be rendered as བོ◌ུ།, how to correct that?

Thanks a lot!

jbezos commented 3 months ago

(Related to https://github.com/latex3/babel/issues/250 but I can’t reopen this issue, so I moved messages here.)

Please, don’t ask new questions in closed issues, even if related. I can overlook them easily.

As to the line breaking, you can make spaces in shads and tshegs more flexible with, for example:

\directlua{
  Babel.tibetan.shad = {.5, .5, 0, false}
  Babel.tibetan.tsheg = {0, .001, 0, false}
}

See https://latex3.github.io/babel/news/whats-new-in-babel-3.81.html

I’ll modify the rules so that closing characters are dealt with. In the meanwhile, you can modify babel-tibetan.tex in the following way. Replace:

 \babelprehyphenation{tibetan}{^^^^0f0b[^ ^^^^0f0d^^^^0f0e]}%
    { {insert, penalty=10000}, {insert, space=\bbl@tempe, data=1}, {},
      {insert, space=\bbl@tempe, data=1}, {} }}

with

  \babelprehyphenation{tibetan}{^^^^0f0b[^ {)}^^^^0f0d^^^^0f0e]}%
    { {insert, penalty=10000}, {insert, space=\bbl@tempe, data=1}, {},
      {insert, space=\bbl@tempe, data=1}, {} }}

Another question: is there a simple way to prevent a single syllable from being alone on its line (beginning – in the case where the line incorporates other languages just before – or end)?

Very likely it's possible with luatex, but I have to investigate.

A last one: བོུ། seems to be rendered as བོ◌ུ།, how to correct that?

The rendering of characters depends, in principle, on the renderer or the font. Try with HarfBuzz.

BenjaminGalliot commented 3 months ago

Please, don’t ask new questions in closed issues, even if related. I can overlook them easily.

I hesitated, but you said "If you need further help, just continue this thread.", but after some days without any news, I started this new issue!

Thanks for the help, in LuaLaTeX, the line break, the management of the closing parenthesis and the rendering by Harfbuzz worked!

Do you have any idea of the unexpected behavior in XeLaTeX with foreignlanguage and selectlanguage?

Very likely it's possible with luatex, but I have to investigate.

Thank you!

jbezos commented 3 months ago

I hesitated, but you said "If you need further help, just continue this thread.", but after some days without any news, I started this new issue!

Quite true. But 8 months have passed! 🙂

Line breaking in xetex is hardcoded, but perhaps can be fine-tuned with the interchar mechanism (not sure).