Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions llama.cpp/projects/logo/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Logo generators — llama.cpp-style brand family

Two parameterised generators sharing one visual language (dark `#111`, Martian
Mono wordmark, orange accent, **embedded font — no outlines**):
Mono wordmark, orange accent). The wordmark ships two ways: as **real `<text>`
with the font embedded** (default — editable, selectable) or, with
`--outline-text`, as **`<path>` outlines** (font-independent, ~5× smaller — see
[Outlined wordmarks](#outlined-wordmarks---outline-text)):

- **java-llama.cpp** — a 3-shard **"J"** icon (small hook top, stem, hook
bottom, flush right edge) in the style of the
Expand All @@ -13,14 +16,15 @@ Mono wordmark, orange accent, **embedded font — no outlines**):

| File | Purpose |
|---|---|
| `logolib.py` | Shared base: `BaseConfig` (canvas/font fields), font embedding, config load/write, PNG export, Martian Mono metrics, `fmt`. |
| `logolib.py` | Shared base: `BaseConfig` (canvas/font fields), font embedding, text→path outlining (`text_to_path_d`), config load/write, PNG export, Martian Mono metrics, `fmt`. |
| `generate_java_llama_logo.py` | java-llama.cpp generator (shard-J geometry + wordmark). |
| `java-llama-logo-config.json` | Config for the java-llama.cpp logo. |
| `generate_srcmorph_logo.py` | srcmorph generator (wordmark + blurred m-in-"morph"). |
| `srcmorph-logo-config.json` | Config for the srcmorph logo. |
| `preview_icon.py` | Fast **shard-icon** preview (PIL, no font) — for J-shape iteration. |
| `MartianMono-Regular.ttf` | Wordmark font (OFL-1.1), embedded into the SVG as base64. |
| `*-generated.svg` / `*.png` | Generated output. |
| `*-generated.svg` / `*.png` | Generated output (embedded-font wordmark). |
| `*-outlined.svg` | Generated output with the wordmark as `<path>` outlines (`--outline-text`) — no embedded font, no `<text>`. |

**Font:** [Martian Mono](https://github.com/evilmartians/mono) by the Martian
Mono Project Authors (Evil Martians), licensed under the SIL Open Font License
Expand Down Expand Up @@ -49,18 +53,49 @@ python generate_java_llama_logo.py -c java-llama-logo-config.json \
# Write a fresh default config to edit
python generate_java_llama_logo.py --write-default-config myconfig.json

# Font-independent wordmark: <path> outlines instead of embedded font + <text>
python generate_java_llama_logo.py -c java-llama-logo-config.json \
--outline-text -o java-llama-cpp-outlined.svg

# Construction anchors overlay
python generate_java_llama_logo.py -c java-llama-logo-config.json -o debug.svg --debug

# Fast icon-shape preview while tuning geometry (no font needed)
python preview_icon.py -c java-llama-logo-config.json -o preview_icon.png

# srcmorph — same flags
# srcmorph — same flags (including --outline-text)
python generate_srcmorph_logo.py -c srcmorph-logo-config.json \
-o srcmorph-generated.svg --png srcmorph.png
python generate_srcmorph_logo.py -c srcmorph-logo-config.json \
--outline-text -o srcmorph-outlined.svg
python generate_srcmorph_logo.py --write-default-config srcmorph-logo-config.json
```

## Outlined wordmarks (`--outline-text`)

By default the wordmark is real `<text>` with `MartianMono-Regular.ttf`
base64-embedded via `@font-face`. That blob is ~64 KB — about 98% of each
generated SVG — because it ships the *whole* font. `--outline-text` instead
converts only the glyphs actually used into `<path>` outlines (via fontTools'
`text_to_path_d` in `logolib.py`), so the file drops to ~13–16 KB and needs no
font at all. The `srcmorph` blur is preserved: the `feGaussianBlur` filters move
from the `<text>` onto the outlined groups (filters work on any element).

| | Embedded font (default) | `--outline-text` |
|---|---|---|
| Wordmark markup | `<text>` + `@font-face` | `<path>` only |
| Self-contained / portable | ✅ | ✅ |
| Text selectable / restyleable / editable | ✅ | ❌ (frozen geometry) |
| Font binary redistributed in the file | yes (OFL-1.1, permitted) | no |
| Survives renderers that strip `<style>`/`@font-face` | ❌ | ✅ |
| File size | ~65–71 KB | ~13–16 KB |

Use the **default** when the SVG is a working master you may re-letter or when
selectable text matters; use **`--outline-text`** for distribution — smaller,
font-independent, and robust in sanitizing renderers. Outlining needs
[`fonttools`](https://pypi.org/project/fonttools/) (`pip install fonttools`); the
default text mode does not.

## How the java-llama.cpp icon is built

The **J** is three slanted shards sharing one italic `shear`. Their right edges
Expand Down Expand Up @@ -106,8 +141,9 @@ manually.

### Wordmark

`java-` is drawn in `orange`, `llama.cpp` in `white`, as **real `<text>`** with
the font embedded (`embed_font: true`) — nothing is converted to outlines.
`java-` is drawn in `orange`, `llama.cpp` in `white`. By default it is **real
`<text>`** with the font embedded (`embed_font: true`); pass `--outline-text` to
emit `<path>` outlines instead (see [Outlined wordmarks](#outlined-wordmarks---outline-text)).

## How the srcmorph "m" is built

Expand Down
50 changes: 40 additions & 10 deletions llama.cpp/projects/logo/generate_java_llama_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class LogoConfig(BaseConfig):
java_text: str = "java-"
llama_text: str = "llama.cpp"

# Emit the wordmark as <path> outlines instead of <text> + embedded font.
# Font/text-independent: no @font-face, no <text>, smaller file, license-clean.
outline_text: bool = False

# Debug layer (anchors + seam lines)
debug: bool = False

Expand Down Expand Up @@ -318,28 +322,50 @@ def build_svg(c: LogoConfig) -> str:
'\n <g id="debug-guides">\n' + "\n".join(lines) + "\n </g>"
)

font_family = escape(c.font_family, {'"': "&quot;"})
java_text = escape(c.java_text)
llama_text = escape(c.llama_text)
style = font_face_style(c)
if c.outline_text:
style = ""
desc = "Shard J icon in the llama.cpp style with an outlined wordmark."
java_d, split_x = logolib.text_to_path_d(
c.java_text, c.font_size, text_x, text_baseline, c.letter_spacing, c.font_path
)
llama_d, _ = logolib.text_to_path_d(
c.llama_text, c.font_size, split_x, text_baseline, c.letter_spacing, c.font_path
)
wordmark = (
f' <g id="wordmark">\n'
f' <path id="java-part" d="{java_d}" fill="{c.orange}"/>\n'
f' <path id="llama-part" d="{llama_d}" fill="{c.white}"/>\n'
f' </g>'
)
else:
style = font_face_style(c)
desc = "Shard J icon in the llama.cpp style with an embedded-font wordmark."
font_family = escape(c.font_family, {'"': "&quot;"})
java_text = escape(c.java_text)
llama_text = escape(c.llama_text)
wordmark = (
f' <text id="wordmark" x="{fmt(text_x)}" y="{fmt(text_baseline)}"\n'
f' font-family="{font_family}, monospace"\n'
f' font-size="{fmt(c.font_size)}px"\n'
f' font-weight="{c.font_weight}"\n'
f' letter-spacing="{fmt(c.letter_spacing)}px">'
f'<tspan id="java-part" fill="{c.orange}">{java_text}</tspan>'
f'<tspan id="llama-part" fill="{c.white}">{llama_text}</tspan></text>'
)

return f"""<?xml version="1.0" encoding="UTF-8"?>
<svg width="{fmt(c.width)}" height="{fmt(c.height)}" viewBox="0 0 {fmt(c.width)} {fmt(c.height)}"
fill="none" xmlns="http://www.w3.org/2000/svg">
<title>java-llama.cpp cover</title>
<desc>Shard J icon in the llama.cpp style with an embedded-font wordmark.</desc>{style}
<desc>{desc}</desc>{style}

<rect id="background" width="{fmt(c.width)}" height="{fmt(c.height)}" fill="{c.background}"/>

<g id="j-symbol" transform="translate({fmt(icon_x)} {fmt(icon_y)}) scale({fmt(icon_scale)})" fill="{c.white}">
{icon_body}{debug_layer}
</g>

<text id="wordmark" x="{fmt(text_x)}" y="{fmt(text_baseline)}"
font-family="{font_family}, monospace"
font-size="{fmt(c.font_size)}px"
font-weight="{c.font_weight}"
letter-spacing="{fmt(c.letter_spacing)}px"><tspan id="java-part" fill="{c.orange}">{java_text}</tspan><tspan id="llama-part" fill="{c.white}">{llama_text}</tspan></text>
{wordmark}
</svg>
"""

Expand All @@ -350,6 +376,8 @@ def main() -> None:
parser.add_argument("-c", "--config", type=Path, help="JSON file overriding defaults")
parser.add_argument("--write-default-config", type=Path, help="Write the default JSON config and exit")
parser.add_argument("--debug", action="store_true", help="Render construction anchors")
parser.add_argument("--outline-text", action="store_true",
help="Emit the wordmark as <path> outlines (no embedded font, no <text>)")
parser.add_argument("--png", type=Path, help="Also rasterise a PNG (needs 'pip install resvg-py')")
parser.add_argument("--png-width", type=int, default=2250, help="PNG width in px")
args = parser.parse_args()
Expand All @@ -361,6 +389,8 @@ def main() -> None:
config = logolib.load_config(LogoConfig, args.config)
if args.debug:
config = replace(config, debug=True)
if args.outline_text:
config = replace(config, outline_text=True)

svg = build_svg(config)
args.output.write_text(svg, encoding="utf-8")
Expand Down
54 changes: 42 additions & 12 deletions llama.cpp/projects/logo/generate_srcmorph_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class SrcmorphConfig(BaseConfig):
text_x: float = 1500 # manual mode
text_baseline: float = 1500 # manual mode

# Emit the wordmark as <path> outlines instead of <text> + embedded font.
# The blur filters move onto the outlined groups, so the morph is preserved.
outline_text: bool = False


def font_face_style(c: SrcmorphConfig) -> str:
if not c.embed_font:
Expand All @@ -84,6 +88,12 @@ def morph_glyph(c: SrcmorphConfig, glyph: str, gx: float, baseline: float):
n = max(2, c.m_layers)
span = 1.0 / (n - 1)

glyph_d = None
if c.outline_text:
glyph_d, _ = logolib.text_to_path_d(
glyph, F, gx, baseline, c.letter_spacing, c.font_path
)

defs, body = [], []
for i in range(n):
p = i / (n - 1) # 0 = leftmost (blurry), 1 = rightmost (sharp)
Expand Down Expand Up @@ -113,11 +123,16 @@ def morph_glyph(c: SrcmorphConfig, glyph: str, gx: float, baseline: float):
f'<rect width="{fmt(c.width)}" height="{fmt(c.height)}" fill="url(#mg{i})"/></mask>'
)
op = c.fade_to + (1.0 - c.fade_to) * p # left dissolves, right solid
body.append(
f'<g mask="url(#mm{i})" opacity="{fmt(op)}">'
f'<text x="{fmt(gx)}" y="{fmt(baseline)}" font-family="{c.font_family}, monospace" '
f'font-size="{fmt(F)}" fill="{c.morph_color}" filter="url(#mf{i})">{glyph}</text></g>'
)
if c.outline_text:
inner = (
f'<path d="{glyph_d}" fill="{c.morph_color}" filter="url(#mf{i})"/>'
)
else:
inner = (
f'<text x="{fmt(gx)}" y="{fmt(baseline)}" font-family="{c.font_family}, monospace" '
f'font-size="{fmt(F)}" fill="{c.morph_color}" filter="url(#mf{i})">{glyph}</text>'
)
body.append(f'<g mask="url(#mm{i})" opacity="{fmt(op)}">{inner}</g>')
return "".join(defs), "".join(body)


Expand Down Expand Up @@ -151,15 +166,25 @@ def build_svg(c: SrcmorphConfig) -> str:
m_x = text_x + n_src * adv + space_before
tail_x = m_x + adv + space_after

common = (
f'font-family="{c.font_family}, monospace" font-size="{fmt(c.font_size)}px" '
f'font-weight="{c.font_weight}" letter-spacing="{fmt(c.letter_spacing)}px"'
)
src_el = f'<text id="src-part" x="{fmt(src_x)}" y="{fmt(baseline)}" {common} fill="{c.src_color}">{c.src_text}</text>'
tail_el = f'<text id="orph-part" x="{fmt(tail_x)}" y="{fmt(baseline)}" {common} fill="{c.morph_color}">{tail}</text>'
if c.outline_text:
src_d, _ = logolib.text_to_path_d(
c.src_text, c.font_size, src_x, baseline, c.letter_spacing, c.font_path
)
tail_d, _ = logolib.text_to_path_d(
tail, c.font_size, tail_x, baseline, c.letter_spacing, c.font_path
)
src_el = f'<path id="src-part" d="{src_d}" fill="{c.src_color}"/>'
tail_el = f'<path id="orph-part" d="{tail_d}" fill="{c.morph_color}"/>'
else:
common = (
f'font-family="{c.font_family}, monospace" font-size="{fmt(c.font_size)}px" '
f'font-weight="{c.font_weight}" letter-spacing="{fmt(c.letter_spacing)}px"'
)
src_el = f'<text id="src-part" x="{fmt(src_x)}" y="{fmt(baseline)}" {common} fill="{c.src_color}">{c.src_text}</text>'
tail_el = f'<text id="orph-part" x="{fmt(tail_x)}" y="{fmt(baseline)}" {common} fill="{c.morph_color}">{tail}</text>'
mdefs, mbody = morph_glyph(c, m_char, m_x, baseline)

style = font_face_style(c)
style = "" if c.outline_text else font_face_style(c)
defs = f"<style>{style}</style>{mdefs}" if style else mdefs

return f"""<?xml version="1.0" encoding="UTF-8"?>
Expand Down Expand Up @@ -187,13 +212,18 @@ def main() -> None:
parser.add_argument("--write-default-config", type=Path, help="Write the default JSON config and exit")
parser.add_argument("--png", type=Path, help="Also rasterise a PNG (needs 'pip install resvg-py')")
parser.add_argument("--png-width", type=int, default=2250)
parser.add_argument("--outline-text", action="store_true",
help="Emit the wordmark as <path> outlines (no embedded font, no <text>)")
args = parser.parse_args()

if args.write_default_config:
logolib.write_default_config(SrcmorphConfig, args.write_default_config)
return

config = logolib.load_config(SrcmorphConfig, args.config)
if args.outline_text:
from dataclasses import replace
config = replace(config, outline_text=True)
svg = build_svg(config)
args.output.write_text(svg, encoding="utf-8")

Expand Down
Loading