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

iOS text rendering not supported #726

Open
maun opened this issue Jan 5, 2025 · 2 comments
Open

iOS text rendering not supported #726

maun opened this issue Jan 5, 2025 · 2 comments

Comments

@maun
Copy link
Contributor

maun commented Jan 5, 2025

After #679 is merged it should be possible to build and run on iOS using cargo-mobile2. This works for a simple rect, but crashes when using text.

I found the following reasons for this

  1. The fallback fonts are not defined in cosmic-text, this is easy to fix.
  2. The dependency fontdb loads the available fonts from the system directory (here)

This is not supported on iOS and must be done using CoreText, I created an issue for this.

(related: #233)

Crash log:

window creation done
window event Focused(true)
thread '<unnamed>' panicked at /Users/manuel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cosmic-text-0.12.1/src/shape.rs:251:33:
no default font found
stack backtrace:
   0:        0x107505b24 - std::backtrace_rs::backtrace::libunwind::trace::h2504f6a7a9083436
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:        0x107505b24 - std::backtrace_rs::backtrace::trace_unsynchronized::h6d30c5a7e5c0e95b
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x107505b24 - std::sys::backtrace::_print_fmt::h4d241177db3ad3db
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/sys/backtrace.rs:66:9
   3:        0x107505b24 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h7a0e784acb8aeff7
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/sys/backtrace.rs:39:26
   4:        0x107520730 - core::fmt::rt::Argument::fmt::hdcf4364f643ba5f0
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/fmt/rt.rs:177:76
   5:        0x107520730 - core::fmt::write::hc7ae0c33f591ced7
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/fmt/mod.rs:1186:21
   6:        0x107503224 - std::io::Write::write_fmt::h73a91b3d4edc8b40
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/io/mod.rs:1839:15
   7:        0x1075059d8 - std::sys::backtrace::BacktraceLock::print::ha96d44dc3d9057c0
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/sys/backtrace.rs:42:9
   8:        0x1075068fc - std::panicking::default_hook::{{closure}}::h6410df3ad7c0548b
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:268:22
   9:        0x107506744 - std::panicking::default_hook::h04f2d093d7cf1671
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:295:9
  10:        0x1075070b4 - std::panicking::rust_panic_with_hook::h5564521c80b92207
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:801:13
  11:        0x107506d64 - std::panicking::begin_panic_handler::{{closure}}::h24bfefb8a0ebe306
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:674:13
  12:        0x107505fe8 - std::sys::backtrace::__rust_end_short_backtrace::hc1a47cedc59d63b1
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/sys/backtrace.rs:170:18
  13:        0x107506a1c - rust_begin_unwind
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:665:5
  14:        0x10755e730 - core::panicking::panic_fmt::hcf86678192bed007
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:74:14
  15:        0x10755e710 - core::panicking::panic_display::hab223dafa50efa5e
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:264:5
  16:        0x10755e710 - core::option::expect_failed::hc0aae6e2775950e6
                               at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/option.rs:2021:5
  17:        0x10706e080 - core::option::Option<T>::expect::h61e77952fb293d2e
                               at /Users/manuel/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:933:21
  18:        0x107099d94 - cosmic_text::shape::shape_run::hbb59a34151ce1658
                               at /Users/manuel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cosmic-text-0.12.1/src/shape.rs:251:16
  19:        0x10709ac50 - cosmic_text::shape::shape_run_cached::h062accfdf377c51c
                               at /Users/manuel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cosmic-text-0.12.1/src/shape.rs:405:5
  20:        0x107098c58 - cosmic_text::shape::Shaping::run::h5d3b31157047d2d9

Edit: seems to be out of scope for fontdb :(, any ideas how to proceed?

@maun
Copy link
Contributor Author

maun commented Jan 7, 2025

fontique (part of parley, used by xilem) supports iOS by using CoreText: implementation

So when iOS should be supported cosmic-text/fontdb needs to implement something similar, or floem could use parley. I do not know cosmic-text, nor parley, so I do not know which is a better fit for floem.

@jrmoulton
Copy link
Collaborator

Either would be a good fit but lots of the editor code would be difficult to port to parley.

I'm in favor of having our renderer APIs use our own types for glyph runs that could be used from either. then we could port the text input to parley pretty easily and keep the editor using cosmic text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants