diff --git a/web/themes/custom/leshed/apple-touch-icon.png b/web/themes/custom/leshed/apple-touch-icon.png new file mode 100644 index 0000000..39fc178 Binary files /dev/null and b/web/themes/custom/leshed/apple-touch-icon.png differ diff --git a/web/themes/custom/leshed/assets/img/favicon-gen.py b/web/themes/custom/leshed/assets/img/favicon-gen.py new file mode 100644 index 0000000..81ffff2 --- /dev/null +++ b/web/themes/custom/leshed/assets/img/favicon-gen.py @@ -0,0 +1,42 @@ +"""Génère les favicons « Sh » à partir des glyphes Epilogue variable. +Usage : python3 favicon-gen.py """ +import sys, os +from fontTools.ttLib import TTFont +from fontTools.varLib.instancer import instantiateVariableFont +from fontTools.pens.svgPathPen import SVGPathPen +from fontTools.pens.boundsPen import BoundsPen +F = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fonts/epilogue/") +UP, IT = "Epilogue-VariableFont_wght.ttf", "Epilogue-Italic-VariableFont_wght.ttf" + +def glyph(font, ch, w): + f = instantiateVariableFont(TTFont(F + font), {"wght": w}) + gs = f.getGlyphSet(); name = f.getBestCmap()[ord(ch)] + p = SVGPathPen(gs); gs[name].draw(p) + b = BoundsPen(gs); gs[name].draw(b) + return p.getCommands(), b.bounds + +def make(out, letters, gap=40): + parts, x = [], None + for font, ch, w in letters: + d, b = glyph(font, ch, w) + dx = -b[0] if x is None else x + gap - b[0] + parts.append((d, dx, b)); x = dx + b[2] + x0 = 0; W = x + y0 = min(b[1] for _, _, b in parts); y1 = max(b[3] for _, _, b in parts); H = y1 - y0 + S, pad = 1000, 140; sc = (S - 2 * pad) / max(W, H) + tx = pad + ((S - 2 * pad) - W * sc) / 2 + ty = pad + ((S - 2 * pad) - H * sc) / 2 + y1 * sc + paths = "".join(f'' for d, dx, _ in parts) + open(out, "w").write( + f'' + f'' + f'{paths}') + +o = sys.argv[1] +# S italique très gras, h droit fin (contraste du logo « Le Shed »). +make(o + "/favicon.svg", [(IT, "S", 900), (UP, "h", 100)]) # 180 px et plus +make(o + "/favicon-tab.svg", [(IT, "S", 900), (UP, "h", 300)]) # onglets +make(o + "/favicon-small.svg", [(IT, "S", 900), (UP, "h", 400)]) # ico 16/32 +# variante inverse, pour comparaison +make(o + "/alt.svg", [(IT, "S", 100), (UP, "h", 900)]) +make(o + "/alt-small.svg", [(IT, "S", 400), (UP, "h", 900)]) diff --git a/web/themes/custom/leshed/favicon.ico b/web/themes/custom/leshed/favicon.ico new file mode 100644 index 0000000..84483ab Binary files /dev/null and b/web/themes/custom/leshed/favicon.ico differ diff --git a/web/themes/custom/leshed/favicon.svg b/web/themes/custom/leshed/favicon.svg new file mode 100644 index 0000000..231b965 --- /dev/null +++ b/web/themes/custom/leshed/favicon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/themes/custom/leshed/leshed.theme b/web/themes/custom/leshed/leshed.theme index a6008ac..60235ec 100644 --- a/web/themes/custom/leshed/leshed.theme +++ b/web/themes/custom/leshed/leshed.theme @@ -42,6 +42,17 @@ function leshed_page_attachments_alter(&$page) { ]; } } + + // favicon.ico (racine du thème) est servi par Drupal ; on ajoute la version + // SVG, prioritaire pour les navigateurs qui la gèrent, et l'icône iOS. + $theme_path = base_path() . \Drupal::service('extension.list.theme')->getPath('leshed') . '/'; + $icons = [ + 'leshed_favicon_svg' => ['rel' => 'icon', 'href' => $theme_path . 'favicon.svg', 'type' => 'image/svg+xml'], + 'leshed_apple_touch_icon' => ['rel' => 'apple-touch-icon', 'href' => $theme_path . 'apple-touch-icon.png'], + ]; + foreach ($icons as $key => $attributes) { + $page['#attached']['html_head'][] = [['#tag' => 'link', '#attributes' => $attributes], $key]; + } } /** * Implements hook_preprocess_HOOK() for html.html.twig.