Skip to content
Open
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
732 changes: 729 additions & 3 deletions crates/Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
members = [ 'squircle' ]
members = [ 'logo', 'squircle' ]
resolver = '2'
12 changes: 12 additions & 0 deletions crates/logo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "linebender_logo"
version = "0.1.0"
edition = "2024"
description = "Generate the Linebender logomark and horizontal lockup"
license = "Apache-2.0"
publish = false

[dependencies]
parley = { version = "0.11.1", default-features = false, features = ["std"] }
skrifa = "0.44"
resvg = { version = "0.47", default-features = false }
15 changes: 15 additions & 0 deletions crates/logo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Linebender logos

![Linebender horizontal lockup](../../static/brand/lockup.png)

Run `cargo run --locked -p linebender_logo` from the repository’s `crates` directory to regenerate the logomark and horizontal lockup in `static/brand/`. The SVGs have transparent backgrounds. The header colors the lockup with its theme color, and the favicon follows the browser’s color scheme. resvg renders each paper preview as a PNG at twice the SVG dimensions.

The mark reuses the community logo’s two curves. Parley shapes “Linebender” in Space Grotesk Medium (weight 500), and Skrifa draws those glyphs at the variation coordinates selected by Parley.

## License

The Linebender logomark and horizontal lockup are licensed under either the [MIT License](https://opensource.org/license/mit) or the [Apache License, Version 2.0](../../LICENSE.apache-2.0), at your option.

## Credit

[Space Grotesk](https://github.com/floriankarsten/space-grotesk) is copyright 2020 The Space Grotesk Project Authors. The unmodified variable font is bundled under the [SIL Open Font License 1.1](assets/spacegrotesk-OFL.txt). The OFL permits using the font in a logo and redistributing the font with its copyright notice and license.
8 changes: 8 additions & 0 deletions crates/logo/assets/mark-fragment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions crates/logo/assets/spacegrotesk-OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2020 The Space Grotesk Project Authors (https://github.com/floriankarsten/space-grotesk)

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.
Binary file added crates/logo/assets/spacegrotesk.ttf
Binary file not shown.
138 changes: 138 additions & 0 deletions crates/logo/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
use parley::{
FontContext, FontFamily, FontWeight, Layout, LayoutContext, PositionedLayoutItem, StyleProperty,
};
use resvg::{tiny_skia, usvg};
use skrifa::{
FontRef, GlyphId, MetadataProvider,
instance::{NormalizedCoord, Size},
outline::{DrawSettings, OutlinePen},
};
use std::{error::Error, fmt::Write as _, fs, path::Path};

type Result<T> = std::result::Result<T, Box<dyn Error>>;
const WEIGHT: f32 = 500.0;

#[derive(Default)]
struct PathData(String);
impl OutlinePen for PathData {
fn move_to(&mut self, x: f32, y: f32) {
write!(self.0, "M{x:.3} {y:.3}").unwrap();
}
fn line_to(&mut self, x: f32, y: f32) {
write!(self.0, "L{x:.3} {y:.3}").unwrap();
}
fn quad_to(&mut self, a: f32, b: f32, x: f32, y: f32) {
write!(self.0, "Q{a:.3} {b:.3} {x:.3} {y:.3}").unwrap();
}
fn curve_to(&mut self, a: f32, b: f32, c: f32, d: f32, x: f32, y: f32) {
write!(self.0, "C{a:.3} {b:.3} {c:.3} {d:.3} {x:.3} {y:.3}").unwrap();
}
fn close(&mut self) {
self.0.push('Z');
}
}

// Return SVG paths in baseline-relative coordinates with a common capital height.
fn lettering(fonts: &mut FontContext, family: &str, text: &str, cap: f32) -> Result<(String, f32)> {
let mut ctx = LayoutContext::new();
let mut builder = ctx.ranged_builder(fonts, text, 1., false);
builder.push_default(FontFamily::Source(family.into()));
builder.push_default(StyleProperty::FontSize(100.));
builder.push_default(StyleProperty::FontWeight(FontWeight::new(WEIGHT)));
let mut layout: Layout<()> = builder.build(text);
layout.break_all_lines(None);
let mut paths = String::new();
let mut scale = None;
for line in layout.lines() {
for item in line.items() {
let PositionedLayoutItem::GlyphRun(batch) = item else {
continue;
};
let run = batch.run();
let data = run.font();
let font = FontRef::from_index(data.data.as_ref(), data.index)?;
let coords: Vec<_> = run
.normalized_coords()
.iter()
.map(|v| NormalizedCoord::from_bits(*v))
.collect();
let size = Size::new(run.font_size());
let metrics = font.metrics(size, coords.as_slice());
let factor =
*scale.get_or_insert(cap / metrics.cap_height.ok_or("font lacks cap height")?);
let outlines = font.outline_glyphs();
for g in batch.positioned_glyphs() {
let outline = outlines.get(GlyphId::new(g.id)).ok_or("missing glyph")?;
let mut pen = PathData::default();
outline.draw(DrawSettings::unhinted(size, coords.as_slice()), &mut pen)?;
write!(
paths,
"<path transform='translate({} {}) scale({factor} -{factor})' d='{}'/>",
g.x * factor,
(g.y - batch.baseline()) * factor,
pen.0
)?;
}
}
}
Ok((paths, layout.width() * scale.ok_or("empty layout")?))
}
fn mark(x: f32, y: f32, height: f32) -> String {
let curves = include_str!("../assets/mark-fragment.svg");
format!(
"<g transform='translate({x} {y}) scale({}) translate(-58 -6)' stroke='currentColor' fill='none' stroke-width='9.19' stroke-linecap='round' stroke-linejoin='round'>{curves}</g>",
height / 388.
)
}
fn export(dir: &Path, name: &str, title: &str, width: u32, height: u32, body: &str) -> Result<()> {
let svg = format!(
"<svg xmlns='http://www.w3.org/2000/svg' width='{width}' height='{height}' viewBox='0 0 {width} {height}' color='#161511'><title>{title}</title><style>@media (prefers-color-scheme: dark) {{ :root {{ color: #fff }} }}</style><g fill='currentColor'>{body}</g></svg>"
);
let tree = usvg::Tree::from_str(&svg, &usvg::Options::default())?;
let mut image = tiny_skia::Pixmap::new(width * 2, height * 2).ok_or("invalid render size")?;
// The PNG is the paper proof used in the README and PR.
image.fill(tiny_skia::Color::from_rgba8(245, 244, 238, 255));
resvg::render(
&tree,
tiny_skia::Transform::from_scale(2., 2.),
&mut image.as_mut(),
);
image.save_png(dir.join(format!("{name}.png")))?;
fs::write(dir.join(format!("{name}.svg")), svg)?;
Ok(())
}
fn main() -> Result<()> {
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
let out = root.join("../../static/brand");
fs::create_dir_all(&out)?;
let mut fonts = FontContext::new();
let bytes = include_bytes!("../assets/spacegrotesk.ttf").to_vec();
if fonts
.collection
.register_fonts(bytes.into(), None)
.is_empty()
{
return Err("could not register Space Grotesk".into());
}
let (word, width) = lettering(&mut fonts, "Space Grotesk", "Linebender", 44.)?;
let lockup = format!(
"{}<g transform='translate(100 81)'>{word}</g>",
mark(24., 20., 80.)
);
export(
&out,
"lockup",
"Linebender",
(width + 124.).ceil() as u32,
120,
&lockup,
)?;
export(
&out,
"logomark",
"Linebender",
256,
256,
&mark(57.73, 32., 192.),
)
}
24 changes: 16 additions & 8 deletions sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,25 @@ table td {
}

.site-title {
font-size: 26px;
font-weight: 300;
line-height: 54px;
letter-spacing: -1px;
margin-bottom: 0;
display: flex;
align-items: center;
min-height: 56px;
float: left;
}

.site-title,
.site-title:visited {
color: var(--header-color);
.site-title::before {
content: "";
width: 187px;
height: 48px;
background-color: var(--header-color);
mask: url("/brand/lockup.svg") center / contain no-repeat;
}

@media (forced-colors: active) {
.site-title::before {
forced-color-adjust: none;
background-color: LinkText;
}
}

.site-nav {
Expand Down
Binary file added static/brand/lockup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions static/brand/lockup.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/brand/logomark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading