Skip to content

Commit d4d32c9

Browse files
committed
Add optional display implementation using embedded-graphics (taken from mlog-pico)
1 parent 8b74cfb commit d4d32c9

File tree

10 files changed

+4601
-7
lines changed

10 files changed

+4601
-7
lines changed

Cargo.lock

Lines changed: 218 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ strum = { version = "0.27.2", default-features = false, features = ["derive"] }
3434
thiserror = { version = "2.0.12", default-features = false }
3535
widestring = { version = "1.2.0", default-features = false, features = ["alloc"] }
3636

37+
# embedded_graphics
38+
embedded-graphics = { version = "0.8.1", optional = true }
39+
3740
# no_std
3841
libm = { version = "0.2.11", optional = true }
3942
serde-json-core = { version = "0.6.0", optional = true }
@@ -61,6 +64,7 @@ indicatif = { version = "0.18.0", optional = true }
6164
bitflags = "2.9.1"
6265

6366
[build-dependencies]
67+
eg-font-converter = { git = "https://github.com/embedded-graphics/bdf", optional = true }
6468
lalrpop = { version = "0.22.2", optional = true }
6569

6670
[dev-dependencies]
@@ -70,6 +74,10 @@ velcro = "0.5.4"
7074

7175
[features]
7276
default = ["std"]
77+
embedded_graphics = [
78+
"dep:eg-font-converter",
79+
"dep:embedded-graphics",
80+
]
7381
no_std = [
7482
"dep:libm",
7583
"dep:serde-json-core",

build.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,27 @@ fn main() {
44
println!("cargo:rerun-if-changed=src/logic/grammar.lalrpop");
55
lalrpop::process_root().unwrap();
66
}
7+
8+
#[cfg(feature = "embedded_graphics")]
9+
{
10+
use std::{env, fs, path::PathBuf};
11+
12+
use eg_font_converter::FontConverter;
13+
14+
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
15+
16+
let fonts_dir = out_dir.join("fonts");
17+
fs::create_dir(&fonts_dir).ok();
18+
19+
println!("cargo:rerun-if-changed=fonts/mindustry/logic.bdf");
20+
21+
// https://github.com/Anuken/Mindustry/blob/65a50a97423431640e636463dde97f6f88a2b0c8/core/src/mindustry/ui/Fonts.java#L88C27-L88C126
22+
FontConverter::with_file("fonts/mindustry/logic.bdf", "LOGIC")
23+
.glyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890\"!`?'.,;:()[]{}<>|/@\\^$€-%+=#_&~* ")
24+
.replacement_character(' ')
25+
.convert_mono_font()
26+
.unwrap()
27+
.save(&fonts_dir)
28+
.unwrap();
29+
}
730
}

fonts/mindustry/LICENSE

Lines changed: 619 additions & 0 deletions
Large diffs are not rendered by default.

fonts/mindustry/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `logic.bdf`: `otf2bdf -p 12 -c m -o logic.bdf logic.ttf`
2+
- `logic.ttf`: https://github.com/Anuken/Mindustry/blob/65a50a97423431640e636463dde97f6f88a2b0c8/core/assets/fonts/logic.ttf

0 commit comments

Comments
 (0)