Repository navigation
Closed
Labels
6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Description
I am trying to set IPA proportional fonts for Japanese serif & sans-serif, but it seems that fonts set via fonts.defaultFonts are not matched by fc-match.
configuration.nix:
fonts = {
fonts = [
pkgs.ipafont
pkgs.powerline-fonts
pkgs.baekmuk-ttf
];
fontconfig.defaultFonts = {
serif = [
"DejaVu Serif"
"IPAPMincho"
"Baekmuk Batang"
];
sansSerif = [
"DejaVu Sans"
"IPAPGothic"
"Baekmuk Dotum"
];
monospace = [
"DejaVu Sans Mono for Powerline"
"IPAGothic"
"Baekmuk Dotum"
];
};
};
/etc/fonts/conf.d/98-nixos.conf & /etc/fonts/2.11/conf.d/98-nixos.conf are correctly generated:
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<!-- Default rendering settings -->
<match target="font">
<edit mode="assign" name="hinting">
<bool>true</bool>
</edit>
<edit mode="assign" name="autohint">
<bool>true</bool>
</edit>
<edit mode="assign" name="hintstyle">
<const>hintfull</const>
</edit>
<edit mode="assign" name="antialias">
<bool>true</bool>
</edit>
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
<edit mode="assign" name="lcdfilter">
<const>lcddefault</const>
</edit>
</match>
<!-- Default fonts -->
<alias>
<family>sans-serif</family>
<prefer>
<family>DejaVu Sans</family>
<family>IPAPGothic</family>
<family>Baekmuk Dotum</family>
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>DejaVu Serif</family>
<family>IPAPMincho</family>
<family>Baekmuk Batang</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>DejaVu Sans Mono for Powerline</family>
<family>IPAGothic</family>
<family>Baekmuk Dotum</family>
</prefer>
</alias>
</fontconfig>
but fc-match seems to ignore it:
> fc-cache -r
> fc-match sans-serif -s ~
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSans-Bold.ttf: "DejaVu Sans" "Bold"
DejaVuSans-Oblique.ttf: "DejaVu Sans" "Oblique"
DejaVuSans-BoldOblique.ttf: "DejaVu Sans" "Bold Oblique"
LiberationSans-Regular.ttf: "Liberation Sans" "Regular"
luxisr.ttf: "Luxi Sans" "Regular"
ipag.ttf: "IPAゴシック" "Regular"
dotum.ttf: "Baekmuk Dotum" "Regular"
gulim.ttf: "Baekmuk Gulim" "Regular"
FreeSans.ttf: "FreeSans" "нормален"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
DejaVuSerif-Bold.ttf: "DejaVu Serif" "Bold"
DejaVuSerif-Italic.ttf: "DejaVu Serif" "Italic"
DejaVuSerif-BoldItalic.ttf: "DejaVu Serif" "Bold Italic"
FreeMono.ttf: "FreeMono" "нормален"
FreeSerif.ttf: "FreeSerif" "нормален"
FuraMono-Regular Powerline.otf: "Fira Mono for Powerline" "Regular"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
luximr.ttf: "Luxi Mono" "Regular"
Anonymice Powerline.ttf: "Anonymous Pro for Powerline" "Regular"
Ubuntu Mono derivative Powerline.ttf: "Ubuntu Mono derivative Powerline" "Regular"
LiberationSerif-Italic.ttf: "Liberation Serif" "Italic"
7x13-ISO8859-1.pcf.gz: "Fixed" "Regular"
7x13.pcf.gz: "Fixed" "Regular"
8x13.pcf.gz: "Fixed" "Regular"
12x13ja.pcf.gz: "Fixed" "ja"
6x12.pcf.gz: "Fixed" "SemiCondensed"
6x13.pcf.gz: "Fixed" "SemiCondensed"
9x15.pcf.gz: "Fixed" "Regular"
18x18ja.pcf.gz: "Fixed" "ja"
10x20.pcf.gz: "Fixed" "Regular"
> fc-match serif -s
DejaVuSerif.ttf: "DejaVu Serif" "Book"
DejaVuSerif-Bold.ttf: "DejaVu Serif" "Bold"
DejaVuSerif-Italic.ttf: "DejaVu Serif" "Italic"
DejaVuSerif-BoldItalic.ttf: "DejaVu Serif" "Bold Italic"
LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
LiberationSerif-Italic.ttf: "Liberation Serif" "Italic"
ipam.ttf: "IPA明朝" "Regular"
luxirr.ttf: "Luxi Serif" "Regular"
batang.ttf: "Baekmuk Batang" "Regular"
FreeSerif.ttf: "FreeSerif" "нормален"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSans-BoldOblique.ttf: "DejaVu Sans" "Bold Oblique"
FreeMono.ttf: "FreeMono" "нормален"
FreeSans.ttf: "FreeSans" "нормален"
FuraMono-Regular Powerline.otf: "Fira Mono for Powerline" "Regular"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
luximr.ttf: "Luxi Mono" "Regular"
Anonymice Powerline.ttf: "Anonymous Pro for Powerline" "Regular"
Ubuntu Mono derivative Powerline.ttf: "Ubuntu Mono derivative Powerline" "Regular"
7x13-ISO8859-1.pcf.gz: "Fixed" "Regular"
7x13.pcf.gz: "Fixed" "Regular"
8x13.pcf.gz: "Fixed" "Regular"
12x13ja.pcf.gz: "Fixed" "ja"
6x12.pcf.gz: "Fixed" "SemiCondensed"
6x13.pcf.gz: "Fixed" "SemiCondensed"
9x15.pcf.gz: "Fixed" "Regular"
18x18ja.pcf.gz: "Fixed" "ja"
10x20.pcf.gz: "Fixed" "Regular"
- nixos-version: 15.07pre66213.9d5508d (Dingo)
- nix-channel: https://nixos.org/channels/nixos-unstable
Metadata
Metadata
Assignees
Labels
6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Activity
vcunat commentedon Aug 4, 2015
I'd try to find the cause with help of
$FC_DEBUG; see docs.vcunat commentedon Aug 4, 2015
BTW, is it possible that this is connected to perhaps font and/or fontconfig files not being immediately "visible" #9027? Have you rebooted after adding the fonts?
ericsagnes commentedon Aug 4, 2015
Thanks for the advices, I tried to reboot but it didn't help.
The IPA Font is present and japanese characters are displayed fine so it shouldn't be related to #9027 .
The problem I face is that by default the non proportional IPA fonts are used (the versions without P), but I would like to use the proportional versions instead.
Match Debug:
The fonts set in
fontconfig.defaultFontsappears quite at the end of the sort result ("DejaVu Sans"(w) "IPAPGothic"(w) "Baekmuk Dotum"(w)).So it seems that for some reason the settings in
98-nixos.confhave a lower priority than other setting files.Config files loaded:
Caching information:
IPA Fonts availability:
vcunat commentedon Aug 4, 2015
The first
fc-matchresult certainly seems consistent to me: you have DejaVu fonts as the first indefaultFonts, and that's whatfc-matchreturns. Evenfc-match :lang=jawill likely do so, as the fonts claim ja support.ericsagnes commentedon Aug 4, 2015
Deja Vu fonts first is correct, but the second entry in
fontconfig.defaultFonts.sansSerifIPAPGothic doesn't appear in the match list.As a test, I changed my
fontconfigoptions as below:The generated
/etc/fonts/2.11/conf.d/98-nixos.confis correct:But
fc-matchfor sans-serif still match DejaVu and there is no IPAPGothic in the results:Detailed output:
vcunat commentedon Aug 4, 2015
IPAPGothic is in your detailed list. Anyway, I don't know the exact semantics of fontconfig and I don't see it directly in the docs. I would think this font gets pruned (see the
-aparameter) because whatever additional font requirements you specify, DejaVu will be in front and shadowing it.ericsagnes commentedon Aug 4, 2015
After some research, it seems that priorities for families alias are set by the order of parsing conf files.
98-nixos.confbeing one of the last files read, its settings get the lowest priority.But there is a
bindingproperty that when set tostrongforces priority of configuration rules.I tried with a user defined
~/.config/fontconfig/fonts.confas below:And
fc-matchmatches correctly the preferred fonts:I suppose that adding
binding="strong"to thealiastags fordefaultFontsin https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/config/fonts/fontconfig.nix should make it work as expected for most of users. (what is the point to set default fonts if they have the lowest priority?)I am pretty new to NixOS and don't know yet how to make changes to local configuration modules.
If someone could point to some documentation or update https://nixos.org/wiki/NixOS_Modifying_Modules , I will be very happy to test the changes and submit a patch if it works as expected.
vcunat commentedon Aug 4, 2015
The docs give an explanation of what
bindingmeans:My understanding is that if we use a strong one, the first font in the
defaultFontslist will be used even if it doesn't support the requested language. That doesn't seem a good default behavior to me./cc @ttuegel: you seem to know more about this, judging from 9707ffd.
ttuegel commentedon Aug 4, 2015
Yes, that is correct. That would be inappropriate behavior for the default settings.
While the configuration files are parsed in order, that does not mean that later ones have lower priority. On the contrary, consider this, from the manual:
<alias>Alias elements provide a shorthand notation for the set of common match operations needed to
substitute one font family for another. They contain a
<family>element followed by optional<prefer>,<accept>and<default>elements. Fonts matching the<family>element are edited toprepend the list of
<prefer>ed families before the matching<family>, append the<accept>ablefamilies after the matching
<family>and append the<default>families to the end of the family list.We may need to move that config file. According to the
READMEthe standard ranges are:Therefore, it may be more appropriate to do these settings in
60-nixos-generic-aliases.conf. Moving the settings to a higher precedence would very likely solve this problem.nixos/fontconfig: separate rendering and alias configuration
ericsagnes commentedon Aug 4, 2015
Thanks!
Just to give some feedback, as a test, I tried to rename my
~/.config/fontconfig/fonts.confto~/.config/fontconfig/conf.d/60-nixos-generic-aliases.conf(removing thebinding="strong"attributes) butfc-matchfailed to match the proportional IPA fonts.In the same file, putting
binding="same"to thealiastag makesfc-matchmatch the proportional IPA fonts.Please ignore if it is not relevant information.
ttuegel commentedon Aug 4, 2015
The filename should only affect the order a file is loaded in compared to other files in the same directory. Though, come to think of it, that may hose my fix. I will have to think on this more.
If
binding="same"works, then probably some file that ships withfontconfigorfontconfig-ultimateis probably usingbinding="strong"where it should not.vcunat commentedon Aug 4, 2015
Yes, I'm afraid we might have a problem from the fact that within a single
conf.d/the file reading order is alphabetical, but we include several dirs and these aren't read "interleaved". I believe the split pushed now only changes order wrt. the "infinality" configs and not wrt. any upstream configs.To truly interleave the reading, we'd have to join our system
conf.dtrees, e.g. bybuildEnv. (However, I'm not yet certain if all should be joined, and it's probably impossible to join system and per-user config together.)ttuegel commentedon Aug 4, 2015
@vcunat
buildEnvmight be a little overkill; we really just want something likelndir. But that's the way we need to go for the system config files. Upstream intends that all the system files be interleaved. We don't need to worry about the user configuration, I think, as that isn't intended to be interleaved.vcunat commentedon Aug 4, 2015
User config: personally, I would expect that if I put some files into the user config instead of the system one, it will create the same result for that user. But that's probably just nitpicking ATM.
Another minor twist that got introduced: controlling the default font for a family by a file
conf.d/30-familyName.confinstalled with the fonts. #6793 That allows choosing among them also by standard nix-env priorities. I think interleaving isn't needed for those and it's enough to process them after the upstream config.ericsagnes commentedon Dec 18, 2015
Works perfectly, thanks!
Sorry for the late closing.