diff --git a/.gitignore b/.gitignore index b2be92b7db01b7bfebb8e0aabd2f546906ff651a..fcfc4a1b5c57316c0a2ec8f062ba7a1fc4cf3617 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -result +result* diff --git a/README.md b/README.md index 30efceb5e88517cc2eba6dabe654c93b91c977c9..59fc8ffbd2f6f3a1ee63c89b45305b0b652cc52e 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 3692152925b0d02fc9686724a507eeb04d7aaec6..2ec1f709592a9e307d5cfb2b1cf0041c7b1894c5 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 4179e282ce3f3c816f1af839703aef9e4e0b9380..9dfeb04de0353207ada0f6f4c89e5babb9d6be38 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 96d9f802f41c8a06f4ba0f42b2cf7f3f6ee16df2..f78cb0d05f982da496b6df3f5ad316329d5d2653 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