Skip to content

Commit 069681b

Browse files
fschuttclaude
andcommitted
fix: don't use rayon on wasm (target-gated off) + bump 4.4.1
rayon is `[target.'cfg(not(target_family="wasm"))']`-only, but the `multithreading` feature could still be enabled on wasm — so `use rayon` in FcScanDirectoriesInner / FcParseFontFiles was reached without the crate, failing wasm32 builds (E0433 unresolved `rayon`). Gate both rayon paths on `all(feature="multithreading", not(target_family="wasm"))`; wasm falls back to the existing sequential path. wasm doesn't need rayon at all. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 283409b commit 069681b

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust-fontconfig"
3-
version = "4.4.0"
3+
version = "4.4.1"
44
authors = ["Felix Schütt <felix.schuett@maps4print.com>"]
55
edition = "2021"
66
license = "MIT"

src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4287,7 +4287,7 @@ fn FcParseFontBytesInner(font_bytes: &[u8], font_id: &str) -> Option<Vec<(FcPatt
42874287

42884288
#[cfg(all(feature = "std", feature = "parsing"))]
42894289
fn FcScanDirectoriesInner(paths: &[(Option<String>, String)]) -> Vec<(FcPattern, FcFontPath)> {
4290-
#[cfg(feature = "multithreading")]
4290+
#[cfg(all(feature = "multithreading", not(target_family = "wasm")))]
42914291
{
42924292
use rayon::prelude::*;
42934293

@@ -4300,7 +4300,9 @@ fn FcScanDirectoriesInner(paths: &[(Option<String>, String)]) -> Vec<(FcPattern,
43004300
.flatten()
43014301
.collect()
43024302
}
4303-
#[cfg(not(feature = "multithreading"))]
4303+
// wasm has no rayon (it's target-gated off), so even with `multithreading`
4304+
// enabled wasm falls back to the sequential path.
4305+
#[cfg(not(all(feature = "multithreading", not(target_family = "wasm"))))]
43044306
{
43054307
paths
43064308
.iter()
@@ -4352,7 +4354,7 @@ fn FcScanSingleDirectoryRecursive(dir: PathBuf) -> Vec<(FcPattern, FcFontPath)>
43524354
#[cfg(all(feature = "std", feature = "parsing"))]
43534355
fn FcParseFontFiles(files_to_parse: &[PathBuf]) -> Vec<(FcPattern, FcFontPath)> {
43544356
let result = {
4355-
#[cfg(feature = "multithreading")]
4357+
#[cfg(all(feature = "multithreading", not(target_family = "wasm")))]
43564358
{
43574359
use rayon::prelude::*;
43584360

@@ -4361,7 +4363,7 @@ fn FcParseFontFiles(files_to_parse: &[PathBuf]) -> Vec<(FcPattern, FcFontPath)>
43614363
.filter_map(|file| FcParseFont(file))
43624364
.collect::<Vec<Vec<_>>>()
43634365
}
4364-
#[cfg(not(feature = "multithreading"))]
4366+
#[cfg(not(all(feature = "multithreading", not(target_family = "wasm"))))]
43654367
{
43664368
files_to_parse
43674369
.iter()

0 commit comments

Comments
 (0)