NixOS/nixos-artwork

Square logo?

ryantm opened this issue ยท 9 comments

I was surprised that the logo is very close to square but it is not square. Is this intentional? Would a logo revision that makes it square be welcome?

Can a regular hexagon fit snugly against all sides of a square? Maths says no! :) (At least, not without rotating it a a weird angle.)

Though, what do you mean, you want to see a logo file where the drawing area is square, with the logo appropriately centered?

What would be the use of such file? (It would help to know how it'd be used, I guess)

Yes, I was looking for the drawing area to be square.

I am trying to fix this warning message that Discourse keeps warning us about:
discourse_icon_warning

It is asking for a 512x512 px logo.

Well, I went ahead and extended the canvas in GIMP and uploaded it. It's weird that the icon directory Makefile generates a folder called 512x512, but the file inside is not that exact dimensions. Is that typical with icons?

Oh, I would assume it's not "right" to have a 512x512 (or ๐’™ร—๐’™) directory with non-squared images. Keep this open, with actionable task: make the Makefile generate square files.

I believe this is how the png images are generated for use on an installed NixOS system, good thing that apparently nothing fails when using non-square images here.

It does seem like the logo being non-square causes it to be unevenly rescaled on GNOME:
image
This is because the .svg is directly copied over into hicolor/scalable/apps/ alongside the converted .png versions. Perhaps we should consider either making the SVG square or converting it into a square one in icons/Makefile.

Sorry for unearthing this issue after three years by the way ๐Ÿ˜…

Don't be sorry, you're right. This isn't looking correct :)

I guess the quickest solution at least for the svg and png would be adding a bunch of transparent bars above and below to mock some square-ish dimensions.

A special logo-squared.png should be the best fit for not breaking systems that require the file dimensions being equal to the content's bounding box.

I would like to get this fixed, so I can reuse the icons in our Lomiri packaging without having to look at a prominently displayed, slightly stretched logo 24/7.

image

We can fix the converted pngs to properly conform to the ZxZ dimensions at build time, since we're already using imagemagick to produce them from the svgs:

Code diff
diff --git a/icons/Makefile b/icons/Makefile
index c5ee35a..e64cfbb 100755
--- a/icons/Makefile
+++ b/icons/Makefile
@@ -13,13 +13,16 @@ icons = \
   $(foreach size,$(sizes),$(size)x$(size)/$(category)/nix-snowflake-white.png) \
   scalable/$(category)/nix-snowflake-white.svg
 
+full_square = $(shell ./determine-square-size.sh ../logo/nix-snowflake.svg)
+white_square = $(shell ./determine-square-size.sh ../logo/white.svg)
+
 install_dest = $(DESTDIR)$(prefix)/share/icons/$(theme)
 
 all: $(icons)
 
 %/$(category)/nix-snowflake.png: ../logo/nix-snowflake.svg
        @mkdir -p $(@D)
-       convert -background none -resize $* $< $@
+       convert -background none -gravity center -extent $(full_square) -resize $* $< $@
 
 scalable/$(category)/nix-snowflake.svg: ../logo/nix-snowflake.svg
        @mkdir -p $(@D)
@@ -27,7 +30,7 @@ scalable/$(category)/nix-snowflake.svg: ../logo/nix-snowflake.svg
 
 %/$(category)/nix-snowflake-white.png: ../logo/white.svg
        @mkdir -p $(@D)
-       convert -background none -resize $* $< $@
+       convert -background none -gravity center -extent $(white_square) -resize $* $< $@
 
 scalable/$(category)/nix-snowflake-white.svg: ../logo/white.svg
        @mkdir -p $(@D)
diff --git a/icons/determine-square-size.sh b/icons/determine-square-size.sh
new file mode 100755
index 0000000..0902065
--- /dev/null
+++ b/icons/determine-square-size.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+# Needs: imagemagick
+
+if [[ $# -lt 1 ]]; then
+  echo "Usage: $0 /path/to/file.svg" >2
+  exit 1
+fi
+
+width="$(identify -format '%w' "$1")"
+height="$(identify -format '%h' "$1")"
+
+largerLength="$width"
+if [[ "$largerLength" -lt "$height" ]]; then
+  largerLength="$height"
+fi
+
+echo "${largerLength}x${largerLength}"
+exit 0

nix-snowflake -> nix-snowflake

Buuuuut this won't work for the installed svgs, since there's apparently no decent way of doing this for those from the command line? (convert doesn't like svg->svg w/ resizing and produces an empty image, inkscape can only do convenient resizes on raster exports or a hack like this which i would rather not do, rsvg-convert can resize but not pad/center)

Any objections to just uploading manually square'd nix-snowflake-square.svg & white-square.svg and using those for the icon Makefile instead?

I've found a way to do this fully at build time, would appreciate any opinions on it: #118