# SPDX-FileCopyrightText: 2025 toastal <toastal@posteo.net>
# SPDX-License-Identifier: MPL-2.0
{
  lib,
  parallel,
  linkFarm,
  runCommand,
  fontforge,
  mplus-outline-fonts,
}:

let
  inherit (import ../utils.nix { inherit lib parallel; }) beparallel;
in
runCommand "mplus-webfonts"
  {
    nativeBuildInputs = [ fontforge ];
  }
  ''
    mkdir -p "$out"
    find "${mplus-outline-fonts.githubRelease}/share/fonts/" \( -iname "Mplus2*.otf" -o -iname "MplusCode60*.otf" \) \
      | ${beparallel ''fontforge --lang=ff -c 'Open($1); Generate($2);' {} $out/{/.}.woff2''}
  ''
