How to set custom fonts with identical names but different styles?

errm, hello guys! :grinning_cat:

am noob, me stuck, i has many font-related questions: what must one do to have a custom font for… oh, i dunno, this option (for example):

boot.loader.grub.font

what does the "${pkgs.grub2}/share/grub/unicode.pf2" default stand for..? i guess.. the ${pkgs.grub2} part is an alias (?) to/for /nix/store/*? thats convenient! if only i could read manuals and knew exactly what is it that i am looking at is called, ah… :sob: could it be a package variable, mayhaps..? i mean, it has a $ character, so… yeah, i would have used which and realpath (idek how to use the latter, nvm)… i really dont know how this works, lemme demonstrate the extent of my unknowledge:

$ which grub2

which: no grub2 in (/run/wrappers/bin:
/home/frog/.nix-profile/bin:
/nix/profile/bin:
/home/frog/.local/state/nix/profile/bin:
/etc/profiles/per-user/frog/bin:
/nix/var/nix/profiles/default/bin:
/run/current-system/sw/bin)

(edited to made it look readable and pretty)
(same goes for just which grub)

its looking in the $PATH (i think? although i still dont know what are those profile paths, should they exist if i use flakes anyway..?), but it found nothing… ugh, im gonna get laughed at this, but i just forgor. i just forgot how to use this… help… i wanna know moar about (configuring) fonts (on nixos)! so, um, what is there to know, where to read, which commands to type in..? as in, uh, how does one check and use such ${pkgs.PKG} thingies..? so far ive spotted only a few such options with such strings (?), for example:

boot.loader.grub.font (boot.loader.grub.enable of which i do have and set to true)

console.font

boot.plymouth.font

but most interesting of them all is this one:

services.kmscon.fonts

one can both set a font package AND set the font name FROM the installed font package. man, if only something like this was in fonts.fontconfig.defaultFonts.*although… this, too, wouldnt help with my issue: picking a font that has an identical name, but different style! am i crazy? is this, like, too much obscure to be accessible??? :sob:

blah… that was basically my first question… yeah…

question numero dos:

i wanna set a global (system-wide) font, so that ANY application can immediately apply it, BUT there are some font packages that have the same font names but different font styles, for example:

pkgs.unscii

$ fc-list unscii

/nix/store/...-unscii-2.1/share/fonts/misc/unscii-8-alt.pcf.gz: Unscii:style=alt
/nix/store/...-unscii-2.1/share/fonts/misc/unscii-8-thin.pcf.gz: Unscii:style=thin
/nix/store/...-unscii-2.1/share/fonts/opentype/unscii-8-mcr.otf: unscii:style=8-mcr
/nix/store/...-unscii-2.1/share/fonts/opentype/unscii-8-tall.otf: unscii:style=8-tall
/nix/store/...-unscii-2.1/share/fonts/opentype/unscii-16-full.otf: unscii:style=16-full
/nix/store/...-unscii-2.1/share/fonts/misc/unscii-8-tall.pcf.gz: Unscii:style=tall
/nix/store/...-unscii-2.1/share/fonts/misc/unscii-16.pcf.gz: Unscii:style=16
/nix/store/...-unscii-2.1/share/fonts/opentype/unscii-16.otf: unscii:style=16
/nix/store/...-unscii-2.1/share/fonts/opentype/unscii-8-alt.otf: unscii:style=8-alt
/nix/store/...-unscii-2.1/share/fonts/misc/unscii-8-fantasy.pcf.gz: Unscii:style=fantasy
/nix/store/...-unscii-2.1/share/fonts/opentype/unscii-8-thin.otf: unscii:style=8-thin
/nix/store/...-unscii-2.1/share/fonts/misc/unscii-8.pcf.gz: Unscii:style=8
/nix/store/...-unscii-2.1/share/fonts/misc/unscii-16-full.pcf.gz: Unscii:style=full
/nix/store/...-unscii-2.1/share/fonts/misc/unscii-8-mcr.pcf.gz: Unscii:style=mcr
/nix/store/...-unscii-2.1/share/fonts/opentype/unscii-8.otf: unscii:style=8
/nix/store/...-unscii-2.1/share/fonts/opentype/unscii-8-fantasy.otf: unscii:style=8-fantasy
$ fc-match -a unscii

unscii-16-full.otf: "unscii" "16-full"
unscii-16.otf: "unscii" "16"
unscii-8-alt.otf: "unscii" "8-alt"
unscii-8-fantasy.otf: "unscii" "8-fantasy"
unscii-8-mcr.otf: "unscii" "8-mcr"
unscii-8-tall.otf: "unscii" "8-tall"
unscii-8-thin.otf: "unscii" "8-thin"
unscii-8.otf: "unscii" "8"
unscii-16-full.pcf.gz: "Unscii" "full"
unscii-16.pcf.gz: "Unscii" "16"
unscii-8-tall.pcf.gz: "Unscii" "tall"
unscii-8-alt.pcf.gz: "Unscii" "alt"
unscii-8-fantasy.pcf.gz: "Unscii" "fantasy"
unscii-8-mcr.pcf.gz: "Unscii" "mcr"
unscii-8.pcf.gz: "Unscii" "8"
unscii-8-thin.pcf.gz: "Unscii" "thin"
...

or worse: both the names AND styles are identical, except font(‘)(s)(’) FILE names (paths?):

pkgs.monocraft

$ fc-list monocraft

/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=Bold
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=SemiBold-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=Regular
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=Black
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=Regular
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=Light
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=ExtraLight-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=Black
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=SemiBold
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=Bold-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=Black-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=Light-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=SemiBold-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=Bold-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=Light-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=Black-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=Bold
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=SemiBold
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=Light-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=Black-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=SemiBold
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=SemiBold-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=ExtraLight-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=ExtraLight
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=Black
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=Light
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=Light
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=Regular
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=Bold
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=Bold-Italic
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft.ttc: Monocraft:style=ExtraLight
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-nerd-fonts-patched.ttc: Monocraft:style=ExtraLight
/nix/store/...-monocraft-4.2.1/share/fonts/truetype/...-Monocraft-no-ligatures.ttc: Monocraft:style=ExtraLight-Italic

(where the second ... is actually RANDOM this time!)

ok! the question is: how does one make a SPECIFIC font to be global - everywhere where it can bee (bzz!) (cos there are certain apps that have baked-in fonts with stupid chud DejaVu Sans defaults that i just want to physically rip out, ugh!..)?

sorry, lemme rephrase this: for example, i want these:

unscii-8.otf: "unscii" "8"
...-Monocraft-no-ligatures.ttc: "Monocraft" "SemiBold"

(sic! notice that "Monocraft" .ttc font has an RNG path/thingie prepended to it, whereas unscii .otf does not! i dunno why that is???)

so, NOT nerd-fonts (or patched), WITHOUT ligatures, "8" (unscii-8, .otf) and/or "SemiBold" (for unscii and monocraft packages respectively), declaratively, the nixos way, without creating some imperative local fontconfig’s, without resorting to use pkgs.qt*ct and/or pkgs.nwg-look and stuff like that… well, heh, if you thought it would be this simple:

  fonts.fontconfig.defaultFonts.* = [ # by "*" i mean any of them, really...
    # "Monocraft SemiBold" # systemctl poweroff
    # "Monocraft" "SemiBold" # bro...
  ];

…then you would be WRONG!!! sorry, i know you probably saw this a kilometre (1000 metres) away… dont mind me haha! (as for me, its very difficult to see what im typing now that my fonts are all messed up… actually, now that i think about it, i literally cant read anything that isnt a legible monospaced font… not as in render-wise, no, i just simply prefer, i would like a certain font to be applied in every app, thats right, using mono fonts in serif and sans-serif places!

right… so that one didnt work out. i shall try the .otf one! (cos .pcf’s are for TTY’s, yeah? oh, wait, its an X11 font format??? y-yeah… .otf it is, then!). help me, official nixos wikipedia, the free online encyclopedia that anyone can edit..? okay. thank you, wiki.nixos.org! so, now i have this font thusly:

firstly, i install:

  fonts.packages = [
    pkgs.unscii
  ];

secondly, i look for a specific font name that i want with the fc-match -a unscii (that i already used above), to just get the name (after :):

unscii-8.otf: "unscii" "8"

tertiarily, i set that font name to make it system-wide (supposedly):

  fonts.fontconfig.defaultFonts.monospace = [ # just so i could sort by type, perchance?
    "unscii" # < clueless
  ];

quadripily, i check which font is now mono:

$ fc-match monospace

unscii-16-full.otf: "unscii" "16-full"

ok, so, apparently, it (still) defaults to unscii-16-full.otf with the unscii:style=16 style… somehow, after having tried many other ways… uhh, how is this decided, exactly? and, more importantly, how do i actually choose then, how do i set a different one from the same font package and/or font family, which are all identical?

configuration.nix

  fonts.packages = [
    pkgs.unscii
  ];
  fonts.fontconfig.defaultFonts.monospace = [
    # "unscii" # LOUD INCORRECT BUZZER!  
    # "Unscii" # REALLY? TRY "-i" LOL
    # "unscii-8" # HOW ABOUT NO.
    # "unscii 8" # WRONG, WRONG && WRONG!!!1
    # "unscii-8.otf" # ...
    # "unscii:style=8" # WASTED! JOB FAILED!
  ];

(very simplified example btw)
(i tried everything, except absolute paths, but do they even work in a list of string?)
(also insert nixos-rebuild switch somewhere in between those steps above where i forgot to mention that i update every picosecond as if i was quick saving in a game)

…yeah. none of the above works. it still defaults to either:

...-Monocraft.ttc: "Monocraft" "Regular"
unscii-16-full.otf: "unscii" "16-full"

or the notorious:

DejaVuSans.ttf: "DejaVu Sans" "Book"

(that i have yet to figure out where does it come from…)

but then i got overwhelmed by trying to figure this out, so here is my third and (hopefully) last question of mine:

how does one DELETE this terrible, horrible DejaVu font??? and so i checked with pkgs.nix-tree (idk any other way lol) and i found that its dependancies are as follows:

...-dejavu-fonts-minimal-2.37

Immediate Parents (5):

fontconfig-2.17.1
fc-cache
steam-run-1.0.0.85-fhsenv-rootfs
steam-1.0.0.85-fhsenv-rootfs
fontconfig-2.17.1-lib

okay… what must one do in (presumably) this option here?:

programs.steam.fontPackages

…to remove the DejaVu font(s)..? entirely from the system (again, presumably?)? aaanyway, im gonna experiment with lib.mkForce in a minute, but… i just dont know what im doing. should i really do it all imperatively (temporarily)? err…

it would have been (probably) easier if, for instance, fonts.fontconfig.defaultFonts.* were of type list of string or package or absolute path or something like that, you know what i mean..? or, better yet, like that kmscon font option i noticed above? wouldve been perfect. but again, i just dont know the answer to the first question, how to substitute (or shorten) the, uh, ${pkgs.PKG} absolute paths for some nixos (mostly font-related) options… is any of this possible and/or worth it, guys? my eyes are just so tired from staring at non-pixelated non-monospaced fonts… and so i read and searched, but ultimately found :frog: all on the internet… sorry! :sweat_smile: orrr maybe i just dont know how fonts work..? :sob: (i dont)

edit1: ooh! and, by the way, uhh, shouldnt there also be a fonts.fontconfig.defaultFonts.proportional option… question mark??? i dont use any propo fonts myself, but this letterform is now an option, for example, in literally any web browser: if you go to options, then fonts, you could see that a proportional font is… unset, but it is there and it appears to default to Serif fonts! because, um, nixos doesnt have this option..? its not a problem for me, my selected fonts are still rendered fine, but i just wanna know if this is… a thing that can be configured? there are, actually, font family/typeface packages with propo font names that anyone CAN already choose in *.defaultFonts.* already, but again, that would apply only to serif and sans-serif letterforms, but uhh yeah

edit2: sry i may or may not ask a fourth (4!!!) question (but later) about emoji fonts (i recently found this pixel emoji font called pkgs.serenityos-emoji-font, but i think its not rendering correctly even with fonts.fontconfig.useEmbeddedBitmaps???), cos some of them are ignored and mixed with some other default / built-in emoji fonts, or are completely invisible… EDIT1: eugh i just found out that serenityos is from the devs of ladybird… EDIT2: even worse, the emoji characters seem to be “shifted” by one, uh, i dont know the technical term, but, for example, a red heart appears as a “mended / bandaged heart” emoji, which is one character before the red heart character…? idk, it could be a per-app setting or something… ughhh, this is seriously the biggest issue i have ever faced in linux, in general - FONTS! nixos made this much easier and simple than in any other distro, true, but its pretty much still a linux issue, right? its just the most craziest, most difficultest obstacle for me… :sob: but i found that nixos could still… ehh, it still could be… made more easy, yknow? it shouldnt be this hard to just… applying fonts. does anyone else find applying fonts in linux hard or is it just me..?

edit3: ooooh and before i forget, does one have to actually use the fc-cache command, like, ever..? or does nixos do it by itself when a user is tinkering with font options on every rebuild..? :melting_face: cos i remember i forcefully scanned the font caches that one time and… my system was super slow then, apps were just freezing and becoming unresponsive, (i assume) just cos something tried to render some unknown characters/symbols/corrupted fonts..? it then magically fixed itself after a reboot (iirc?), so… yeah, lots of things to learn. but hey. im on my 2500th+ generation, so all is well, ominous smiley face. no, really, i wanna know how to set all of those fonts… :sob:

thank you in advance!! :zany_face: i hope i phrased this wall of text alright, cos i cant usually even finish a sentence… and i hope that i provided enough information! even though i feel like i missed something obvious..

If you really want help you need to be way shorter on your message. I doubt someone wants to read that much to understand what you want certainly I don’t.

If you want to set fonts in one place you might want to have a look at: Introduction - Stylix

3 Likes