Commit d9701137 authored by Pol Dellaiera's avatar Pol Dellaiera
Browse files

roboto: 2.138 -> 3.011, switch to variable version

The old repository (https://github.com/google/roboto) has been archived by Google.
parent 48f6c520
Loading
Loading
Loading
Loading
+13 −28
Original line number Diff line number Diff line
@@ -2,52 +2,37 @@
  lib,
  stdenvNoCC,
  fetchzip,
  python3Packages,
}:

stdenvNoCC.mkDerivation rec {
stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "roboto";
  version = "2.138";
  version = "3.011";

  src = fetchzip {
    url = "https://github.com/google/roboto/releases/download/v${version}/roboto-unhinted.zip";
    url = "https://github.com/googlefonts/roboto-3-classic/releases/download/v${finalAttrs.version}/Roboto_v${finalAttrs.version}.zip";
    stripRoot = false;
    hash = "sha256-ue3PUZinBpcYgSho1Zrw1KHl7gc/GlN1GhWFk6g5QXE=";
    hash = "sha256-Ko5x4zn/bhrFLuYktaAsqsWUsIOMfnxK8rZ4UiqK8ds=";
  };

  nativeBuildInputs = [
    python3Packages.fonttools
  ];

  installPhase = ''
    runHook preInstall

    # The RobotoCondensed fonts have a usWidthClass value of 5, which is
    # incorrect. It should be 3.
    # See the corresponding issue at https://github.com/googlefonts/roboto-3-classic/issues/130
    for file in RobotoCondensed*; do
      fontname=$(echo $file | sed 's/\.ttf//')
      ttx -v -o $fontname.xml $file
      substituteInPlace $fontname.xml \
        --replace-fail "<usWidthClass value=\"5\"/>" "<usWidthClass value=\"3\"/>"
      ttx --no-recalc-timestamp $fontname.xml -o $fontname.ttf
    done

    install -Dm644 *.ttf -t $out/share/fonts/truetype
    install -Dm644 unhinted/static/*.ttf -t $out/share/fonts/truetype

    runHook postInstall
  '';

  meta = {
    homepage = "https://github.com/google/roboto";
    description = "Roboto family of fonts";
    homepage = "https://github.com/googlefonts/roboto-3-classic";
    description = "This is a variable version of Roboto intended to be a 1:1 match with the official non-variable release from Google";
    longDescription = ''
      Google’s signature family of fonts, the default font on Android and
      Chrome OS, and the recommended font for Google’s visual language,
      Material Design.
      This is not an official Google project, but was enabled with generous
      funding by Google Fonts, who contracted Type Network. The Roboto family of
      instances contained 6 weights and two widths of normal, along with italic
      of the regular width.
    '';
    license = lib.licenses.asl20;
    license = lib.licenses.ofl;
    platforms = lib.platforms.all;
    maintainers = [ lib.maintainers.romildo ];
  };
}
})