Open akavel opened 1 year ago
Hm; I found some hints for debugging the fontconfig library by setting an FC_DEBUG
environment variable, apparently accepting flags with values from 1 to 4096. Seems to dump some info when set before running sile, so I will try investigating through this.
Also, feels like it may potentially be related/the same issue as #1552.
edit: Hm, it looks like only the opentype/
and truetype/
subdirs of ~/.nix-profile/share/fonts/
are searched, so neither ttf/
nor otf/
are. Sounds like I will need to further debug where this is configured.
$ FC_DEBUG=8 sile --debug fonts tmp.sil 2>&1 | grep .nix-profile
adding fonts from /home/akavel/.nix-profile/lib/X11/fonts
cache scan dir /home/akavel/.nix-profile/lib/X11/fonts
adding fonts from /home/akavel/.nix-profile/share/fonts
adding fonts from /home/akavel/.nix-profile/share/fonts/opentype
adding fonts from /home/akavel/.nix-profile/share/fonts/truetype
[...]
edit 2: Not verified yet, but looks like a packaging bug in the alegreya font package in Nixpkgs/NixOS: it seems that practically all other font packages move stuff to the opentype/
and truetype/
dirs, with alegreya
, alegreya-sans
, and montserrat
being the only exceptions I noticed. Will try to verify this locally and if confirmed, submit a PR to Nixpkgs. Still, in that case it would actually not seem related to #1552 (or is it?); also, I haven't found a place in Nixpkgs where those dir names would be configured (so maybe it is a builtin fontconfig thing?).
edit 3: Just tweaking the installPhase
of the alegreya
package to put the files in truetype/
& opentype/
did not, to my surprise, seem to have any influence on the sile
outcome. Notably, files are there, but FC_DEBUG=8
still does not seem to show them being loaded. (Even after running fc-cache -r
.) Seems I'm stuck, again :(
edit 4: Wooow, but running sile using its own flake.nix
worked! Now that's weird to me, and would seem even more to suggest that's maybe some NixOS packaging issue:
$ nix run github:sile-typesetter/sile/v0.14.5 -- --debug fonts tmp.sil
SILE v0.14.5-1a86520-flake (Lua 5.3)
<tmp.sil> as sil
[fonts] Looking for Alegreya;10;400;;normal;;LTR
[fonts] Resolved font family 'Alegreya' -> /nix/store/5dz0bix2mwdvwl7gnw7iy1l7f7qib4zq-home-manager-path/share/fonts/opentype/Alegreya-Regular.otf
[fonts] Looking for Alegreya;10;700;;normal;;LTR
[fonts] Resolved font family 'Alegreya' -> /nix/store/5dz0bix2mwdvwl7gnw7iy1l7f7qib4zq-home-manager-path/share/fonts/opentype/Alegreya-Bold.otf<...wms6r-sile-0.14.5-1a86520-flake/share/sile/core/sile.lua:363> as lua
MCDBG f=/nix/store/5dz0bix2mwdvwl7gnw7iy1l7f7qib4zq-home-manager-path/share/fonts/opentype/Alegreya-Regular.otf
[1]
@doronbehar Does the difference in behavior observed in SILE's calls to fontconfig
when used directly as a Flake vs. home-manager make any sense to you at all?
Is it possible we're looking at a bug it Nix itself (not just packaging) where it is not allowing the original SILE build to pick up on the new paths in the updated font package?
Tentatively marking this as not our bug, but I'm going to keep it open for tracking until we're certain it's a Nix issue and get a fix in the works.
I'm pretty sure I understand what #1552 is about and that it has no relation to this.
Question: Are you running your tests in a SILE source directory or some other workspace? There are some known issues with trying to run SILE from your system while you happen to have PWD
of a copy of the SILE sources because it prioritizes ./
over other paths to load resources from. That leads to really confusing mismatches.
Are you running your tests in a SILE source directory or some other workspace?
Other workspace - a directory containing a small personal git repository with my custom *.sil file[s].
Does that other workspace by chance have a nix devel environment or shell of its own that might be excluding your home manager supplied environment and using only its local dependencies?
@doronbehar Does the difference in behavior observed in SILE's calls to
fontconfig
when used directly as a Flake vs. home-manager make any sense to you at all?Is it possible we're looking at a bug it Nix itself (not just packaging) where it is not allowing the original SILE build to pick up on the new paths in the updated font package?
I've never encountered such issue before.. From what I know font-config related issues are complicated, and I'm not experienced in debugging them... I too would suggest to look for differences in the environment of these two sile
executions - try to override the wrapper in the flake version and in home-manager's version such that it will write the environment in which it runs sile to a text file (env > ~/sile-{HomeManager,flake}.env
or alike).
Good idea. You don't have to override the wrapper anywhere, as long as you can execute SILE itself you can just ask it to dump the environment. You can just shell out from Lua like this:
$ sile -e 'os.execute("env > vars.env");os.exit()'
Do that for both ways of executing and hopefully that will give us something worth diffing.
I'm working on a NixOS (via flakes) machine and with a separate home-manager setup (also via flakes). I have the Alegreya font installed via
nix profile install nixpkgs#alegreya
, andsile
installed viahome-manager
(sile --version
showsSILE v0.14.5 (Lua 5.3)
). Runningfc-match
shows:However, the font seems not found by SILE - when I try to render the following
tmp.sil
file:I see output like below:
Curiously, when I change
Alegreya
toGentium Plus
in thetmp.sil
file, the font seems properly detected, with a path in my~/.nix-profile
:Is there some way how I could try to debug why fontconfig, as used by SILE, does not seem to find the Alegreya font in my
~/.nix-profile
tree? (FWIW, a~/.nix-profile/share/fonts/ttf/Alegreya-Regular.ttf
seems to also exist on my machine, though apparentlyfc-match
picks the*.otf
file.) I'm stuck and don't have more ideas what I could investigate further, and how to find if the issue is on SILE side, or on Nix/NixOS side, and in what way - any help would be appreciated!