Skip to content

Commit b106e8c

Browse files
authored
Merge pull request #44 from sysprog21/tweak-logo
Tweak logo ASCII art for markdown rendering
2 parents f3bb012 + 539ba6a commit b106e8c

File tree

4 files changed

+219
-7
lines changed

4 files changed

+219
-7
lines changed

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
root = true
33

44
# Shell script-specific settings
5+
# Aligns with .ci/check-format.sh: shfmt -i 4 -bn -ci -sr
56
[*.sh]
67
indent_style = space
78
indent_size = 4
89
end_of_line = lf
910
trim_trailing_whitespace = true
1011
insert_final_newline = true
11-
function_next_line = true
12+
function_next_line = false
1213
switch_case_indent = true
1314
space_redirects = true
1415
binary_next_line = true

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

0 commit comments

Comments
 (0)