latex3 / luaotfload

OpenType font loader for LuaTeX
Other
59 stars 6 forks source link

Stix Two Math keeps rewriting the cache with lualatex #166

Open cont-lan opened 4 years ago

cont-lan commented 4 years ago

This issue started out as a question on TeX StackExchange (where my username is LeifLund):

https://tex.stackexchange.com/questions/560861/stix-two-math-keeps-rewriting-the-cache-with-lualatex

On the advice of Ulrike Fischer in comments I came here. The MWE I use has tiny changes compared to the one in StackExchange: MWE.tex.zip

The end of ls -ltr of the font cache:

-rw-rw-r-- 1 leif leif  449264 2020-08-30 12:47 stix2text-bold.luc
-rw-rw-r-- 1 leif leif  764569 2020-08-30 12:47 stix2text-italic.lua
-rw-rw-r-- 1 leif leif  477285 2020-08-30 12:47 stix2text-italic.luc
-rw-rw-r-- 1 leif leif 1042702 2020-09-01 11:35 stix2math.lua
-rw-rw-r-- 1 leif leif 1042702 2020-09-01 11:35 before
-rw-rw-r-- 1 leif leif  628077 2020-09-01 11:35 stix2math.luc

The file before is a copy of stix2math.lua. After running lualatex MWE we get

-rw-rw-r-- 1 leif leif  449264 2020-08-30 12:47 stix2text-bold.luc
-rw-rw-r-- 1 leif leif  764569 2020-08-30 12:47 stix2text-italic.lua
-rw-rw-r-- 1 leif leif  477285 2020-08-30 12:47 stix2text-italic.luc
-rw-rw-r-- 1 leif leif 1042702 2020-09-01 11:35 before
-rw-rw-r-- 1 leif leif 1042702 2020-09-01 15:19 stix2math.lua
-rw-rw-r-- 1 leif leif 1042702 2020-09-01 15:19 after
-rw-rw-r-- 1 leif leif  628077 2020-09-01 15:19 stix2math.luc

where after is a new copy of stix2math.lua. The diff is diff.zip

Versions of everything: TeX 3.14159265 (TeX Live 2020)

luaotfload-tool version: "3.14"
Luaotfload: "v3.14/2020-05-06"
Revision: "79077b0311ec65e8eb3c60bfc306500d72fd270e"
Lua interpreter: stock; version "Lua 5.3"
Luatex version: 1.12
Platform: type=unix name=linux
    +  machine: x86_64
    + nodename: xxx.xxx.xxx
    +  release: 5.8.4-200.fc32.x86_64
    +  sysname: Linux
    +  version: #1 SMP Wed Aug 26 22:28:08 UTC 2020
Index: version=-1 created="2020-08-29 14:36:08" modified="2020-08-29 14:36:08"

I have made a separate installation of Texlive 2020, so no files come from the Fedora distribution.

u-fischer commented 4 years ago

What do the logs say at the end about the location of the font file? It is always the same location?

zauguin commented 4 years ago

@cont-lan Could you additionally upload:

cont-lan commented 4 years ago

@u-fischer: I enclose the log file MWE.log.zip It mentions the .otf files, but I cannot find any mention of any of the cache files.

u-fischer commented 4 years ago

you are not using the stix math font in your MWE ;-(. Add an \int or so so that you can see in the log where the font is from. And add the files @zauguin asked for.

cont-lan commented 4 years ago

@u-fischer @zauguin We had a short local power outage :-( hence the delay.

Above I promised that I did not have any files from the fedora distibution. That turned out to be a lie, because the Fedora package stix-fonts is in fact installed, and seems to insinuate itself into the lualatex processing. I suggest that we put this discussion on hold until I have understood more about why the Fedora package was installed, and how and why it mixes with the Texlive files.

zauguin commented 4 years ago

@u-fischer @zauguin We had a short local power outage :-( hence the delay.

Above I promised that I did not have any files from the fedora distibution. That turned out to be a lie, because the Fedora package stix-fonts is in fact installed, and seems to insinuate itself into the lualatex processing. I suggest that we put this discussion on hold until I have understood more about why the Fedora package was installed, and how and why it mixes with the Texlive files.

I can't tell you why it is installed, but it is default behavior in luaotfload that in that case, the system font is preferred.

Even if you have these additional fonts installed, luotfload still shouldn't keep rewriting the cache. So it would be great if you could provide the information anyway.

cont-lan commented 4 years ago

@zauguin

@cont-lan Could you additionally upload:

* The diff you get between `after` and `stix2math.lua` after running `lualatex MWE` a second time

That was exactly the diff you got.

* `ls -l` output for the font file used for STIX2 Math (The path should be given at the end of the log or around line 44520 of `stix2math.lua`.

Here are the ls -l and the md5sum of both files.

ls -l /usr/share/fonts/stix-fonts/STIX2Math.otf; md5sum /usr/share/fonts/stix-fonts/STIX2Math.otf
-rw-r--r-- 1 root root 808220 2019-06-18 18:47 /usr/share/fonts/stix-fonts/STIX2Math.otf
ec7220889178fdf32e3a2605c7b64209  /usr/share/fonts/stix-fonts/STIX2Math.otf
ls -l /opt/texlive/texmf-dist/fonts/opentype/public/stix2-otf/STIX2Math.otf; md5sum /opt/texlive/texmf-dist/fonts/opentype/public/stix2-otf/STIX2Math.otf
-rw-r--r-- 1 root root 808220 2019-05-03 00:48 /opt/texlive/texmf-dist/fonts/opentype/public/stix2-otf/STIX2Math.otf
2cdae3efd06ddad8e66bc743796bb3d3  /opt/texlive/texmf-dist/fonts/opentype/public/stix2-otf/STIX2Math.otf

The file mentioned in stix2math.lua is /usr/share/fonts.... The md5sum show that they are obviously different, even if they have the same size.

* complete copy of any version of `stix2math.lua`

stix2math.lua.zip

* The output of `luaotfload-tool --list='familyname:Stix Two*' --fields=basename,fullpath`

luaotfload-tool --list='familyname:Stix Two*' --fields=basename,fullpath

stixtwomath STIX2Math.otf /opt/texlive/texmf-dist/fonts/opentype/public/stix2-otf/STIX2Math.otf stixtwotext STIX2Text-BoldItalic.otf /opt/texlive/texmf-dist/fonts/opentype/public/stix2-otf/STIX2Text-BoldItalic.otf stixtwotext STIX2Text-Regular.otf /opt/texlive/texmf-dist/fonts/opentype/public/stix2-otf/STIX2Text-Regular.otf stixtwotext STIX2Text-Italic.otf /opt/texlive/texmf-dist/fonts/opentype/public/stix2-otf/STIX2Text-Italic.otf stixtwotext STIX2Text-Bold.otf /opt/texlive/texmf-dist/fonts/opentype/public/stix2-otf/STIX2Text-Bold.otf stixtwotext STIX2Text-Regular.otf /usr/share/fonts/stix-fonts/STIX2Text-Regular.otf stixtwotext STIX2Text-BoldItalic.otf /usr/share/fonts/stix-fonts/STIX2Text-BoldItalic.otf stixtwotext STIX2Text-Bold.otf /usr/share/fonts/stix-fonts/STIX2Text-Bold.otf stixtwotext STIX2Text-Italic.otf /usr/share/fonts/stix-fonts/STIX2Text-Italic.otf stixtwomath STIX2Math.otf /usr/share/fonts/stix-fonts/STIX2Math.otf

zauguin commented 4 years ago

The issue is that unicode-math tries to load the font both in regular and in bold. The regular font is loaded using the family lookup rules and therefore correctly selects the system font. For the bold font, the system detects that no bold version exists and therefore tries other ways of finding the font before falling back to the regular version. In this step, the rule "system font before texmf font" is not checked and the first found font is used, in this case the texmf one. Therefore the "bold" and the "regular" version are the same font, but oaded from different locations.

Given that both loctions have the same filename, the same cache file is used and both caches overwrite each other, triggering cache rewriting everytime the document is compiled. (The same issue probably caused #40) We can probably fix this by adding a lookup system similar to families for individual fonts.

u-fischer commented 4 years ago

@zauguin would it be possible/sensible to make the cache unique by location, e.g. by adding a hash of the path to the name?

zauguin commented 4 years ago

@u-fischer Sensible? IMO yes. Possible? Not without patching the fontloader. The only cache we have which is not managed by the fontloader (the hb one for harf) already does this.