NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.14k stars 13.42k forks source link

Iosevka: missing webfonts #182465

Open pinpox opened 2 years ago

pinpox commented 2 years ago

Describe the bug

Not strictly a bug, but other types of issue didn't fit. The iosevka package is missing the webfont and has no option to include it

Steps To Reproduce

Steps to reproduce the behavior:

  1. build the iosevka package
  2. Look at the files inside

Expected behavior

Either have the webfont files included per default or include them optionally

Additional context

The font is build here using this command

npm run build --no-update-notifier -- --jCmd=$NIX_BUILD_CORES ttf::$pname >/dev/null

To include the other formats like the webfont variant, the command would have to be:

npm run build --no-update-notifier -- --jCmd=$NIX_BUILD_CORES contents::$pname >/dev/null

There are even more variants documented here but I think the option to include all of them with contents::.. would be useful. My usecase is using the webfont as part of building a static blog.

Notify maintainers

@cstrahan @jfrankenau @ttuegel @babariviere @rileyinman @AluisioASG

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.


[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.53, NixOS, 22.11 (Raccoon), 22.11.20220714.8591f14`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.9.1`
 - channels(root): `""`
 - channels(pinpox): `"home-manager"`
 - nixpkgs: `/nix/store/xd5ma751ipnmx4vfli808rl1gsc6gp0y-source````
toastal commented 2 years ago

Personally, I would prefer to see ttf-iosevka and woff2-iosevka (but for all fonts). From the OS perspective, webfonts are not ideal or useful. And on the web, due to size, you should probably only serve up *.woff2 files (as of writing)--all other formats are too large to ethically serve to users (i.e. *.ttf, *.otf, *.woff). As such, I don't know that there's a use case I as a user would want both traditional and web formats together.

If it helps, I've been using a function like

mkWOFF2From = { name, pkg, ext }: pkgs.stdenvNoCC.mkDerivation {
    name = "${name}-woff2";
    nativeBuildInputs = [ pkgs.fontforge pkg ];
    dontInstall = true;
    unpackPhase = ''
        WOFF2_DIR="$out/share/fonts/woff2/"
        mkdir -p "$WOFF2_DIR"
        for file in ${pkg}/share/fonts/truetype/*.${ext}; do
            NAME="$(basename $file .${ext})"
            fontforge --lang=ff \
                -c 'Open($1); Generate($2);' \
                "$file" \
                "$WOFF2_DIR/$NAME.woff2"
        done
    '';
};
pinpox commented 2 years ago

Why is there a need for a custom function? Since the build command of iosevka (linked above) can be customized to output any selection of the desired formats, I don't see why it would hurt to add the choice with a sensible default.

Since we are passing parmaters with defaults already here in the package it seems like a simple solution to add a outputFormats option or simlilar that can be any of the formats described in the iosevka customized build options (contents, ttf, ttf-unhinted, webfont, etc.) and using it here instead of hard-coding ttf.

toastal commented 2 years ago

I don't see why it would hurt to add the choice with a sensible default.

Oh, I don't disagree. TTF is likely a best default. I would only be wary of building WOFF2 for user's desktop systems too. I believe some of the fonts in Nixpkgs do build at multiple types which wastes quite a bit of space on the machine.

ncfavier commented 1 year ago

I think this might be a good use case for split-output derivations? Leave traditional fonts in out and put web fonts in a separate woff2 output?

EDIT: apparently the place for such a discussion would be https://github.com/NixOS/nixpkgs/pull/91518, which seems dead

toastal commented 1 year ago

If it were me, I'd love to see fonts.iosevka and webfonts.iosevka or something like this.