diff --git a/BRAND.md b/BRAND.md index 2333a9d..6a8beec 100644 --- a/BRAND.md +++ b/BRAND.md @@ -25,14 +25,18 @@ when the product adopts the design-system package; until then the hex values in | Wordmark (3d) | `src/logo/wordmark/sources/wordmark/` | Text + refresh lines only | | Mono (3e) | `src/logo/sources/mono.svg` and `src/logo/wordmark/sources/lockup-horizontal/mono.svg` | E-paper / single-ink | +Lockup and wordmark SVGs are **outlined paths** (no ``). Rebuild outlines +with `pnpm outline:text` after editing masters that still use text (requires +`fonts/OpenSauceSans-*.otf`). + ## Usage - Do not stretch. Keep aspect ratio. - Clear space ≈ mark height. - Yellow-dark (`#FFB300`) on black; yellow-light (`#C89200`) on white. - Use `favicon` / 16px simplified mark for browser favicons. -- Lockup SVGs still contain `` (Open Sauce Sans). Browsers render them; - CI PNG rasterization may fall back to a system font until text is outlined. +- Lockup / wordmark SVGs use outlined paths (no ``). Run `pnpm outline:text` + if you introduce live text again. ## Layout diff --git a/docs/logo-asset-workflow.md b/docs/logo-asset-workflow.md index 764f2dd..6c0dac6 100644 --- a/docs/logo-asset-workflow.md +++ b/docs/logo-asset-workflow.md @@ -3,9 +3,11 @@ ## Masters 1. Update SVG under `src/logo/…` (or OG under `src/og-image/…`). -2. Run `npm run sync:legacy-svg` so root `svg/` matches (legacy CDN). -3. Run `npm run validate && npm run build`. -4. Commit `src/` + synced `svg/` (never commit `dist/`). +2. If wordmark/lockup masters use ``, run `pnpm outline:text` (needs + `fonts/OpenSauceSans-*.otf`). +3. Run `pnpm sync:legacy-svg` so root `svg/` matches (legacy CDN). +4. Run `pnpm validate && pnpm build`. +5. Commit `src/` + synced `svg/` + fonts if changed (never commit `dist/`). ## Build outputs @@ -31,9 +33,9 @@ https://cdn.jsdelivr.net/gh/singleton-sd/poc-inkads-assets@/svg/icon/icon-d ## Follow-ups -- Outline lockup `` to paths for deterministic PNG / email. - Email / documents packs. -- Point marketing at Pages URLs (`https://assets.inkads.poc.singletonsd.com/…`). +- Point marketing at Pages URLs (`https://assets.inkads.poc.singletonsd.com/…`) + — see marketing issue #94 / PR. ## npm package diff --git a/fonts/Open Sauce Sans OFL.txt b/fonts/Open Sauce Sans OFL.txt new file mode 100644 index 0000000..c90f19e --- /dev/null +++ b/fonts/Open Sauce Sans OFL.txt @@ -0,0 +1,93 @@ +Copyright (c) 2020 The Open Sauce Sans Authors (https://github.com/marcologous/Open-Sauce-Fonts) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/fonts/OpenSauceSans-Medium.otf b/fonts/OpenSauceSans-Medium.otf new file mode 100644 index 0000000..2fdea5b Binary files /dev/null and b/fonts/OpenSauceSans-Medium.otf differ diff --git a/fonts/OpenSauceSans-SemiBold.otf b/fonts/OpenSauceSans-SemiBold.otf new file mode 100644 index 0000000..7abb31f Binary files /dev/null and b/fonts/OpenSauceSans-SemiBold.otf differ diff --git a/fonts/README.md b/fonts/README.md new file mode 100644 index 0000000..89563ab --- /dev/null +++ b/fonts/README.md @@ -0,0 +1,9 @@ +# Fonts (outline tooling) + +Open Sauce Sans OTFs used by `pnpm outline:text` to convert lockup/wordmark +`` into paths. + +- License: SIL Open Font License — see `Open Sauce Sans OFL.txt` +- Source: https://github.com/marcologous/Open-Sauce-Fonts + +These files are for build tooling only; they are not served on the Pages CDN. diff --git a/package.json b/package.json index 7edaf24..8db4a42 100644 --- a/package.json +++ b/package.json @@ -36,13 +36,16 @@ "test": "node --test scripts/validate-assets.test.mjs", "build": "node scripts/build.mjs", "generate": "pnpm build", + "outline:text": "node scripts/outline-text-svgs.mjs", "prepublishOnly": "pnpm sync:legacy-svg && pnpm validate && pnpm build", "release": "release-it -VV --dry-run --ci", - "release:ci": "release-it --ci" + "release:ci": "release-it --ci", + "outline:text": "node scripts/outline-text-svgs.mjs" }, "devDependencies": { "@release-it/conventional-changelog": "^10.0.6", "conventional-changelog-conventionalcommits": "^8.0.0", + "opentype.js": "^2.0.0", "release-it": "^19.2.4", "sharp": "^0.33.5", "to-ico": "^1.1.5" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1fd8e90..7526fb8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: conventional-changelog-conventionalcommits: specifier: ^8.0.0 version: 8.0.0 + opentype.js: + specifier: ^2.0.0 + version: 2.0.0 release-it: specifier: ^19.2.4 version: 19.2.4 @@ -1078,6 +1081,10 @@ packages: resolution: {integrity: sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==} engines: {node: '>=18'} + opentype.js@2.0.0: + resolution: {integrity: sha512-kCyjv6xdDY1W/jLWZ/L3QhhTlKUqDZMQ5+Jdlw12b3dXkKNpYBqqlMMj0YDQPShWFTMwgZI1hG14kN3XUDSg/A==} + hasBin: true + ora@9.0.0: resolution: {integrity: sha512-m0pg2zscbYgWbqRR6ABga5c3sZdEon7bSgjnlXC64kxtxLOyjRcbbUkLj7HFyy/FTD+P2xdBWu8snGhYI0jc4A==} engines: {node: '>=20'} @@ -2412,6 +2419,8 @@ snapshots: is-inside-container: 1.0.0 wsl-utils: 0.1.0 + opentype.js@2.0.0: {} + ora@9.0.0: dependencies: chalk: 5.6.2 diff --git a/scripts/outline-text-svgs.mjs b/scripts/outline-text-svgs.mjs new file mode 100644 index 0000000..f668a90 --- /dev/null +++ b/scripts/outline-text-svgs.mjs @@ -0,0 +1,110 @@ +#!/usr/bin/env node +/** + * Replace in wordmark/lockup SVGs with outlined using + * Open Sauce Sans OTFs under fonts/. Run before committing vector masters. + * + * pnpm outline:text + * pnpm sync:legacy-svg + */ +import { readFile, writeFile, readdir } from "node:fs/promises"; +import { readFileSync } from "node:fs"; +import { join, dirname } from "node:path"; +import { fileURLToPath } from "node:url"; +import opentype from "opentype.js"; + +const ROOT = join(dirname(fileURLToPath(import.meta.url)), ".."); +const FONTS = join(ROOT, "fonts"); +const WORDMARK_ROOT = join(ROOT, "src/logo/wordmark/sources"); + +const WEIGHT_TO_FONT = { + 500: "OpenSauceSans-Medium.otf", + 600: "OpenSauceSans-SemiBold.otf", +}; + +/** @type {Map} */ +const fontCache = new Map(); + +function loadFont(file) { + if (!fontCache.has(file)) { + const buf = readFileSync(join(FONTS, file)); + fontCache.set(file, opentype.parse(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength))); + } + return fontCache.get(file); +} + +/** + * @param {import('opentype.js').Font} font + * @param {string} text + * @param {number} x + * @param {number} y baseline + * @param {number} fontSize + * @param {number} letterSpacing + */ +function textToPathData(font, text, x, y, fontSize, letterSpacing) { + const scale = (1 / font.unitsPerEm) * fontSize; + let cursor = x; + const parts = []; + for (const ch of text) { + const glyph = font.charToGlyph(ch); + const path = glyph.getPath(cursor, y, fontSize); + const d = path.toPathData(2); + if (d) parts.push(d); + cursor += glyph.advanceWidth * scale + letterSpacing; + } + return parts.join(" "); +} + +/** + * @param {string} svg + */ +function outlineSvgText(svg) { + return svg.replace(/]*)>([^<]*)<\/text>/g, (_full, attrs, content) => { + const get = (name) => { + const m = attrs.match(new RegExp(`\\b${name}="([^"]*)"`)); + return m ? m[1] : null; + }; + const x = Number(get("x") ?? 0); + const y = Number(get("y") ?? 0); + const fontSize = Number(get("font-size") ?? 16); + const weight = Number(get("font-weight") ?? 500); + const fill = get("fill") ?? "#000000"; + const letterSpacing = Number(get("letter-spacing") ?? 0); + const fontFile = WEIGHT_TO_FONT[weight] ?? WEIGHT_TO_FONT[500]; + const font = loadFont(fontFile); + const d = textToPathData(font, content, x, y, fontSize, letterSpacing); + return ``; + }); +} + +async function walkSvgs(dir, acc = []) { + const entries = await readdir(dir, { withFileTypes: true }); + for (const e of entries) { + const full = join(dir, e.name); + if (e.isDirectory()) await walkSvgs(full, acc); + else if (e.name.endsWith(".svg")) acc.push(full); + } + return acc; +} + +async function main() { + const files = await walkSvgs(WORDMARK_ROOT); + let changed = 0; + for (const file of files) { + const before = await readFile(file, "utf8"); + if (!/ { + console.error(err); + process.exit(1); +}); diff --git a/scripts/validate-assets.mjs b/scripts/validate-assets.mjs index f77041c..7bc7f93 100644 --- a/scripts/validate-assets.mjs +++ b/scripts/validate-assets.mjs @@ -73,7 +73,11 @@ export async function validateAssets() { continue; } try { - assertSvgSafe(await readFile(full, "utf8"), path); + const svg = await readFile(full, "utf8"); + assertSvgSafe(svg, path); + if (/ to paths (pnpm outline:text)`); + } } catch (e) { errors.push(e.message); } diff --git a/src/logo/wordmark/sources/lockup-horizontal/dark.svg b/src/logo/wordmark/sources/lockup-horizontal/dark.svg index 55f6c59..2ff3f65 100644 --- a/src/logo/wordmark/sources/lockup-horizontal/dark.svg +++ b/src/logo/wordmark/sources/lockup-horizontal/dark.svg @@ -5,8 +5,8 @@ - InkAds + - BY SINGLETON SD + diff --git a/src/logo/wordmark/sources/lockup-horizontal/light.svg b/src/logo/wordmark/sources/lockup-horizontal/light.svg index 57378cc..86ac7db 100644 --- a/src/logo/wordmark/sources/lockup-horizontal/light.svg +++ b/src/logo/wordmark/sources/lockup-horizontal/light.svg @@ -5,8 +5,8 @@ - InkAds + - BY SINGLETON SD + diff --git a/src/logo/wordmark/sources/lockup-horizontal/mono.svg b/src/logo/wordmark/sources/lockup-horizontal/mono.svg index ff88265..738765a 100644 --- a/src/logo/wordmark/sources/lockup-horizontal/mono.svg +++ b/src/logo/wordmark/sources/lockup-horizontal/mono.svg @@ -5,7 +5,7 @@ - InkAds + diff --git a/src/logo/wordmark/sources/lockup-stacked/dark.svg b/src/logo/wordmark/sources/lockup-stacked/dark.svg index 8a043c3..10acfbb 100644 --- a/src/logo/wordmark/sources/lockup-stacked/dark.svg +++ b/src/logo/wordmark/sources/lockup-stacked/dark.svg @@ -5,8 +5,8 @@ - InkAds + - BY SINGLETON SD + diff --git a/src/logo/wordmark/sources/lockup-stacked/light.svg b/src/logo/wordmark/sources/lockup-stacked/light.svg index ab61d0d..00f4ce9 100644 --- a/src/logo/wordmark/sources/lockup-stacked/light.svg +++ b/src/logo/wordmark/sources/lockup-stacked/light.svg @@ -5,8 +5,8 @@ - InkAds + - BY SINGLETON SD + diff --git a/src/logo/wordmark/sources/wordmark/dark.svg b/src/logo/wordmark/sources/wordmark/dark.svg index 037f307..5a9b4ac 100644 --- a/src/logo/wordmark/sources/wordmark/dark.svg +++ b/src/logo/wordmark/sources/wordmark/dark.svg @@ -1,5 +1,5 @@ - InkAds + diff --git a/src/logo/wordmark/sources/wordmark/light.svg b/src/logo/wordmark/sources/wordmark/light.svg index 6461362..fcc1758 100644 --- a/src/logo/wordmark/sources/wordmark/light.svg +++ b/src/logo/wordmark/sources/wordmark/light.svg @@ -1,5 +1,5 @@ - InkAds + diff --git a/svg/lockup-horizontal/lockup-horizontal-dark.svg b/svg/lockup-horizontal/lockup-horizontal-dark.svg index 55f6c59..2ff3f65 100644 --- a/svg/lockup-horizontal/lockup-horizontal-dark.svg +++ b/svg/lockup-horizontal/lockup-horizontal-dark.svg @@ -5,8 +5,8 @@ - InkAds + - BY SINGLETON SD + diff --git a/svg/lockup-horizontal/lockup-horizontal-light.svg b/svg/lockup-horizontal/lockup-horizontal-light.svg index 57378cc..86ac7db 100644 --- a/svg/lockup-horizontal/lockup-horizontal-light.svg +++ b/svg/lockup-horizontal/lockup-horizontal-light.svg @@ -5,8 +5,8 @@ - InkAds + - BY SINGLETON SD + diff --git a/svg/lockup-horizontal/lockup-horizontal-mono.svg b/svg/lockup-horizontal/lockup-horizontal-mono.svg index ff88265..738765a 100644 --- a/svg/lockup-horizontal/lockup-horizontal-mono.svg +++ b/svg/lockup-horizontal/lockup-horizontal-mono.svg @@ -5,7 +5,7 @@ - InkAds + diff --git a/svg/lockup-stacked/lockup-stacked-dark.svg b/svg/lockup-stacked/lockup-stacked-dark.svg index 8a043c3..10acfbb 100644 --- a/svg/lockup-stacked/lockup-stacked-dark.svg +++ b/svg/lockup-stacked/lockup-stacked-dark.svg @@ -5,8 +5,8 @@ - InkAds + - BY SINGLETON SD + diff --git a/svg/lockup-stacked/lockup-stacked-light.svg b/svg/lockup-stacked/lockup-stacked-light.svg index ab61d0d..00f4ce9 100644 --- a/svg/lockup-stacked/lockup-stacked-light.svg +++ b/svg/lockup-stacked/lockup-stacked-light.svg @@ -5,8 +5,8 @@ - InkAds + - BY SINGLETON SD + diff --git a/svg/wordmark/wordmark-dark.svg b/svg/wordmark/wordmark-dark.svg index 037f307..5a9b4ac 100644 --- a/svg/wordmark/wordmark-dark.svg +++ b/svg/wordmark/wordmark-dark.svg @@ -1,5 +1,5 @@ - InkAds + diff --git a/svg/wordmark/wordmark-light.svg b/svg/wordmark/wordmark-light.svg index 6461362..fcc1758 100644 --- a/svg/wordmark/wordmark-light.svg +++ b/svg/wordmark/wordmark-light.svg @@ -1,5 +1,5 @@ - InkAds +