# Regenerates every file in 00_Brand/Logo and 00_Brand/Social (SVG). # Setup once: python -m pip install uharfbuzz fonttools # Fonts: put TiroBangla-Regular.ttf, Fraunces.ttf (variable) and BalooDa2.ttf # from https://github.com/google/fonts (ofl/tirobangla, ofl/fraunces, ofl/balooda2) # into a "fonts" folder next to this script. # Run: python make_logo.py # PNG versions were made from the SVGs at 1080-2000 px wide (any SVG-to-PNG tool works). """Build outlined logo SVGs for Astha Green Life. Text is shaped with HarfBuzz (correct Bangla conjuncts) and converted to paths, so the files render the same everywhere without the fonts installed.""" import os, sys, math import uharfbuzz as hb from fontTools.pens.svgPathPen import SVGPathPen from fontTools.pens.transformPen import TransformPen from fontTools.pens.boundsPen import BoundsPen HERE = os.path.dirname(os.path.abspath(__file__)) FONTS = os.path.join(HERE, "fonts") OUT = sys.argv[1] os.makedirs(OUT, exist_ok=True) # ---------- brand colours ---------- FOREST, LEAF, SAGE, GOLD, IVORY = "#173F25", "#2C6A3F", "#5B9A62", "#C8922A", "#F7F2E8" MINT = "#CFE3CC" # ---------- icon geometry (100 x 100 design box) ---------- LEFT = "M48.6 8C28 24 14 60 26 91C40 72 49.2 44 48.6 8Z" RIGHT = "M51.4 8C72 24 86 60 74 91C60 72 50.8 44 51.4 8Z" DROP = "M50 51.5C54.6 58.5 58.4 64.2 58.4 70.4A8.4 8.4 0 0 1 41.6 70.4C41.6 64.2 45.4 58.5 50 51.5Z" def cubic_bounds(p0, p1, p2, p3, n=200): xs, ys = [], [] for i in range(n + 1): t = i / n; u = 1 - t xs.append(u**3*p0[0] + 3*u*u*t*p1[0] + 3*u*t*t*p2[0] + t**3*p3[0]) ys.append(u**3*p0[1] + 3*u*u*t*p1[1] + 3*u*t*t*p2[1] + t**3*p3[1]) return min(xs), min(ys), max(xs), max(ys) # icon bounds (outer curves of both leaves) lb = cubic_bounds((48.6, 8), (28, 24), (14, 60), (26, 91)) rb = cubic_bounds((51.4, 8), (72, 24), (86, 60), (74, 91)) IX0, IY0, IX1, IY1 = lb[0], 8, rb[2], 91 IW, IH = IX1 - IX0, IY1 - IY0 def icon_group(x, y, h, left, right, drop): """Place the icon so its visual box starts at (x, y) with height h.""" s = h / IH tx, ty = x - IX0 * s, y - IY0 * s return (f'' f'' f''), IW * s # ---------- text shaping ---------- class Face: def __init__(self, fname, variations=None): blob = hb.Blob.from_file_path(os.path.join(FONTS, fname)) self.face = hb.Face(blob) self.font = hb.Font(self.face) self.upem = self.face.upem if variations: self.font.set_variations(variations) def shape(self, text, size, tracking=0.0): """Return (svg path d, bounds, advance) with baseline at y=0, x starting at 0. tracking is extra space per glyph cluster in em.""" buf = hb.Buffer(); buf.add_str(text); buf.guess_segment_properties() hb.shape(self.font, buf, {"kern": True, "liga": True}) s = size / self.upem pen = SVGPathPen(None, ntos=lambda v: ("%.2f" % v).rstrip("0").rstrip(".")) bpen = BoundsPen(None) x = 0.0 infos, poss = buf.glyph_infos, buf.glyph_positions last_cluster = None for i, (info, pos) in enumerate(zip(infos, poss)): if last_cluster is not None and info.cluster != last_cluster and tracking: x += tracking * size last_cluster = info.cluster gx = x + pos.x_offset * s gy = pos.y_offset * s t = (s, 0, 0, -s, gx, -gy) self.font.draw_glyph_with_pen(info.codepoint, TransformPen(pen, t)) self.font.draw_glyph_with_pen(info.codepoint, TransformPen(bpen, t)) x += pos.x_advance * s return pen.getCommands(), bpen.bounds, x TIRO = Face("TiroBangla-Regular.ttf") FRAUNCES = Face("Fraunces.ttf", {"wght": 600, "opsz": 12, "SOFT": 50, "WONK": 0}) FRAUNCES_D = Face("Fraunces.ttf", {"wght": 480, "opsz": 72, "SOFT": 50, "WONK": 0}) BN = "আস্থা গ্রিন লাইফ" EN = "ASTHA GREEN LIFE" def text_at(d, x, y, fill, sw=0): return f'' def svg(w, h, body, title): return (f'' f'{title}{body}\n') def write(name, content): with open(os.path.join(OUT, name), "w", encoding="utf-8") as f: f.write(content) print("wrote", name) def wordmark_pair(bn_size): bn_d, bn_b, bn_adv = TIRO.shape(BN, bn_size) bn_w = bn_b[2] - bn_b[0] # English line: choose tracking so it spans the Bangla wordmark width en_size = bn_size * 0.30 lo, hi = 0.0, 1.5 for _ in range(40): mid = (lo + hi) / 2 _, b, _ = FRAUNCES.shape(EN, en_size, mid) if (b[2] - b[0]) < bn_w: lo = mid else: hi = mid en_d, en_b, _ = FRAUNCES.shape(EN, en_size, lo) return (bn_d, bn_b), (en_d, en_b) def horizontal(colors, name, title): left, right, drop, bn_fill, en_fill = colors H = 120.0 (bn_d, bn_b), (en_d, en_b) = wordmark_pair(64) pad = 6 ig, iw = icon_group(pad, pad, H, left, right, drop) gap = 30 tx = pad + iw + gap # vertical placement: Bangla block upper part, English line lower part bn_h = bn_b[3] - bn_b[1] en_h = en_b[3] - en_b[1] line_gap = 13 block_h = bn_h + line_gap + en_h top = pad + (H - block_h) / 2 bn_y = top - bn_b[1] # bounds y1 is negative (above baseline) en_y = top + bn_h + line_gap - en_b[1] body = ig + text_at(bn_d, tx - bn_b[0], bn_y, bn_fill, 1.1) + text_at(en_d, tx - en_b[0], en_y, en_fill) W = tx + (bn_b[2] - bn_b[0]) + pad write(name, svg(W, H + 2 * pad, body, title)) def stacked(colors, name, title): left, right, drop, bn_fill, en_fill = colors (bn_d, bn_b), (en_d, en_b) = wordmark_pair(64) bn_w = bn_b[2] - bn_b[0] pad = 6 W = bn_w + 2 * pad H_icon = 132.0 iw = IW * (H_icon / IH) ig, _ = icon_group((W - iw) / 2, pad, H_icon, left, right, drop) y = pad + H_icon + 26 bn_h = bn_b[3] - bn_b[1] bn_y = y - bn_b[1] en_h = en_b[3] - en_b[1] en_y = y + bn_h + 13 - en_b[1] body = ig + text_at(bn_d, pad - bn_b[0], bn_y, bn_fill, 1.1) + text_at(en_d, pad - en_b[0], en_y, en_fill) H = y + bn_h + 13 + en_h + pad write(name, svg(W, H, body, title)) def english(colors, name, title): left, right, drop, txt, _ = colors H = 120.0 d, b, _ = FRAUNCES_D.shape("Astha Green Life", 62) pad = 6 ig, iw = icon_group(pad, pad, H, left, right, drop) tx = pad + iw + 28 th = b[3] - b[1] ty = pad + (H - th) / 2 - b[1] body = ig + text_at(d, tx - b[0], ty, txt) W = tx + (b[2] - b[0]) + pad write(name, svg(W, H + 2 * pad, body, title)) def icon_file(colors, name, title, bg=None, size=512, circle=False, scale=0.62): left, right, drop = colors body = "" if bg: body += (f'' if circle else f'') h = size * scale w = IW * h / IH ig, _ = icon_group((size - w) / 2, (size - h) / 2, h, left, right, drop) write(name, svg(size, size, body + ig, title)) COLOR = (FOREST, SAGE, GOLD, FOREST, LEAF) REVERSE = (IVORY, "#8FC497", GOLD, IVORY, MINT) MONO_F = (FOREST, FOREST, FOREST, FOREST, FOREST) MONO_W = ("#FFFFFF",) * 5 horizontal(COLOR, "AGL_Logo_Horizontal.svg", "Astha Green Life logo") horizontal(REVERSE, "AGL_Logo_Horizontal_Reverse.svg", "Astha Green Life logo (for dark backgrounds)") horizontal(MONO_F, "AGL_Logo_Horizontal_Mono.svg", "Astha Green Life logo, one colour") stacked(COLOR, "AGL_Logo_Stacked.svg", "Astha Green Life logo, stacked") stacked(REVERSE, "AGL_Logo_Stacked_Reverse.svg", "Astha Green Life logo, stacked, for dark backgrounds") english(COLOR, "AGL_Logo_English.svg", "Astha Green Life English logo") english(REVERSE, "AGL_Logo_English_Reverse.svg", "Astha Green Life English logo for dark backgrounds") icon_file((FOREST, SAGE, GOLD), "AGL_Icon.svg", "Astha Green Life icon", scale=0.86) icon_file((IVORY, "#8FC497", GOLD), "AGL_Icon_Reverse.svg", "Astha Green Life icon for dark backgrounds", scale=0.86) icon_file((FOREST, FOREST, FOREST), "AGL_Icon_Mono.svg", "Astha Green Life icon, one colour", scale=0.86) icon_file((FOREST, SAGE, GOLD), "AGL_Facebook_Profile.svg", "Astha Green Life Facebook profile picture", bg=IVORY, size=1080, scale=0.56) icon_file((IVORY, "#8FC497", GOLD), "AGL_Facebook_Profile_Dark.svg", "Astha Green Life Facebook profile picture, dark", bg=FOREST, size=1080, scale=0.56) # ---------- Facebook cover 1640 x 924 (desktop shows the middle 1640 x 624 band) ---------- def cover(name): W, H = 1640, 924 GOLD_LIGHT = "#E2B866" body = f'' # quiet arch outlines echoing the logo, at the far sides for cx, sc, op in ((120, 5.2, .10), (1520, 5.2, .10), (250, 3.4, .07), (1390, 3.4, .07)): tx, ty = cx - 50 * sc, H - 91 * sc + 40 body += (f'') # centred lockup: icon + Bangla wordmark + English line (reverse colours) (bn_d, bn_b), (en_d, en_b) = wordmark_pair(118) H_icon = 214.0 ig, iw = icon_group(0, 0, H_icon, IVORY, "#8FC497", GOLD) bn_w = bn_b[2] - bn_b[0] gap = 54 total_w = iw + gap + bn_w x0 = (W - total_w) / 2 band_top, band_h = 150, 624 tag_d, tag_b, _ = TIRO.shape("খাঁটি ভেষজ, পূর্ণ আস্থা", 50) tag_h = tag_b[3] - tag_b[1] block_h = H_icon + 58 + tag_h y0 = band_top + (band_h - block_h) / 2 ig, _ = icon_group(x0, y0, H_icon, IVORY, "#8FC497", GOLD) tx = x0 + iw + gap bn_h = bn_b[3] - bn_b[1]; en_h = en_b[3] - en_b[1] lg = 24 tb = bn_h + lg + en_h t_top = y0 + (H_icon - tb) / 2 body += ig body += text_at(bn_d, tx - bn_b[0], t_top - bn_b[1], IVORY, 1.6) body += text_at(en_d, tx - en_b[0], t_top + bn_h + lg - en_b[1], MINT) # tagline centred under the lockup, with a small gold rule either side tw = tag_b[2] - tag_b[0] ty = y0 + H_icon + 58 - tag_b[1] tx2 = (W - tw) / 2 - tag_b[0] body += text_at(tag_d, tx2, ty, GOLD_LIGHT, 0.6) ry = y0 + H_icon + 58 + tag_h * 0.55 body += (f'' f'') write(name, svg(W, H, body, "Astha Green Life Facebook cover")) cover("AGL_Facebook_Cover.svg")