Skip to content

Commit efc04ef

Browse files
committed
fix: added favicon and generating script
1 parent 98c7339 commit efc04ef

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

media/favicon.ico

18 KB
Binary file not shown.

scripts/generate_logo.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from PIL import Image, ImageDraw, ImageFont
2+
3+
import matplotlib.font_manager
4+
5+
size = 256
6+
7+
# Create a new black image with a transparent background
8+
image_size = (size, size)
9+
background_color = (0, 0, 0, 255)
10+
image = Image.new("RGBA", image_size, background_color)
11+
12+
# Print available fonts
13+
14+
# Load a monospace font
15+
# Could be: FiraCode-Retina
16+
font_size = int(size / 2)
17+
try:
18+
font = ImageFont.truetype("FiraCode-Retina.ttf", font_size)
19+
except OSError:
20+
print("Available fonts:", [font.split("/")[-1] for font in matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')])
21+
raise
22+
23+
# Draw the string "$ su" on the image
24+
def draw_text_old():
25+
text = "$ su"
26+
text_color = (255, 255, 255, 255)
27+
draw = ImageDraw.Draw(image)
28+
text_width, text_height = draw.textsize(text, font=font)
29+
text_position = ((image_size[0] - text_width) // 2, (image_size[1] - text_height) // 2)
30+
draw.text(text_position, text, font=font, fill=text_color)
31+
32+
# Draw the string "$" and "su" on the image with adjusted spacing
33+
def draw_text():
34+
draw = ImageDraw.Draw(image)
35+
dollar_sign = "$"
36+
text = "su"
37+
text_color = (255, 255, 255, 255)
38+
39+
left, top, right, bottom = draw.textbbox((0, 0), dollar_sign, font=font)
40+
dollar_sign_width = right - left
41+
dollar_sign_height = bottom - top
42+
left, top, right, bottom = draw.textbbox((0, 0), text, font=font)
43+
text_width = right - left
44+
text_height = bottom - top
45+
print("Dollar:", (dollar_sign_width, dollar_sign_height))
46+
print("Text su:", (text_width, text_height))
47+
48+
spacing = int(font_size / 8) # Adjust this value to control the spacing between the "$" and "su"
49+
print("Spacing:", spacing)
50+
total_width = dollar_sign_width + spacing + text_width
51+
print("Total width:", total_width)
52+
53+
54+
dollar_sign_position = ((image_size[0] - total_width) // 2,
55+
(image_size[1] - dollar_sign_height) // 2)
56+
text_position = (dollar_sign_position[0] + dollar_sign_width + spacing,
57+
(image_size[1] - dollar_sign_height) // 2)
58+
59+
draw.text(dollar_sign_position, dollar_sign, font=font, fill=text_color)
60+
draw.text(text_position, text, font=font, fill=text_color)
61+
62+
# Actually draw
63+
draw_text()
64+
65+
# Save the image as a favicon
66+
image.save("media/favicon.ico", "ICO")
67+
print("Done!")

templates/head-includes.pug

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
meta(charset="utf-8")
22
meta(name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no")
33

4+
// Favicon
5+
link(rel="shortcut icon" href="/media/favicon.ico" type="image/x-icon")
6+
47
// MDL
58
link(rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons")
69
// Possible values for primary: deep_orange, red, pink, purple, deep_purple, indigo, blue, light_blue, cyan, teal, green, light_green, lime, yellow, amber, orange, brown, blue_grey, grey

0 commit comments

Comments
 (0)