linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.24k stars 93 forks source link

Cannot run examples - missing fonts? #491

Closed DaLynX closed 2 years ago

DaLynX commented 2 years ago

It seems the examples rely on some ttf fonts that are not in the repository.

λ cargo run --example mondrian
   Compiling winapi v0.3.9
   Compiling libm v0.2.1
   Compiling ppv-lite86 v0.2.16
   Compiling static_assertions v1.1.0
   Compiling getrandom v0.2.4
   Compiling num-traits v0.2.14
   Compiling rand_core v0.6.3
   Compiling rand_chacha v0.3.1
   Compiling rand v0.8.4
   Compiling rand_distr v0.4.3
   Compiling wio v0.2.2
   Compiling os_info v3.1.0
   Compiling dwrote v0.11.0
   Compiling piet v0.5.0 (C:\Users\...\piet\piet)
error: couldn't read piet\src\samples\../../snapshots/resources/Anaheim-Regular.ttf: The system cannot find the path specified. (os error 3)
  --> piet\src\samples\picture_13.rs:16:28
   |
16 |       let _ = text.load_font(include_bytes!(
   |  ____________________________^
17 | |         "../../snapshots/resources/Anaheim-Regular.ttf"
18 | |     ));
   | |_____^
   |
   = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)

error: couldn't read piet\src\samples\../../snapshots/resources/Anaheim-Bold.ttf: The system cannot find the path specified. (os error 3)
  --> piet\src\samples\picture_13.rs:20:20
   |
20 |         .load_font(include_bytes!("../../snapshots/resources/Anaheim-Bold.ttf"))
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)

error: couldn't read piet\src\samples\../../snapshots/resources/Inconsolata-variable.ttf: The system cannot find the path specified. (os error 3)
  --> piet\src\samples\picture_14.rs:17:20
   |
17 |           .load_font(include_bytes!(
   |  ____________________^
18 | |             "../../snapshots/resources/Inconsolata-variable.ttf"
19 | |         ))
   | |_________^
   |
   = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `piet` due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed
cmyr commented 2 years ago

interesting, the problem you're hitting is in an example that is used in testing only, so we should figure out a way to make this work.

There's an easy temporary solution, though, which is that you need to checkout the submodules. I think git submodule update --init should do it?

DaLynX commented 2 years ago

Yes, that solved it, thanks!