-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommon.typ
More file actions
94 lines (87 loc) · 2.48 KB
/
common.typ
File metadata and controls
94 lines (87 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// SPDX-License-Identifier: GPL-3.0-or-later
/// General banner theme
#let theme = (
background: rgb("#000000"),
foreground: rgb("#E12617"),
fontsizes: (
title: 24pt,
subtitle: 18pt,
author: 18pt,
date: 18pt,
),
)
/// Prepare a Creative Commons Icon for display in the banner.
///
/// Overwrites the background and foreground colors to match the configured theme.
///
/// -> bytes
#let cc_icon(
/// Path to the (unmodified) CC icon to convert. The icon must be a SVG file.
///
/// -> str
path
) = {
let raw_svg = read(path, encoding: "utf8")
// Adapt foreground color to whatever the theme says
let fix_fg = raw_svg.replace("path ", "path fill=\"" + theme.foreground.to-hex() + "\" ")
// Adapt background color to whatever the theme says
let themed_icon = fix_fg.replace("FFFFFF", theme.background.to-hex())
bytes(themed_icon)
}
/// Prepare the NoName e.V. logo for display in the banner.
///
/// Overwrites the foreground (stroke) color to match the configured theme.
///
/// -> bytes
#let nnev_logo(
/// Path to the base (unmodified) NoName e.V. logo. The logo must be a SVG file.
///
/// -> str
path
) = {
let raw_svg = read(path, encoding: "utf8")
// Adapt foreground color to whatever the theme says
let themed_icon = raw_svg.replace("fill:#000000", "fill:" + theme.foreground.to-hex())
bytes(themed_icon)
}
#let banner(content, theme: theme) = {
set text(
fill: theme.foreground,
hyphenate: false,
font: "DejaVu Sans Mono",
)
set par(justify: true)
set align(center)
page(
numbering: none,
footer: none,
header: none,
margin: 0pt,
width: 16cm,
height: 9cm,
fill: theme.background,
)[
#content
#place(center + bottom,
block(
height: 2cm,
width: 90%,
spacing: 0pt,
inset: (
bottom: 0.3cm,
),
)[
#grid(
columns: (1cm, 1cm, 1cm),
gutter: 5pt,
align: (center, center, center),
image(cc_icon("cc_icon_logo.svg")),
image(cc_icon("cc_icon_by.svg")),
image(cc_icon("cc_icon_sa.svg")),
)
#v(-0.7em)
#link("https://creativecommons.org/licenses/by-sa/4.0/")
]
)
]
}