From 560e626a88a9d73a28ae5fafcc436edf47c1b4e2 Mon Sep 17 00:00:00 2001 From: tilcreator <tilcreator@tc-j.de> Date: Sat, 12 Mar 2022 02:14:56 +0100 Subject: [PATCH] Cleanup a bit no real functional changes --- flake.nix | 13 +++++++------ Genos-Bold.ttf => src/font/Genos-Bold.ttf | Bin src/index.html | 11 +++++------ 3 files changed, 12 insertions(+), 12 deletions(-) rename Genos-Bold.ttf => src/font/Genos-Bold.ttf (100%) diff --git a/flake.nix b/flake.nix index 4750b72..8b6ab9e 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 f785d07..11f6afe 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, -- GitLab