mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Fix build on QNX
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / files-changed (push) Waiting to run
CI / build_and_test (--exclude bevy-example, ubuntu-22.04, 1.82) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, --exclude bevy-example, windows-2022, 1.82) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / files-changed (push) Waiting to run
CI / build_and_test (--exclude bevy-example, ubuntu-22.04, 1.82) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, --exclude bevy-example, windows-2022, 1.82) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
- The memmap2 dependecy doesn't compile on QNX, so disable fontdb's memmap feature on QNX (besides WASM) - Assume the availability of the Noto Sans font from the fonts system package
This commit is contained in:
parent
8faa22292e
commit
554c73f1ef
3 changed files with 39 additions and 5 deletions
|
@ -30,4 +30,7 @@ cfg-if = { version = "1", optional = true }
|
|||
libloading = { version = "0.8.0", optional = true }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
fontdb = { workspace = true, optional = true, default-features = true }
|
||||
fontdb = { workspace = true, optional = true, features = ["std", "fs", "fontconfig"] }
|
||||
|
||||
[target.'cfg(all(not(target_arch = "wasm32"), not(target_os = "nto")))'.dependencies]
|
||||
fontdb = { workspace = true, optional = true, features = ["memmap"] }
|
||||
|
|
|
@ -17,6 +17,7 @@ pub struct FontDatabase {
|
|||
target_vendor = "apple",
|
||||
target_arch = "wasm32",
|
||||
target_os = "android",
|
||||
target_os = "nto",
|
||||
)))]
|
||||
pub fontconfig_fallback_families: Vec<String>,
|
||||
// Default font families to use instead of SansSerif when SLINT_DEFAULT_FONT env var is set.
|
||||
|
@ -64,6 +65,7 @@ thread_local! {
|
|||
target_vendor = "apple",
|
||||
target_arch = "wasm32",
|
||||
target_os = "android",
|
||||
target_os = "nto",
|
||||
)))]
|
||||
mod fontconfig;
|
||||
|
||||
|
@ -117,15 +119,20 @@ fn init_fontdb() -> FontDatabase {
|
|||
target_vendor = "apple",
|
||||
target_arch = "wasm32",
|
||||
target_os = "android",
|
||||
target_os = "nto",
|
||||
)))]
|
||||
let mut fontconfig_fallback_families = Vec::new();
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg(any(target_arch = "wasm32", target_os = "nto"))]
|
||||
{
|
||||
let data = include_bytes!("sharedfontdb/DejaVuSans.ttf");
|
||||
font_db.load_font_data(data.to_vec());
|
||||
font_db.set_sans_serif_family("DejaVu Sans");
|
||||
}
|
||||
#[cfg(target_os = "nto")]
|
||||
{
|
||||
font_db.set_sans_serif_family("Noto Sans");
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
font_db.load_fonts_dir("/system/fonts");
|
||||
|
@ -146,6 +153,7 @@ fn init_fontdb() -> FontDatabase {
|
|||
target_vendor = "apple",
|
||||
target_arch = "wasm32",
|
||||
target_os = "android",
|
||||
target_os = "nto",
|
||||
)))] {
|
||||
match fontconfig::find_families("sans-serif") {
|
||||
Ok(mut fallback_families) => {
|
||||
|
@ -179,6 +187,7 @@ fn init_fontdb() -> FontDatabase {
|
|||
target_vendor = "apple",
|
||||
target_arch = "wasm32",
|
||||
target_os = "android",
|
||||
target_os = "nto",
|
||||
)))]
|
||||
fontconfig_fallback_families,
|
||||
default_font_family_ids,
|
||||
|
@ -203,7 +212,13 @@ pub fn register_font_from_path(path: &std::path::Path) -> Result<(), Box<dyn std
|
|||
for face_info in db.faces() {
|
||||
match &face_info.source {
|
||||
fontdb::Source::Binary(_) => {}
|
||||
fontdb::Source::File(loaded_path) | fontdb::Source::SharedFile(loaded_path, ..) => {
|
||||
fontdb::Source::File(loaded_path) => {
|
||||
if *loaded_path == requested_path {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_os = "nto"))]
|
||||
fontdb::Source::SharedFile(loaded_path, ..) => {
|
||||
if *loaded_path == requested_path {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -232,13 +232,13 @@ impl FontCache {
|
|||
// replacing files. Unlinking OTOH is safe and doesn't destroy the file mapping,
|
||||
// the backing file becomes an orphan in a special area of the file system. That works
|
||||
// on Unixy platforms and on Windows the default file flags prevent the deletion.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(all(not(target_arch = "wasm32"), not(target_os = "nto")))]
|
||||
let (shared_data, face_index) = unsafe {
|
||||
sharedfontdb::FONT_DB.with_borrow_mut(|db| {
|
||||
db.make_mut().make_shared_face_data(fontdb_face_id).expect("unable to mmap font")
|
||||
})
|
||||
};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg(any(target_arch = "wasm32", target_os = "nto"))]
|
||||
let (shared_data, face_index) = crate::sharedfontdb::FONT_DB.with_borrow(|db| {
|
||||
db.face_source(fontdb_face_id)
|
||||
.map(|(source, face_index)| {
|
||||
|
@ -456,6 +456,7 @@ impl FontCache {
|
|||
target_vendor = "apple",
|
||||
target_arch = "wasm32",
|
||||
target_os = "android",
|
||||
target_os = "nto",
|
||||
)))]
|
||||
fn font_fallbacks_for_request(
|
||||
&self,
|
||||
|
@ -489,6 +490,21 @@ impl FontCache {
|
|||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "nto")]
|
||||
fn font_fallbacks_for_request(
|
||||
&self,
|
||||
_family: Option<&SharedString>,
|
||||
_pixel_size: PhysicalLength,
|
||||
_primary_font: &LoadedFont,
|
||||
_reference_text: &str,
|
||||
) -> Vec<SharedString> {
|
||||
[SharedString::from("Noto Sans")]
|
||||
.iter()
|
||||
.filter(|family_name| self.is_known_family(&family_name))
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn is_known_family(&self, family: &str) -> bool {
|
||||
self.available_families.contains(family)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue