brandgen 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- brandgen-2.0.0/.github/workflows/test.yml +73 -0
- brandgen-2.0.0/.gitignore +10 -0
- brandgen-2.0.0/LICENSES/Apache-2.0.txt +73 -0
- brandgen-2.0.0/PKG-INFO +139 -0
- brandgen-2.0.0/pyproject.toml +56 -0
- brandgen-2.0.0/readme.md +125 -0
- brandgen-2.0.0/src/brandgen/__init__.py +11 -0
- brandgen-2.0.0/src/brandgen/__main__.py +9 -0
- brandgen-2.0.0/src/brandgen/build.py +262 -0
- brandgen-2.0.0/src/brandgen/cli.py +167 -0
- brandgen-2.0.0/src/brandgen/document.py +213 -0
- brandgen-2.0.0/src/brandgen/geometry.py +50 -0
- brandgen-2.0.0/src/brandgen/lockup.py +185 -0
- brandgen-2.0.0/src/brandgen/measure.py +90 -0
- brandgen-2.0.0/src/brandgen/metadata.py +45 -0
- brandgen-2.0.0/src/brandgen/render.py +48 -0
- brandgen-2.0.0/src/brandgen/source.py +62 -0
- brandgen-2.0.0/src/brandgen/typeset.py +205 -0
- brandgen-2.0.0/src/brandgen/variant.py +196 -0
- brandgen-2.0.0/tests/conftest.py +23 -0
- brandgen-2.0.0/tests/sample.py +98 -0
- brandgen-2.0.0/tests/test_build.py +102 -0
- brandgen-2.0.0/tests/test_cli.py +36 -0
- brandgen-2.0.0/tests/test_lockup.py +86 -0
- brandgen-2.0.0/tests/test_source.py +37 -0
- brandgen-2.0.0/tests/test_typeset.py +59 -0
- brandgen-2.0.0/tests/test_variant.py +71 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 brandgen developers
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
name: Test
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
branches: [main]
|
|
10
|
+
pull_request:
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
# Formatting, lint and licensing, independent of the Python version.
|
|
18
|
+
check:
|
|
19
|
+
runs-on: ubuntu-24.04
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
- uses: astral-sh/setup-uv@v6
|
|
23
|
+
- name: Check formatting
|
|
24
|
+
run: uv run --only-group dev ruff format --check
|
|
25
|
+
- name: Lint
|
|
26
|
+
run: uv run --only-group dev ruff check
|
|
27
|
+
- name: Check REUSE compliance
|
|
28
|
+
run: uvx reuse lint
|
|
29
|
+
|
|
30
|
+
test:
|
|
31
|
+
runs-on: ubuntu-24.04
|
|
32
|
+
strategy:
|
|
33
|
+
fail-fast: false
|
|
34
|
+
matrix:
|
|
35
|
+
python: ["3.11", "3.12", "3.13"]
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
# cairosvg loads the system cairo library at run time.
|
|
39
|
+
- name: Install cairo
|
|
40
|
+
run: sudo apt-get update && sudo apt-get install --yes libcairo2
|
|
41
|
+
- uses: astral-sh/setup-uv@v6
|
|
42
|
+
with:
|
|
43
|
+
python-version: ${{ matrix.python }}
|
|
44
|
+
- name: Run the test suite
|
|
45
|
+
run: uv run pytest
|
|
46
|
+
- name: Build the distributions
|
|
47
|
+
run: uv build
|
|
48
|
+
# Install the wheel on its own, away from the checkout, and run a
|
|
49
|
+
# complete build of a synthetic brand through the console script.
|
|
50
|
+
- name: Run the installed command line end to end
|
|
51
|
+
run: |
|
|
52
|
+
uv venv "$RUNNER_TEMP/wheel"
|
|
53
|
+
uv pip install --python "$RUNNER_TEMP/wheel" dist/*.whl
|
|
54
|
+
export PATH="$RUNNER_TEMP/wheel/bin:$PATH"
|
|
55
|
+
brandgen --version
|
|
56
|
+
python tests/sample.py "$RUNNER_TEMP/source"
|
|
57
|
+
brandgen build --input "$RUNNER_TEMP/source" \
|
|
58
|
+
--output "$RUNNER_TEMP/generated" --name ci --quiet
|
|
59
|
+
planned=$(brandgen plan --name ci 2>/dev/null | sort)
|
|
60
|
+
written=$(cd "$RUNNER_TEMP/generated" \
|
|
61
|
+
&& find . -type f ! -name manifest.json | sed 's|^\./||' | sort)
|
|
62
|
+
listed=$(python -c 'import json, sys; print("\n".join(sorted(
|
|
63
|
+
f["path"] for f in json.load(open(sys.argv[1]))["files"])))' \
|
|
64
|
+
"$RUNNER_TEMP/generated/manifest.json")
|
|
65
|
+
test "$planned" = "$written"
|
|
66
|
+
test "$planned" = "$listed"
|
|
67
|
+
echo "$(echo "$planned" | wc -l) files planned, written and listed"
|
|
68
|
+
- name: Keep the generated variants
|
|
69
|
+
if: matrix.python == '3.13'
|
|
70
|
+
uses: actions/upload-artifact@v4
|
|
71
|
+
with:
|
|
72
|
+
name: generated-sample
|
|
73
|
+
path: ${{ runner.temp }}/generated
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
|
|
31
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
+
|
|
33
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
+
|
|
35
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
+
|
|
37
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
38
|
+
|
|
39
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
+
|
|
41
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
42
|
+
|
|
43
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
+
|
|
55
|
+
END OF TERMS AND CONDITIONS
|
|
56
|
+
|
|
57
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
58
|
+
|
|
59
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
60
|
+
|
|
61
|
+
Copyright [yyyy] [name of copyright owner]
|
|
62
|
+
|
|
63
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
64
|
+
you may not use this file except in compliance with the License.
|
|
65
|
+
You may obtain a copy of the License at
|
|
66
|
+
|
|
67
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
68
|
+
|
|
69
|
+
Unless required by applicable law or agreed to in writing, software
|
|
70
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
71
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
72
|
+
See the License for the specific language governing permissions and
|
|
73
|
+
limitations under the License.
|
brandgen-2.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: brandgen
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Generate every distribution variant of a brand's marks
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSES/Apache-2.0.txt
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: cairosvg>=2.7
|
|
9
|
+
Requires-Dist: fonttools>=4.47
|
|
10
|
+
Requires-Dist: lxml>=5
|
|
11
|
+
Requires-Dist: svgelements>=1.9
|
|
12
|
+
Requires-Dist: uharfbuzz>=0.39
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
<!--
|
|
16
|
+
SPDX-FileCopyrightText: 2026 brandgen developers
|
|
17
|
+
|
|
18
|
+
SPDX-License-Identifier: Apache-2.0
|
|
19
|
+
-->
|
|
20
|
+
|
|
21
|
+
# brandgen
|
|
22
|
+
|
|
23
|
+
Generates every distribution variant of a brand's marks from a source
|
|
24
|
+
directory. The brand assets live with the brand; this package only holds the
|
|
25
|
+
code.
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
uv run brandgen build --input path/to/source --output path/to/generated \
|
|
29
|
+
--name kprof
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Input
|
|
33
|
+
|
|
34
|
+
The `--input` directory must contain:
|
|
35
|
+
|
|
36
|
+
| File | Purpose |
|
|
37
|
+
|------|---------|
|
|
38
|
+
| `icon.svg` | The icon. |
|
|
39
|
+
| `wordmark.svg` | The wordmark, outlined or as live text. |
|
|
40
|
+
| exactly one `*.ttf` | The brand font. |
|
|
41
|
+
|
|
42
|
+
Anything else in the directory, such as a hand-made `logo.svg` or a palette,
|
|
43
|
+
is ignored. The logo is composed from the icon and the wordmark.
|
|
44
|
+
|
|
45
|
+
The font is used for two things. Live `<text>` in either SVG is converted to
|
|
46
|
+
outlines with it, so no renderer needs the font installed. And it locates the
|
|
47
|
+
wordmark's baseline: the wordmark text, read from its `aria-label` (Inkscape
|
|
48
|
+
writes one when converting text to paths), is set in the font and matched to
|
|
49
|
+
the outlines. Without a label the bottom of the ink is used and the build
|
|
50
|
+
says so.
|
|
51
|
+
|
|
52
|
+
## The logo
|
|
53
|
+
|
|
54
|
+
The logo is the mark `logo-horizontal`: the icon on the left and the
|
|
55
|
+
wordmark to its right. All lengths are fractions of the icon's ink height:
|
|
56
|
+
|
|
57
|
+
| Option | Default | Meaning |
|
|
58
|
+
|--------|---------|---------|
|
|
59
|
+
| `--body` | `0.625` | Height of the wordmark from the top of its ink to the baseline. |
|
|
60
|
+
| `--gap` | `0.2205625` | Space between the icon's ink and the wordmark's ink. |
|
|
61
|
+
|
|
62
|
+
The wordmark body is centred vertically on the icon, and descenders hang
|
|
63
|
+
below it as in running text. Ink that reaches only slightly below the
|
|
64
|
+
baseline, the overshoot of round letters, counts as part of the body.
|
|
65
|
+
|
|
66
|
+
The defaults reproduce the Ambhora logo. The kprof logo uses
|
|
67
|
+
`--gap 0.359375`.
|
|
68
|
+
|
|
69
|
+
Only the horizontal arrangement exists. A vertical one is a new
|
|
70
|
+
`brandgen.lockup.Arrangement` member and one placement branch in
|
|
71
|
+
`brandgen.lockup.compose`; its mark would be `logo-vertical`.
|
|
72
|
+
|
|
73
|
+
## Output
|
|
74
|
+
|
|
75
|
+
Every mark in every legible colourway, background, padding and format:
|
|
76
|
+
|
|
77
|
+
| | transparent | white | black |
|
|
78
|
+
|-|:-:|:-:|:-:|
|
|
79
|
+
| **color** | yes | yes | yes |
|
|
80
|
+
| **white** | yes | | yes |
|
|
81
|
+
| **black** | yes | yes | |
|
|
82
|
+
|
|
83
|
+
| Padding | Clear space | Marks |
|
|
84
|
+
|---------|-------------|-------|
|
|
85
|
+
| `none` | the source page; for the logo, the composed page | all |
|
|
86
|
+
| `tight` | 10% of ink height | all |
|
|
87
|
+
| `clearspace` | 25% of ink height | all |
|
|
88
|
+
| `generous` | 50% of ink height | all |
|
|
89
|
+
| `avatar` | 10% of ink height, on a square | icon |
|
|
90
|
+
|
|
91
|
+
Formats are SVG, PDF (200 mm wide unless `--pdf-width-mm` says otherwise)
|
|
92
|
+
and PNG at 256, 512 and 1024 pixels (`--png-width`, repeatable). Padding
|
|
93
|
+
widens the canvas around the ink; the artwork itself is never moved.
|
|
94
|
+
|
|
95
|
+
Files are laid out as
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
<output>/<mark>/<format>/<name>-<mark>-<colorway>-on-<background>-<padding>[-<width>px].<ext>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
and `<output>/manifest.json` lists every file with its size, SHA-256 and
|
|
102
|
+
canvas, together with the checksums of the three source files and the
|
|
103
|
+
layout used. SVG and PNG output is byte-for-byte reproducible; PDFs differ
|
|
104
|
+
between runs only in the creation date cairo writes into them.
|
|
105
|
+
|
|
106
|
+
Derived SVGs keep the comments in front of the source's root element, such
|
|
107
|
+
as an SPDX header, and drop editor metadata and `<metadata>` blocks.
|
|
108
|
+
|
|
109
|
+
`--mark`, `--colorway`, `--background`, `--padding` and `--format` narrow the
|
|
110
|
+
matrix; each is repeatable. `brandgen plan --name <name>` lists the files a
|
|
111
|
+
build would write, and `brandgen paddings` explains the padding rules.
|
|
112
|
+
|
|
113
|
+
## Development
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
uv sync
|
|
117
|
+
uv run pytest
|
|
118
|
+
uv run ruff check
|
|
119
|
+
uv run ruff format --check
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The tests build their own font and marks, so the repository holds no brand
|
|
123
|
+
assets.
|
|
124
|
+
|
|
125
|
+
## Layout
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
src/brandgen/
|
|
129
|
+
source.py locating icon, wordmark and font
|
|
130
|
+
document.py reading, recolouring, recanvassing and writing SVG
|
|
131
|
+
typeset.py shaping with the brand font, outlining live text
|
|
132
|
+
measure.py ink boxes and the wordmark baseline
|
|
133
|
+
lockup.py composing the logo
|
|
134
|
+
variant.py the variant matrix and file naming
|
|
135
|
+
render.py PNG and PDF through cairosvg
|
|
136
|
+
build.py running a build and writing the manifest
|
|
137
|
+
cli.py command line interface
|
|
138
|
+
metadata.py version
|
|
139
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 brandgen developers
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
[build-system]
|
|
6
|
+
requires = ["hatchling"]
|
|
7
|
+
build-backend = "hatchling.build"
|
|
8
|
+
|
|
9
|
+
[project]
|
|
10
|
+
name = "brandgen"
|
|
11
|
+
dynamic = ["version"]
|
|
12
|
+
description = "Generate every distribution variant of a brand's marks"
|
|
13
|
+
readme = "readme.md"
|
|
14
|
+
license = "Apache-2.0"
|
|
15
|
+
license-files = ["LICENSES/*"]
|
|
16
|
+
requires-python = ">=3.11"
|
|
17
|
+
dependencies = [
|
|
18
|
+
"cairosvg>=2.7",
|
|
19
|
+
"fonttools>=4.47",
|
|
20
|
+
"lxml>=5",
|
|
21
|
+
"svgelements>=1.9",
|
|
22
|
+
"uharfbuzz>=0.39",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
brandgen = "brandgen.cli:main"
|
|
27
|
+
|
|
28
|
+
[dependency-groups]
|
|
29
|
+
dev = [
|
|
30
|
+
"pillow>=10",
|
|
31
|
+
"pytest>=8",
|
|
32
|
+
"ruff>=0.6",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[tool.hatch.version]
|
|
36
|
+
path = "src/brandgen/metadata.py"
|
|
37
|
+
|
|
38
|
+
[tool.hatch.build.targets.wheel]
|
|
39
|
+
packages = ["src/brandgen"]
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
testpaths = ["tests"]
|
|
43
|
+
|
|
44
|
+
[tool.ruff]
|
|
45
|
+
line-length = 80
|
|
46
|
+
target-version = "py311"
|
|
47
|
+
|
|
48
|
+
[tool.ruff.lint]
|
|
49
|
+
select = ["E", "F", "W", "I", "B", "UP", "TID"]
|
|
50
|
+
|
|
51
|
+
[tool.ruff.lint.flake8-tidy-imports]
|
|
52
|
+
ban-relative-imports = "all"
|
|
53
|
+
|
|
54
|
+
[tool.ruff.lint.isort]
|
|
55
|
+
# The synthetic brand used by the tests, imported from the tests directory.
|
|
56
|
+
known-local-folder = ["sample"]
|
brandgen-2.0.0/readme.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
SPDX-FileCopyrightText: 2026 brandgen developers
|
|
3
|
+
|
|
4
|
+
SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
-->
|
|
6
|
+
|
|
7
|
+
# brandgen
|
|
8
|
+
|
|
9
|
+
Generates every distribution variant of a brand's marks from a source
|
|
10
|
+
directory. The brand assets live with the brand; this package only holds the
|
|
11
|
+
code.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
uv run brandgen build --input path/to/source --output path/to/generated \
|
|
15
|
+
--name kprof
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Input
|
|
19
|
+
|
|
20
|
+
The `--input` directory must contain:
|
|
21
|
+
|
|
22
|
+
| File | Purpose |
|
|
23
|
+
|------|---------|
|
|
24
|
+
| `icon.svg` | The icon. |
|
|
25
|
+
| `wordmark.svg` | The wordmark, outlined or as live text. |
|
|
26
|
+
| exactly one `*.ttf` | The brand font. |
|
|
27
|
+
|
|
28
|
+
Anything else in the directory, such as a hand-made `logo.svg` or a palette,
|
|
29
|
+
is ignored. The logo is composed from the icon and the wordmark.
|
|
30
|
+
|
|
31
|
+
The font is used for two things. Live `<text>` in either SVG is converted to
|
|
32
|
+
outlines with it, so no renderer needs the font installed. And it locates the
|
|
33
|
+
wordmark's baseline: the wordmark text, read from its `aria-label` (Inkscape
|
|
34
|
+
writes one when converting text to paths), is set in the font and matched to
|
|
35
|
+
the outlines. Without a label the bottom of the ink is used and the build
|
|
36
|
+
says so.
|
|
37
|
+
|
|
38
|
+
## The logo
|
|
39
|
+
|
|
40
|
+
The logo is the mark `logo-horizontal`: the icon on the left and the
|
|
41
|
+
wordmark to its right. All lengths are fractions of the icon's ink height:
|
|
42
|
+
|
|
43
|
+
| Option | Default | Meaning |
|
|
44
|
+
|--------|---------|---------|
|
|
45
|
+
| `--body` | `0.625` | Height of the wordmark from the top of its ink to the baseline. |
|
|
46
|
+
| `--gap` | `0.2205625` | Space between the icon's ink and the wordmark's ink. |
|
|
47
|
+
|
|
48
|
+
The wordmark body is centred vertically on the icon, and descenders hang
|
|
49
|
+
below it as in running text. Ink that reaches only slightly below the
|
|
50
|
+
baseline, the overshoot of round letters, counts as part of the body.
|
|
51
|
+
|
|
52
|
+
The defaults reproduce the Ambhora logo. The kprof logo uses
|
|
53
|
+
`--gap 0.359375`.
|
|
54
|
+
|
|
55
|
+
Only the horizontal arrangement exists. A vertical one is a new
|
|
56
|
+
`brandgen.lockup.Arrangement` member and one placement branch in
|
|
57
|
+
`brandgen.lockup.compose`; its mark would be `logo-vertical`.
|
|
58
|
+
|
|
59
|
+
## Output
|
|
60
|
+
|
|
61
|
+
Every mark in every legible colourway, background, padding and format:
|
|
62
|
+
|
|
63
|
+
| | transparent | white | black |
|
|
64
|
+
|-|:-:|:-:|:-:|
|
|
65
|
+
| **color** | yes | yes | yes |
|
|
66
|
+
| **white** | yes | | yes |
|
|
67
|
+
| **black** | yes | yes | |
|
|
68
|
+
|
|
69
|
+
| Padding | Clear space | Marks |
|
|
70
|
+
|---------|-------------|-------|
|
|
71
|
+
| `none` | the source page; for the logo, the composed page | all |
|
|
72
|
+
| `tight` | 10% of ink height | all |
|
|
73
|
+
| `clearspace` | 25% of ink height | all |
|
|
74
|
+
| `generous` | 50% of ink height | all |
|
|
75
|
+
| `avatar` | 10% of ink height, on a square | icon |
|
|
76
|
+
|
|
77
|
+
Formats are SVG, PDF (200 mm wide unless `--pdf-width-mm` says otherwise)
|
|
78
|
+
and PNG at 256, 512 and 1024 pixels (`--png-width`, repeatable). Padding
|
|
79
|
+
widens the canvas around the ink; the artwork itself is never moved.
|
|
80
|
+
|
|
81
|
+
Files are laid out as
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
<output>/<mark>/<format>/<name>-<mark>-<colorway>-on-<background>-<padding>[-<width>px].<ext>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
and `<output>/manifest.json` lists every file with its size, SHA-256 and
|
|
88
|
+
canvas, together with the checksums of the three source files and the
|
|
89
|
+
layout used. SVG and PNG output is byte-for-byte reproducible; PDFs differ
|
|
90
|
+
between runs only in the creation date cairo writes into them.
|
|
91
|
+
|
|
92
|
+
Derived SVGs keep the comments in front of the source's root element, such
|
|
93
|
+
as an SPDX header, and drop editor metadata and `<metadata>` blocks.
|
|
94
|
+
|
|
95
|
+
`--mark`, `--colorway`, `--background`, `--padding` and `--format` narrow the
|
|
96
|
+
matrix; each is repeatable. `brandgen plan --name <name>` lists the files a
|
|
97
|
+
build would write, and `brandgen paddings` explains the padding rules.
|
|
98
|
+
|
|
99
|
+
## Development
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
uv sync
|
|
103
|
+
uv run pytest
|
|
104
|
+
uv run ruff check
|
|
105
|
+
uv run ruff format --check
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The tests build their own font and marks, so the repository holds no brand
|
|
109
|
+
assets.
|
|
110
|
+
|
|
111
|
+
## Layout
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
src/brandgen/
|
|
115
|
+
source.py locating icon, wordmark and font
|
|
116
|
+
document.py reading, recolouring, recanvassing and writing SVG
|
|
117
|
+
typeset.py shaping with the brand font, outlining live text
|
|
118
|
+
measure.py ink boxes and the wordmark baseline
|
|
119
|
+
lockup.py composing the logo
|
|
120
|
+
variant.py the variant matrix and file naming
|
|
121
|
+
render.py PNG and PDF through cairosvg
|
|
122
|
+
build.py running a build and writing the manifest
|
|
123
|
+
cli.py command line interface
|
|
124
|
+
metadata.py version
|
|
125
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 brandgen developers
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
"""Generate every distribution variant of a brand's marks.
|
|
6
|
+
|
|
7
|
+
The input is a source directory with ``icon.svg``, ``wordmark.svg`` and the
|
|
8
|
+
brand font as a ``.ttf``. The logo is composed from the icon and the
|
|
9
|
+
wordmark, and every mark is written in every legible colourway, background,
|
|
10
|
+
padding and format. See ``brandgen.build`` for the entry point.
|
|
11
|
+
"""
|