Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10147 Generating pdf with LuaLateX #10150

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

flagarde
Copy link

No description provided.

\etocruledstyle[#1]{#2}%
 \tableofcontents*}
\etocruledstyle[#1]{#2}%
\tableofcontents*}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should indeed be fixed, and probably also be reported upstream (seen the copyright notice), I will check this. The spaces should stay (as they are from the original.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already send a notice to upstream through issue #9936

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made PR #10171 which incorporates the removal of the stray bytes. I don't know where these bytes come from as they were not found upstream...

@albert-github
Copy link
Collaborator

I did a quick test wit the example (example.tar.gz):

/** \file

Plain text cm/s => 10⁻²*m/s

*/

With pdflatex I get:

image

With lualatex / xelatex I get:

image

so we see that the minus sign is missing.

Versions:

  • This is pdfTeX, Version 3.141592653-2.6-1.40.24 (MiKTeX 22.1) (preloaded format=pdflatex 2022.2.12)
  • This is LuaHBTeX, Version 1.14.0 (MiKTeX 22.1) (format=lualatex 2023.6.15)
  • This is XeTeX, Version 3.141592653-2.6-0.999993 (MiKTeX 22.1) (preloaded format=xelatex 2022.2.16)

Note:
With lualatex and xelatex I get a number of warnings like:

LaTeX Font Info:    Trying to load font information for TU+phv on input line 20
7.
LaTeX Font Info:    No file TUphv.fd. on input line 207.


LaTeX Font Warning: Font shape `TU/phv/m/n' undefined
(Font)              using `TU/lmr/m/n' instead on input line 207.

but I don't think they are influencing the behavior of the minus sign.

@flagarde
Copy link
Author

flagarde commented Jun 29, 2023

I guess it's a font problem. I will do some checks. Do you know what is the codepoint you insert for the - sign ? Normally unicode-math should deal with it. I imagine there is a clash with font packages and unicode-math.

I know Doxygen is loading some font in other places but I didn't found where :(. I think if this packages are removed on lualatex and xetex this should work

@flagarde
Copy link
Author

flagarde commented Jun 29, 2023

Some hacks that seems to work :

\ifpdftex
\doxynewunicodechar{⁰}{${}^{0}$}% Superscript zero
\doxynewunicodechar{ⁱ}{${}^{1}$}% Superscript one
\doxynewunicodechar{²}{${}^{2}$}% Superscript two
\doxynewunicodechar{³}{${}^{3}$}% Superscript three
\doxynewunicodechar{⁴}{${}^{4}$}% Superscript four
\doxynewunicodechar{⁵}{${}^{5}$}% Superscript five
\doxynewunicodechar{⁶}{${}^{6}$}% Superscript six
\doxynewunicodechar{⁷}{${}^{7}$}% Superscript seven
\doxynewunicodechar{⁸}{${}^{8}$}% Superscript eight
\doxynewunicodechar{⁹}{${}^{9}$}% Superscript nine
\doxynewunicodechar{⁻}{${}^{-}$}% Superscript minus
\doxynewunicodechar{⁺}{${}^{+}$}% Superscript plus
\doxynewunicodechar{ⁱ}{${}^{i}$}% Superscript i
\doxynewunicodechar{⁽}{${}^{(}$}% Superscript (
\doxynewunicodechar{⁾}{${}^{)}$}% Superscript )
\doxynewunicodechar{ⁿ}{${}^{n}$}% Superscript n
\else
\usepackage{combofont}
\defaultfontfeatures{Scale=MatchLowercase}
\setupcombofont{rm-regular}
{
	{file:lmroman10-regular.otf:\combodefaultfeat} at #1pt,
	{file:STIXTwoMath-Regular.otf}           at #1pt
}
{
	{} ,
	fallback
}

\setupcombofont{rm-bold}
{
	{file:lmroman10-bold.otf:\combodefaultfeat} at #1pt,
	{file:STIXTwoMath-Regular.otf}       at #1pt
}
{
	{} ,
	fallback
}

\setupcombofont{rm-italic}
{
	{file:lmroman10-bold.otf:\combodefaultfeat} at #1pt,
	{file:STIXTwoMath-Regular.otf}       at #1pt
}
{
	{} ,
	fallback
}


\setupcombofont{tt-regular}
{
	{file:lmmono10-regular.otf:\combodefaultfeat} at #1pt,
	{file:STIXTwoMath-Regular.otf}       at #1pt
}
{
	{} ,
	fallback
}

\setupcombofont{tt-bold}
{
	{file:lmmonolt10-bold.otf:\combodefaultfeat} at #1pt,
	{file:STIXTwoMath-Regular.otf}       at #1pt
}
{
	{} ,
	fallback
}

\setupcombofont{tt-italic}
{
	{file:lmmono10-italic.otf:\combodefaultfeat} at #1pt,
	{file:STIXTwoMath-Regular.otf}       at #1pt
}
{
	{} ,
	fallback
}


\setupcombofont{sf-regular}
{
	{file:lmsans10-regular.otf:\combodefaultfeat} at #1pt,
	{file:STIXTwoMath-Regular.otf}       at #1pt
}
{
	{} ,
	fallback
}

\setupcombofont{sf-bold}
{
	{file:lmsans10-bold.otf:\combodefaultfeat} at #1pt,
	{file:STIXTwoMath-Regular.otf}       at #1pt
}
{
	{} ,
	fallback
}

\setupcombofont{sf-italic}
{
	{file:lmsans10-oblique.otf:\combodefaultfeat} at #1pt,
	{file:STIXTwoMath-Regular.otf}       at #1pt
}
{
	{} ,
	fallback
}


\DeclareFontFamily{TU}{doxygen-rm}{}
\DeclareFontShape {TU}{doxygen-rm}{m}{n} {<->combo*rm-regular}{}
\DeclareFontShape {TU}{doxygen-rm}{m}{it} {<->combo*rm-italic}{}
\DeclareFontShape {TU}{doxygen-rm}{b}{n}{<->combo*rm-bold}{}

\DeclareFontFamily{TU}{doxygen-tt}{}
\DeclareFontShape {TU}{doxygen-tt}{m}{n} {<->combo*tt-regular}{}
\DeclareFontShape {TU}{doxygen-tt}{m}{it} {<->combo*tt-italic}{}
\DeclareFontShape {TU}{doxygen-tt}{b}{n}{<->combo*tt-bold}{}

\DeclareFontFamily{TU}{doxygen-sf}{}
\DeclareFontShape {TU}{doxygen-sf}{m}{n} {<->combo*sf-regular}{}
\DeclareFontShape {TU}{doxygen-sf}{m}{it} {<->combo*sf-italic}{}
\DeclareFontShape {TU}{doxygen-sf}{b}{n}{<->combo*sf-bold}{}

\renewcommand{\rmdefault}{doxygen-rm}
\renewcommand{\sfdefault}{doxygen-sf}
\renewcommand{\ttdefault}{doxygen-tt}
\setmathfont{STIXTwoMath-Regular.otf}
\fi

doxygen could maybe add very used symbol like this :

https://github.com/Christoph-D/latex-unicode-math-mode/blob/master/unicode-math-mode.sty

and maybe this one too (I'm biased because this is crashing with my code :) ) :

https://www.compart.com/en/unicode/block/U+2500

Maybe to put this in a specific .tex to increase from time to time

/** \file

 Plain text cm/s => 10⁻⁰ * m/s

 Plain text cm/s => 10⁻¹ * m/s

 Plain text cm/s => 10⁻² * m/s

 Plain text cm/s => 10⁻³ * m/s

 Plain text cm/s => 10⁻⁴ * m/s

 Plain text cm/s => 10⁻⁵ * m/s

 Plain text cm/s => 10⁻⁶ * m/s

 Plain text cm/s => 10⁻⁷ * m/s

 Plain text cm/s => 10⁻⁸ * m/s

 Plain text cm/s => 10⁻⁹ * m/s

 Plain text cm/s => 10⁺ * m/s

 Plain text cm/s => 10⁼ * m/s

 Plain text cm/s => 10⁽ * m/s

 Plain text cm/s => 10⁾ * m/s

 Plain text cm/s => 10⁻ⁱ * m/s

 Plain text cm/s => 10ⁿ * m/s
 

                          */

The problem was unicode-math doesn't detect them because the text is not in math mode. I add a fallback to the fonts

Luatex:
image

Pdflatex:

image

@albert-github
Copy link
Collaborator

  • fonts to the best of my knowledge doxygen does not really load packages only int translator.h I found that the package courier is loaded.
  • the original code where the superscript minus, two and three are used are in a proprietary software package and I just copied (in an editor) the relevant part. I'm not sure what you mean with the codepoint but when running od -bc on the minus sigh I get for the minus sign 342 201 273 (and for the two: 302 262). The codepoint might be 207B (see https://www.compart.com/en/unicode/block/U+2070).
  • I like the idea of extending the list of superscripts (was no need for me at the time of writing the original pull request Bug 768240 - Make maxLineLen of latex output configurable #711) and maybe also add the subscripts (see also my question / remark at the end off this comment)
  • the pdflatex version looks like to be missing the superscript equal sign , 207C (https://www.compart.com/en/unicode/block/U+2070)

In general I think we should think about the possibility to make lualatex (or xelatex) the default latex engine so we can incorporate the unicode characters (@doxygen what is you opinion on that).

@flagarde
Copy link
Author

@albert-github doxygen.sty load some fonts as you mentioned. Indeed the superscript equal sign , 207C is missing, this is more a pseudo-code (that why I didn't pushed on the code directly to have opinion on this hack).

@albert-github
Copy link
Collaborator

Did you try to run the doxygen tests locally with lualatex/xelatex?
E.g.

make tests TEST_FLAGS=--pdf --pool=4 --cfg LATEX_CMD_NAME=lualatex"

@albert-github
Copy link
Collaborator

Regarding:

doxygen could maybe add very used symbol like this :

https://github.com/Christoph-D/latex-unicode-math-mode/blob/master/unicode-math-mode.sty

and maybe this one too (I'm biased because this is crashing with my code :) ) :

https://www.compart.com/en/unicode/block/U+2500

It looks like this is not an official CTAN package so, I think, adding it directly to doxygen is not a good idea, though a user can always add it by means of LATEX_EXTRA_STYLESHEET

@flagarde
Copy link
Author

Did you try to run the doxygen tests locally with lualatex/xelatex? E.g.

make tests TEST_FLAGS=--pdf --pool=4 --cfg LATEX_CMD_NAME=lualatex"

Yes, I generated the doxygen ref.tex on my problematic file and then modified it by hands.
I tried with pdflatex and lualatex

@flagarde
Copy link
Author

flagarde commented Jun 29, 2023

Regarding:

doxygen could maybe add very used symbol like this :
https://github.com/Christoph-D/latex-unicode-math-mode/blob/master/unicode-math-mode.sty
and maybe this one too (I'm biased because this is crashing with my code :) ) :
https://www.compart.com/en/unicode/block/U+2500

It looks like this is not an official CTAN package so, I think, adding it directly to doxygen is not a good idea, though a user can always add it by means of LATEX_EXTRA_STYLESHEET

Doxygen could provide its own version.

@albert-github
Copy link
Collaborator

Regarding #10150 (comment)

Doxygen could provide it's own version.

that is true but where to stop / what to include, you mentioned the U+2500 block (which is quite a general block though) but other might like to use another block (like the ones after U+2010 or the ones after U+203B).
This was also why I made the remark about thinking about a general solution (in #10150 (comment))

@flagarde
Copy link
Author

Regarding #10150 (comment)

Doxygen could provide it's own version.

that is true but where to stop / what to include, you mentioned the U+2500 block (which is quite a general block though) but other might like to use another block (like the ones after U+2010 or the ones after U+203B). This was also why I made the remark about thinking about a general solution (in #10150 (comment))

True, In fact I thought the inputenc what doing this things for us. I switch to lualatex long time ago :) But some people need to compile with pdflatatex for good or bad reason.

I agree but doxygen could provide the minimum ones (math+ greek symbols + Diacritics). This would not solve the problem with chinese for example.

With the lualatex hack it could be possible to add font for that need by default.

@flagarde
Copy link
Author

Would you accept this hack, or would like to find an other alternative?

@flagarde
Copy link
Author

flagarde commented Jul 6, 2023

@albert-github Maybe this packages would solve some problems
\usepackage{ucs} and \usepackage[utf8x]{inputenc}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants