diff --git a/CLAUDE.md b/CLAUDE.md index 5c2fb7e..265cf0c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -147,3 +147,6 @@ than matching the format again elsewhere. - File search uses `fs.WalkDir` from `./` and does NOT follow symlinks - Hooks use `/bin/sh -c` (Linux/macOS only) - `gocsv` library handles CSV marshal/unmarshal via struct tags +- `scripts/gen-logo.py` regenerates `gitplm-logo.svg` and + `gitplm-logo-square.svg` from Fira Code glyph outlines (fontTools); its + docstring has the `rsvg-convert` commands for the PNG derivatives diff --git a/gitplm-logo-square.png b/gitplm-logo-square.png new file mode 100644 index 0000000..c5e6342 Binary files /dev/null and b/gitplm-logo-square.png differ diff --git a/gitplm-logo-square.svg b/gitplm-logo-square.svg new file mode 100644 index 0000000..71cb5e2 --- /dev/null +++ b/gitplm-logo-square.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/gitplm-logo.png b/gitplm-logo.png index d76bd7e..4b1d35b 100644 Binary files a/gitplm-logo.png and b/gitplm-logo.png differ diff --git a/gitplm-logo.svg b/gitplm-logo.svg index 3c1c042..7e49a59 100644 --- a/gitplm-logo.svg +++ b/gitplm-logo.svg @@ -1,107 +1,7 @@ - - - - - - - - Git - PLM - - - + + + + + diff --git a/scripts/gen-logo.py b/scripts/gen-logo.py new file mode 100644 index 0000000..fd9dd16 --- /dev/null +++ b/scripts/gen-logo.py @@ -0,0 +1,74 @@ +"""Generate the [gitplm] logo assets at the repo root. + +Renders "[gitplm]" as embedded glyph outlines (no font dependency in the +SVG) using Fira Code Medium, in phosphor green on black like a classic +CRT terminal. + +Usage: + python scripts/gen-logo.py + rsvg-convert -w 400 gitplm-logo.svg -o gitplm-logo.png + rsvg-convert -w 360 -h 360 gitplm-logo-square.svg -o gitplm-logo-square.png + +Requires fontTools and the Fira Code font (path below). +""" +from pathlib import Path + +from fontTools.misc.transform import Transform +from fontTools.pens.boundsPen import BoundsPen +from fontTools.pens.svgPathPen import SVGPathPen +from fontTools.pens.transformPen import TransformPen +from fontTools.ttLib import TTFont + +FONT = "/usr/share/fonts/TTF/FiraCodeNerdFont-Medium.ttf" +TEXT = "[gitplm]" +COLOR = "#33ff33" # phosphor green +BG = "#000000" + +ROOT = Path(__file__).resolve().parent.parent + +font = TTFont(FONT) +cmap = font.getBestCmap() +glyphs = font.getGlyphSet() + +# Build one combined path, y-flipped (font coords -> SVG coords), advancing x. +pen = SVGPathPen(glyphs) +bpen = BoundsPen(glyphs) +x = 0 +for ch in TEXT: + g = glyphs[cmap[ord(ch)]] + t = Transform(1, 0, 0, -1, x, 0) + g.draw(TransformPen(pen, t)) + g.draw(TransformPen(bpen, t)) + x += g.width +path = pen.getCommands() +xmin, ymin, xmax, ymax = bpen.bounds +w, h = xmax - xmin, ymax - ymin + + +def svg(width, height, scale, tx, ty): + return f""" + + + + + + +""" + + +# Wide wordmark, normalized to 100 px tall. +pad = 0.30 * h +s = 100.0 / (h + 2 * pad) +W = round((w + 2 * pad) * s, 2) +(ROOT / "gitplm-logo.svg").write_text( + svg(W, 100, s, (pad - xmin) * s, (pad - ymin) * s) +) +print(f"wrote gitplm-logo.svg {W} x 100") + +# Square logo: 360x360, text ~85% of width, centered. +SQ = 360 +s2 = (SQ * 0.85) / w +tx = (SQ - w * s2) / 2 - xmin * s2 +ty = (SQ - h * s2) / 2 - ymin * s2 +(ROOT / "gitplm-logo-square.svg").write_text(svg(SQ, SQ, s2, tx, ty)) +print("wrote gitplm-logo-square.svg 360x360")