Chromium: Difference between revisions
Marked this version for translation |
Added section explaining how to use fonts when running Chromium in a container |
||
| Line 208: | Line 208: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Getting fonts to work in containers == | |||
When building a container using {{Nixpkgs Manual|name=dockerTools.streamLayeredImage|anchor=#ssec-pkgs-dockerTools-streamLayeredImage}} or {{Nixpkgs Manual|name=dockerTools.buildLayeredImage|anchor=#ssec-pkgs-dockerTools-buildLayeredImage}}, the image won't include any fonts, and so Chrome won't be able to render any text. To handle this, you must add {{nixos:package|fontconfig}} to the image, along with the fonts you want included. | |||
Adding fonts to your image will only add them at {{ic|/share/fonts}}, but fontconfig expects them at {{ic|/usr/share/fonts}}, so you just link the fonts to that directory: | |||
<syntaxhighlight lang="nix"> | |||
{ | |||
dockerTools, | |||
chromium, | |||
fontconfig, | |||
maple-mono, | |||
bashNonInteractive, | |||
... | |||
}: | |||
dockerTools.streamLayeredImage { | |||
name = "chromium"; | |||
tag = "latest"; | |||
contents = [ | |||
chromium | |||
fontconfig.out # The default .bin output only contains binaries | |||
# Fontconfig already contains a minimal set of DejaVu fonts, adding extra | |||
# fonts is optional | |||
maple-mono.NF | |||
]; | |||
# This part is only necessary if you're adding extra fonts | |||
fakeRootCommands = '' | |||
#!${bashNonInteractive} | |||
mkdir -p usr/share | |||
ln -s /share/fonts usr/share/fonts | |||
''; | |||
} | |||
</syntaxhighlight> | |||
Chrome will then be able to discover the DejaVu and Maple Mono NF fonts through fontconfig. | |||
If you instead want to use fonts from the {{nixos:package|texlivePackages}} package set, you'll need to symlink the {{ic|/fonts}} directory instead of {{ic|/share/fonts}} as the texlive packages have a different structure: | |||
<syntaxhighlight lang="nix"> | |||
{ | |||
dockerTools, | |||
chromium, | |||
fontconfig, | |||
texlivePackages, | |||
bashNonInteractive, | |||
... | |||
}: | |||
dockerTools.streamLayeredImage { | |||
name = "chromium"; | |||
tag = "latest"; | |||
contents = [ | |||
chromium | |||
fontconfig.out | |||
texlivePackages.opensans | |||
]; | |||
fakeRootCommands = '' | |||
#!${bashNonInteractive} | |||
mkdir -p usr/share | |||
ln -s /fonts usr/share/fonts | |||
''; | |||
} | |||
</syntaxhighlight> | |||
[[Category:Applications]] | [[Category:Applications]] | ||
[[Category:Web Browser{{#translation:}}]] | [[Category:Web Browser{{#translation:}}]] | ||