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

Make flate2/zlib feature optional to enable compiling to WASM. #50

Closed
ajrcarey opened this issue Dec 23, 2021 · 4 comments
Closed

Make flate2/zlib feature optional to enable compiling to WASM. #50

ajrcarey opened this issue Dec 23, 2021 · 4 comments

Comments

@ajrcarey
Copy link

ajrcarey commented Dec 23, 2021

Thank you for such a useful crate! As currently implemented, the use of the flate2/zlib feature in Cargo.toml prevents compiling to WASM, since zlib is not available. Would it be possible to make this dependency optional? Something like the following would do it:

[package]
name = "allsorts"
version = "0.6.0"
authors = ["YesLogic Pty. Ltd. <[email protected]>"]
edition = "2018"

homepage = "https://github.com/yeslogic/allsorts"
documentation = "https://docs.rs/crate/allsorts"
repository = "https://github.com/yeslogic/allsorts"

readme = "README.md"
license = "Apache-2.0"
include = ["/LICENSE", "src/**/*"]

description = "Font parser, shaping engine, and subsetter for OpenType, WOFF, and WOFF2"
keywords = ["font", "shaping", "opentype", "truetype", "parse"]
categories = ["text-processing"]

[dependencies]
bitflags = "1.0"
bitreader = "0.3.2"
brotli-decompressor = "2.3"
byteorder = "1.2"
encoding_rs = "0.8.16"
flate2 = { version = "1.0", default-features = false }
glyph-names = "0.1"
itertools = "0.8"
lazy_static = "1.3.0"
libc = "0.2"
log = "0.4"
num-traits = "0.2"
ouroboros = "0.9"
rustc-hash = "1.1.0"
tinyvec = { version = "1", features = ["alloc"] }
ucd-trie = "0.1.2"
unicode-canonical-combining-class = "0.1.0"
unicode-general-category = "0.3"
unicode-joining-type = "0.4.0"

# Optional dependencies
pathfinder_geometry = { version = "0.5.1", optional = true }

[dev-dependencies]
regex = "1.1.6"

# criterion = "0.3"

# [[bench]]
# name = "bench-shape"
# harness = false

# [[bench]]
# name = "bench-read"
# harness = false

[features]
default = ["outline", "zlib"]
prince = []
outline = ["pathfinder_geometry"]
zlib = ["flate2/zlib"]
miniz_oxide = ["flate2/default"]

The flate2/zlib feature is now exposed by allsorts/zlib, which is added to the default features. So by default everything remains exactly the same. But now consumers who want to compile to WASM (or other scenarios where zlib is not available) can remove that feature and use the allsorts/miniz_oxide feature instead.

No doubt there's other, possibly more elegant, ways of doing this, but this seems a simple enough solution.

Possibly related to #7.

@wezm
Copy link
Contributor

wezm commented Dec 24, 2021

That seems reasonable. Most of the YesLogic folks are on leave at the moment. We should be able to add this in the new year. I return 11 Jan, feel free to ping me at the end of that week if you haven't heard anything by then.

@wezm wezm closed this as completed Jan 11, 2022
@wezm
Copy link
Contributor

wezm commented Jan 11, 2022

I've pushed a change to implement this. I hope to make a release this week but we've got a few other tweaks in the works that I'd like to include so will hold off for a day or so.

@ajrcarey
Copy link
Author

Many thanks, I look forward to the next release.

@wezm
Copy link
Contributor

wezm commented Jan 14, 2022

New release has been published.

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