Skip to content

Commit 9c14a2c

Browse files
committed
Replace inline ASCII art with generated PNG logo
This converts README logo from inline HTML <pre> block to PNG image for better rendering consistency across platforms. It adds automated logo generation script using ImageMagick with Intel One Mono font. - README.md: Replace <pre> with <img> tag, move ASCII art to comment - scripts/generate-logo.sh: Automated PNG generation with font fallback
1 parent d7d1fe1 commit 9c14a2c

3 files changed

Lines changed: 223 additions & 6 deletions

File tree

Documentation/logo.png

5.6 KB
Loading

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Linmo: A Simple Multi-tasking Operating System Kernel
2-
```
2+
3+
<div align="left">
4+
<img src="Documentation/logo.png" alt="Linmo Logo" />
5+
</div>
6+
7+
<!--- Linmo logo source (regenerate with: scripts/generate-logo.sh)
38
▅▅▅▅▅▅▅▅▅▅▅▅▅▅▅▖
49
▐██████████████
510
▐█████▜▆▆▛█████
@@ -11,12 +16,12 @@
1116
▜▖▜▌╺▄▃▄╸ ┓╺▄▄━ █▋▟▍ ▐█▋ ▅▏ ██▍ ▐▋ ▜██▌ █▏ ███ ▐█▋ ▐█▙ ▟█▘
1217
▐▛▀▊ ▝ ▕█▀█ ▗▟██▅▅▇▛ ▅██▙▖▗▟█▖ ▝█▌ ▅█▅ ▝█▘╶▟██▖ ▝▜▇▅▄▇▀▘
1318
▝▙▅█▖ ▀━┷▘ ▟█▅▛
14-
▗██▌█▖ ╺━▇▇━ ▄▊▜█▉ ▆▍ ▕▆
15-
▗██▛▗█▛▅▂▝▀▀▁▃▇██▝██▙ █▍▅▛ ▗▆▀▜▅ ▇▆▀▕▇┻▀▆ ▗▇▀▇▖▕█
16-
▄███▇██▎ ▀▀▀▀▀▔ ▐█████▙▁ █▛▜▄ ▜█▀▜▉ █▎ ▕█▏ █▎▜▛▀▜▉▕█
17-
▀▀▔▔▜▄▀▜▅▄▂▁▁▃▄▆▀▚▟▀▔▀▀▘ ▀▘ ▀▘ ▀▀▀▔ ▀ ▀ ▀ ▀▀▀▔ ▀
19+
▗██▌█▖ ╺━▇▇━ ▄▊▜█▉
20+
▗██▛▗█▛▅▂▝▀▀▁▃▇██▝██▙
21+
▄███▇██▎ ▀▀▀▀▀▔ ▐█████▙
22+
▀▀▔▔▜▄▀▜▅▄▂▁▁▃▄▆▀▚▟▀▔▀▀▘
1823
▝▀▆▄▃████▃▄▆▀▔
19-
```
24+
-->
2025

2126
Linmo is a preemptive, multi-tasking operating system kernel built as an educational showcase for resource-constrained systems.
2227
It offers a lightweight environment where all tasks share a single address space,

scripts/generate-logo.sh

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
#!/usr/bin/env bash
2+
3+
# Generate Linmo logo PNG from ASCII art in README.md
4+
#
5+
# This script extracts ASCII art from a specially formatted comment block
6+
# in README.md and converts it to a PNG image using ImageMagick.
7+
#
8+
# Requirements:
9+
# - ImageMagick (magick or convert command)
10+
# - Intel One Mono font (with fallback to Menlo/Courier)
11+
12+
set -euo pipefail
13+
14+
# Configuration
15+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
17+
README="$PROJECT_ROOT/README.md"
18+
OUTPUT_DIR="$PROJECT_ROOT/Documentation"
19+
OUTPUT_FILE="$OUTPUT_DIR/logo.png"
20+
21+
# Font preferences (in order of preference)
22+
FONTS=("Intel-One-Mono" "Menlo-Regular" "Courier-New" "Courier")
23+
24+
# ImageMagick parameters
25+
POINTSIZE=15
26+
INTERLINE_SPACING=-4
27+
KERNING=0
28+
CANVAS_WIDTH=1600
29+
30+
# Expected minimum number of lines in ASCII art
31+
MIN_LINES=10
32+
33+
# Extract ASCII art from README.md comment block
34+
extract_ascii_art()
35+
{
36+
if [[ ! -f "$README" ]]; then
37+
echo "Error: README.md not found at $README" >&2
38+
return 1
39+
fi
40+
41+
local ascii_art
42+
ascii_art=$(awk '/<!--- Linmo logo source/,/-->/' "$README" \
43+
| sed '1d;$d' \
44+
| sed 's/^ //')
45+
46+
if [[ -z "$ascii_art" ]]; then
47+
echo "Error: No ASCII art found in README.md comment block" >&2
48+
echo "Expected block format:" >&2
49+
echo " <!--- Linmo logo source" >&2
50+
echo " [ASCII art content]" >&2
51+
echo " -->" >&2
52+
return 1
53+
fi
54+
55+
# Validate line count
56+
local line_count
57+
line_count=$(echo "$ascii_art" | wc -l | tr -d ' ')
58+
if [[ "$line_count" -lt "$MIN_LINES" ]]; then
59+
echo "Warning: ASCII art has only $line_count lines (expected at least $MIN_LINES)" >&2
60+
fi
61+
62+
echo "$ascii_art"
63+
}
64+
65+
# Detect available ImageMagick command
66+
detect_imagemagick()
67+
{
68+
if command -v magick &> /dev/null; then
69+
echo "magick"
70+
elif command -v convert &> /dev/null; then
71+
echo "convert"
72+
else
73+
return 1
74+
fi
75+
}
76+
77+
# Detect available font from preference list
78+
detect_font()
79+
{
80+
local available_fonts
81+
available_fonts=$(magick -list font 2> /dev/null | grep -i "Font:" | awk '{print $2}' || echo "")
82+
83+
for font in "${FONTS[@]}"; do
84+
if echo "$available_fonts" | grep -qi "^$font$"; then
85+
echo "$font"
86+
return 0
87+
fi
88+
done
89+
90+
# No preferred font found, return first available monospace font
91+
echo "Courier"
92+
}
93+
94+
# Generate PNG using ImageMagick
95+
generate_png()
96+
{
97+
local ascii_art="$1"
98+
99+
# Detect ImageMagick command
100+
local magick_cmd
101+
if ! magick_cmd=$(detect_imagemagick); then
102+
echo "Error: ImageMagick is not installed." >&2
103+
echo "Please install ImageMagick:" >&2
104+
echo " macOS: brew install imagemagick" >&2
105+
echo " Ubuntu/Debian: sudo apt-get install imagemagick" >&2
106+
echo " Fedora/RHEL: sudo dnf install ImageMagick" >&2
107+
exit 1
108+
fi
109+
110+
# Detect best available font
111+
local font
112+
font=$(detect_font)
113+
echo "Using font: $font"
114+
115+
# Ensure output directory exists
116+
if [[ ! -d "$OUTPUT_DIR" ]]; then
117+
echo "Creating output directory: $OUTPUT_DIR"
118+
mkdir -p "$OUTPUT_DIR"
119+
fi
120+
121+
# Generate PNG with optimized parameters
122+
# - background: black for dark theme
123+
# - fill: white text for maximum contrast
124+
# - font: Intel One Mono for excellent Unicode support
125+
# - pointsize: 16 for compact yet readable text
126+
# - interline-spacing: -4 for tight vertical spacing
127+
# - kerning: 0 for standard character spacing
128+
# - caption: better text rendering than label
129+
# - trim: remove excess whitespace
130+
# - +repage: reset virtual canvas
131+
echo "$ascii_art" | $magick_cmd \
132+
-background black \
133+
-fill white \
134+
-font "$font" \
135+
-pointsize "$POINTSIZE" \
136+
-interline-spacing "$INTERLINE_SPACING" \
137+
-kerning "$KERNING" \
138+
-size "${CANVAS_WIDTH}x" \
139+
caption:@- \
140+
-trim \
141+
+repage \
142+
"$OUTPUT_FILE"
143+
144+
# Verify output file was created
145+
if [[ ! -f "$OUTPUT_FILE" ]]; then
146+
echo "Error: Failed to generate $OUTPUT_FILE" >&2
147+
return 1
148+
fi
149+
150+
# Display output information
151+
local size
152+
size=$(identify "$OUTPUT_FILE" 2> /dev/null | awk '{print $3}' || echo "unknown")
153+
echo "✓ Logo generated successfully"
154+
echo " Output: $OUTPUT_FILE"
155+
echo " Size: $size"
156+
}
157+
158+
# Display usage information
159+
usage()
160+
{
161+
cat << EOF
162+
Usage: $(basename "$0") [OPTIONS]
163+
164+
Generate Linmo logo PNG from ASCII art in README.md
165+
166+
Options:
167+
-h, --help Display this help message
168+
169+
Environment Variables:
170+
POINTSIZE Font size (default: $POINTSIZE)
171+
INTERLINE_SPACING Line spacing (default: $INTERLINE_SPACING)
172+
KERNING Character spacing (default: $KERNING)
173+
174+
Example:
175+
$0
176+
POINTSIZE=20 $0
177+
178+
EOF
179+
}
180+
181+
# Main execution
182+
main()
183+
{
184+
# Parse command line arguments
185+
while [[ $# -gt 0 ]]; do
186+
case "$1" in
187+
-h | --help)
188+
usage
189+
exit 0
190+
;;
191+
*)
192+
echo "Error: Unknown option: $1" >&2
193+
usage
194+
exit 1
195+
;;
196+
esac
197+
shift
198+
done
199+
200+
echo "Extracting ASCII art from README.md..."
201+
local ascii_art
202+
if ! ascii_art=$(extract_ascii_art); then
203+
exit 1
204+
fi
205+
206+
echo "Generating PNG image..."
207+
if ! generate_png "$ascii_art"; then
208+
exit 1
209+
fi
210+
}
211+
212+
main "$@"

0 commit comments

Comments
 (0)