Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to embedded font when system font is unsupported #74

Merged
merged 2 commits into from
Dec 1, 2019

Conversation

hecrj
Copy link
Member

@hecrj hecrj commented Nov 26, 2019

Fixes #69.

This PR embeds Lato in iced_wgpu and uses it when the default system fonts cannot be handled by rusttype. This is a dirty fix and should increase binary size a bit. It's meant to be a workaround while we move the text pipeline in iced_wgpu to something that offers more support (see #33).

Additionally, the PR also removes the loading of a monospace font, reducing memory footprint. We can use the default font instead for the debug/overlay view.

@hecrj hecrj added the bug Something isn't working label Nov 26, 2019
@hecrj hecrj added this to the 0.1.0 milestone Nov 26, 2019
@hecrj hecrj self-assigned this Nov 26, 2019
@safijari
Copy link

I just ran into this issue trying to run the examples, found this PR, switched to this branch and recompiled. Still getting a panic.

@hecrj
Copy link
Member Author

hecrj commented Nov 27, 2019

@safijari Thanks for testing it!

Could you share a backtrace?

@safijari
Copy link

safijari commented Nov 29, 2019

When I run RUST_BACKTRACE=1 cargo run --example tour on 80a8a57 I get:

    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/examples/tour`
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/macros/mod.rs:15:40
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1030
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:188
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:205
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:464
  11: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:373
  12: rust_begin_unwind
             at src/libstd/panicking.rs:302
  13: core::panicking::panic_fmt
             at src/libcore/panicking.rs:82
  14: core::panicking::panic
             at src/libcore/panicking.rs:50
  15: core::option::Option<T>::unwrap
             at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/macros/mod.rs:15
  16: wgpu_request_adapter
             at /home/jari/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-native-0.4.0/src/instance.rs:474
  17: wgpu::Adapter::request
             at /home/jari/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.4.0/src/lib.rs:545
  18: iced_wgpu::renderer::Renderer::new
             at wgpu/src/renderer.rs:51
  19: <iced_wgpu::renderer::Renderer as iced_native::renderer::windowed::Windowed>::new
             at wgpu/src/renderer.rs:417
  20: iced_winit::application::Application::run
             at ./winit/src/application.rs:115
  21: iced::application::Application::run
             at ./src/application.rs:140
  22: iced::sandbox::Sandbox::run
             at ./src/sandbox.rs:128
  23: tour::main
             at examples/tour.rs:10
  24: std::rt::lang_start::{{closure}}
             at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/rt.rs:61
  25: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:48
  26: std::panicking::try::do_call
             at src/libstd/panicking.rs:287
  27: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:81
  28: std::panicking::try
             at src/libstd/panicking.rs:265
  29: std::panic::catch_unwind
             at src/libstd/panic.rs:395
  30: std::rt::lang_start_internal
             at src/libstd/rt.rs:47
  31: std::rt::lang_start
             at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/rt.rs:61
  32: main
  33: __libc_start_main
  34: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.```

@hecrj
Copy link
Member Author

hecrj commented Nov 29, 2019

Hey @safijari, thanks for reporting back.

Your issue is not related to font loading. It seems wgpu is not able to find a suitable graphics adapter. A related issue is #72.

My advice is to check that your Vulkan drivers are installed correctly. I am also working on a renderer alternative that should be able to fallback to software mode in this cases.

@hecrj hecrj merged commit 25ed333 into master Dec 1, 2019
@hecrj hecrj deleted the fix/font-load-panic branch December 1, 2019 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic when running any of the examples under Linux Intel GPU
2 participants