From 6df083322e851eaa8bd00d57d8dcd6d110dcb26b Mon Sep 17 00:00:00 2001 From: tilcreator <tilcreator@tc-j.de> Date: Wed, 9 Mar 2022 17:09:09 +0100 Subject: [PATCH] Add included fonts --- .gitignore | 2 +- README.md | 9 ++- flake.nix | 76 ++++++++++++++----- src/index.html | 2 +- src/{ => svg_templates}/logo_big_template.svg | 18 ++++- .../logo_small_template.svg | 0 6 files changed, 81 insertions(+), 26 deletions(-) rename src/{ => svg_templates}/logo_big_template.svg (96%) rename src/{ => svg_templates}/logo_small_template.svg (100%) diff --git a/.gitignore b/.gitignore index b2be92b..fcfc4a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -result +result* diff --git a/README.md b/README.md index 30efceb..59fc8ff 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ # Divoc BB3 logo generator This generator is meant to provide an easy way to generator BB3 style logos/user pictures. If one needs something more complex, both logo templates in src are nicely editable in Inkscape. ## TODO -- [ ] Include fonts in svgs +- [ ] Modify Genos font, so that the i looks right? - [ ] Apply official stying - [ ] Add more animals - [ ] Add more accent / background colors - [ ] Where to host? ## Build from source `$ nix --extra-experimental-features flakes build` -(legacy: `$ nix-build`) +### legacy +`$ nix-build` +### In a config (legacy) +```nix +(import (pkgs.fetchFromGitLab {domain = "git.cccv.de"; owner = "TilCreator"; repo = "divoc-bb3-logo-generator"; rev = "..."; sha256 = "...";})).default +``` diff --git a/flake.nix b/flake.nix index 3692152..2ec1f70 100644 --- a/flake.nix +++ b/flake.nix @@ -10,26 +10,62 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in rec { - packages.generator = pkgs.stdenv.mkDerivation rec { - name = "generator"; - version = "0.0.0"; - src = ./src; - buildPhase = '' - ${pkgs.inkscape}/bin/inkscape --export-type=png favicon.svg - - # TODO Add fonts - - substituteInPlace index.html \ - --replace "@SVG_BIG_TEMPLATE@" \ - "$(base64 -w0 logo_big_template.svg)" - substituteInPlace index.html \ - --replace "@SVG_SMALL_TEMPLATE@" \ - "$(base64 -w0 logo_small_template.svg)" - ''; - installPhase = '' - mkdir -p $out - cp index.html favicon.svg favicon.png $out/ - ''; + packages = rec { + generator = pkgs.stdenv.mkDerivation rec { + name = "generator"; + version = "0.0.0"; + src = ./src/index.html; + dontUnpack = true; + buildPhase = '' + cp ${src} index.html + substituteInPlace index.html \ + --replace "@SVG_BIG_TEMPLATE@" \ + "$(base64 -w0 ${svg_templates}/logo_big_template.svg)" + substituteInPlace index.html \ + --replace "@SVG_SMALL_TEMPLATE@" \ + "$(base64 -w0 ${svg_templates}/logo_small_template.svg)" + ''; + installPhase = '' + mkdir -p $out + cp index.html $out/index.html + cp ${favicon}/favicon.svg ${favicon}/favicon.png $out/ + ''; + }; + favicon = pkgs.stdenv.mkDerivation rec { + name = "favicon"; + version = "0.0.0"; + src = ./src/favicon.svg; + dontUnpack = true; + buildPhase = "${pkgs.inkscape}/bin/inkscape --export-type=png -o ./favicon.png ${src}; pwd; ls -la"; + installPhase = '' + mkdir -p $out + cp ${src} $out/favicon.svg + cp favicon.png $out/ + ''; + }; + svg_templates = pkgs.stdenv.mkDerivation rec { + name = "generator"; + version = "0.0.0"; + src = ./src/svg_templates; + google_fonts = pkgs.fetchFromGitHub { + owner = "google"; + repo = "fonts"; + rev = "2fba0d68602b7eb3374d030c1c34939de56023f9"; + sha256 = "sha256-IFkKwRRyZeOXD8/9n8UDrruUKK6oQK4BD9wYN2dmSAc="; + }; + buildPhase = '' + substituteInPlace logo_big_template.svg \ + --replace "@GENOS_FONT@" \ + "$(base64 -w0 ${google_fonts}/ofl/genos/Genos\[wght\].ttf)" + substituteInPlace logo_big_template.svg \ + --replace "@NOTO_SANS_JP_FONT@" \ + "$(base64 -w0 ${google_fonts}/ofl/notosansjp/NotoSansJP-Black.otf)" + ''; + installPhase = '' + mkdir -p $out + cp logo_big_template.svg logo_small_template.svg $out/ + ''; + }; }; defaultPackage = packages.generator; } diff --git a/src/index.html b/src/index.html index 4179e28..9dfeb04 100644 --- a/src/index.html +++ b/src/index.html @@ -236,7 +236,7 @@ <h2>Text</h2> <div class="table"> <label for="headline_text">Headline</label> - <input type="text" id="headline_text" value="Divoc"/> + <input type="text" id="headline_text" value="DiVOC"/> </div> <div> <div class="katakana" id="headline_katakana" for="headline_text"> diff --git a/src/logo_big_template.svg b/src/svg_templates/logo_big_template.svg similarity index 96% rename from src/logo_big_template.svg rename to src/svg_templates/logo_big_template.svg index 96d9f80..f78cb0d 100644 --- a/src/logo_big_template.svg +++ b/src/svg_templates/logo_big_template.svg @@ -14,6 +14,20 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> + <style> + @font-face { + font-family: "Genos"; + src: url('data:font/sfnt;base64,@GENOS_FONT@') format('truetype'); + font-weight: bold; + font-style: normal; + } + @font-face { + font-family: "Noto Sans JP"; + src: url('data:application/vnd.ms-opentype;base64,@NOTO_SANS_JP_FONT@') format("opentype"); + font-weight: 900; + font-style: normal; + } + </style> <sodipodi:namedview id="namedview1229" pagecolor="#505050" @@ -161,10 +175,10 @@ y="107.12258" id="text111095"><tspan sodipodi:role="line" - style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Genos;-inkscape-font-specification:'Genos Bold';text-align:center;text-anchor:middle;fill:#ffebd8;fill-opacity:1;stroke-width:0.441811" + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'Genos';-inkscape-font-specification:'Genos Bold';text-align:center;text-anchor:middle;fill:#ffebd8;fill-opacity:1;stroke-width:0.441811" x="67.327217" y="107.12258" - id="headline">DIVOC</tspan></text> + id="headline">DiVOC</tspan></text> </g> <g inkscape:groupmode="layer" diff --git a/src/logo_small_template.svg b/src/svg_templates/logo_small_template.svg similarity index 100% rename from src/logo_small_template.svg rename to src/svg_templates/logo_small_template.svg -- GitLab