diff --git a/flake.nix b/flake.nix index 4750b721b4c196c522920216626ff4fa23a11b42..8b6ab9e1c7ecd2a0e38a80d63632c97203b804b6 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,7 @@ name = "generator"; version = "0.0.0"; src = ./src/index.html; + src-font = ./src/font; dontUnpack = true; buildPhase = '' cp ${src} index.html @@ -26,15 +27,15 @@ "$(base64 -w0 ${svg_templates}/logo_small_template.svg)" ''; installPhase = '' - mkdir -p $out $out/img $out/font + mkdir -p $out $out/img $out/font $out/js cp index.html $out/index.html - cp ${google_fonts}/ofl/notosansjp/NotoSansJP-Black.otf $out + cp ${opentype_js} $out/js/opentype.min.js + cp ${favicon}/favicon.svg ${favicon}/favicon.png $out/img # bundle the Genos-Bold font, since opentype.js can't work with the # variable-width version that's included in google fonts - cp ${./Genos-Bold.ttf} $out/Genos-Bold.ttf - cp ${opentype_js} $out/opentype.min.js - cp ${favicon}/favicon.svg ${favicon}/favicon.png $out/img - cp ${google_fonts}/ufl/ubuntumono/UbuntuMono-Regular.ttf ${google_fonts}/ufl/ubuntu/Ubuntu-Regular.ttf ${google_fonts}/ufl/ubuntu/Ubuntu-Bold.ttf $out/font + cp ${google_fonts}/ufl/ubuntumono/UbuntuMono-Regular.ttf ${google_fonts}/ufl/ubuntu/Ubuntu-Regular.ttf ${google_fonts}/ufl/ubuntu/Ubuntu-Bold.ttf \ + ${google_fonts}/ofl/notosansjp/NotoSansJP-Black.otf ${src-font}/Genos-Bold.ttf \ + $out/font ''; }; favicon = pkgs.stdenv.mkDerivation rec { diff --git a/Genos-Bold.ttf b/src/font/Genos-Bold.ttf similarity index 100% rename from Genos-Bold.ttf rename to src/font/Genos-Bold.ttf diff --git a/src/index.html b/src/index.html index f785d0715fddaf1398be47e76e526f86ec690a05..11f6afe1a2e16543be978997ea0163ce7424b8d9 100644 --- a/src/index.html +++ b/src/index.html @@ -263,11 +263,11 @@ } } </style> - <script src="./opentype.min.js"></script> + <script src="js/opentype.min.js"></script> <script> onhtmlload = () => { - opentype.load('./NotoSansJP-Black.otf', (err, notosans) => - opentype.load("./Genos-Bold.ttf", (err, genos) => main(genos, notosans))) + opentype.load('font/NotoSansJP-Black.otf', (err, notosans) => + opentype.load("font/Genos-Bold.ttf", (err, genos) => main(genos, notosans))) }; main = (genos, notosans) => { @@ -360,9 +360,8 @@ // we don't have any alignment, so center the text by hand let centered_text_path = (font, text, y, fontsize) => { let box = font.getPath(text, 0,0, fontsize).getBoundingBox(); - // 70 mm was eyeballed as "half the width of the svg" since I have - // no idea how to convince inkscape it shouldn't give units in pixels - return font.getPath(text, 70-box.x2/2, y, fontsize).toSVG(); + // 67.73333 mm is half the width of the svg + return font.getPath(text, 67.73333-box.x2/2, y, fontsize).toSVG(); } // Set the big headline (this id is the <g> tag of the default font,