servo / pathfinder

A fast, practical GPU rasterizer for fonts and vector graphics
Apache License 2.0
3.52k stars 198 forks source link

pathfinder_export is not on crates.io #521

Open asattely opened 1 year ago

asattely commented 1 year ago

I'm a little new to the whole rust ecosystem, so please forgive me if this is a dumb thing to report. I was able to find all of the modular crates on crates.io that I tried except for pathfinder_export. Is there an easy way to use it in my project without downloading the whole master branch and using it locally?

s3bk commented 1 year ago

You can use

pathfinder_export = { git = "https://github.com/servo/pathfinder" }
asattely commented 1 year ago

I've done that and for some reason it's saying that the Scene object I've created is of a different type, since the git version seems to be interacting with a different definition of 'Scene' than the crates.io version: image

Could be wrong about that though. I am using renderer 0.5.0, which seems to be the newest as far as I'm aware.

asattely commented 1 year ago

Using this dependencies section in my cargo.toml:

[dependencies]
gcd = "2.1.0"
bitflags = "1.2.1"
rustc-hash = "1.1.0"
font-kit = "0.6"

pathfinder_canvas = { features = ["pf-text"], version = "0.5" }
pathfinder_geometry = { version = "0.5" }
pathfinder_renderer = { version = "0.5" }
pathfinder_resources = { version = "0.5" }
pathfinder_export = { git = "https://github.com/servo/pathfinder", version = "0.1" }
s3bk commented 1 year ago

Yes, it can get quite messy. I use all git dependencies but the internally reference crates.io versions, so it needs a patch section with a few entries:

[patch.crates-io]
pathfinder_geometry = { git = "https://github.com/servo/pathfinder" }
pathfinder_renderer = { git = "https://github.com/servo/pathfinder" }
...
asattely commented 1 year ago

Thank you! I added that to the end of my Cargo.toml and it solved the issue for me. Thanks a lot for your help, and sorry for the unnecessary issue opening.

Tails commented 1 year ago

@asattely could you post the complete Cargo.toml that worked for you? I'm trying the patch but I'm still getting the same Scene error. Here is mine:

pathfinder_canvas = { version="0.5", features=["pf-text"] }
pathfinder_geometry = "0.5"
pathfinder_content  = "0.5"
pathfinder_renderer  = "0.5"
pathfinder_export  = {git = "https://github.com/servo/pathfinder"}

hex_color = "2"
csscolorparser = "0.6.2"
async-channel = "1.7.1"
tokio = { version="1", features = ["full"] }

[patch.crates-io]
pathfinder_geometry = { git = "https://github.com/servo/pathfinder" }
pathfinder_renderer = { git = "https://github.com/servo/pathfinder" }
pathfinder_content = { git = "https://github.com/servo/pathfinder" }

And the error:

error[E0277]: the trait bound `Scene: pathfinder_export::Export` is not satisfied
wasmedge_1  |   --> lib/partage_prerendering/src/canvas/pathfinder.rs:39:13
wasmedge_1  |    |
wasmedge_1  | 38 |         Ok(pathfinder_export::Export::export(
wasmedge_1  |    |            --------------------------------- required by a bound introduced by this call
wasmedge_1  | 39 |             &scene,
wasmedge_1  |    |             ^^^^^^ the trait `pathfinder_export::Export` is not implemented for `Scene`
wasmedge_1  |    |
wasmedge_1  |    = help: the trait `pathfinder_export::Export` is implemented for `pathfinder_renderer::scene::Scene`
s3bk commented 1 year ago

You at least need to add pathfinder_gpu as well. And then all other pathfinder crates that show up twice in cargo.lock.

Tails commented 1 year ago

Thanks for your reply. So, add all the pathfinder_ crates to the [patch.crates-io] list, not as a straight dependency?

s3bk commented 1 year ago

Yes.

Tails commented 1 year ago

For future reference, make sure the following section is defined in the project's workspace root:

[patch.crates-io]
pathfinder_geometry = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_canvas = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_renderer = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_content = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_simd = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_gl = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_webgl = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_gpu = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_resources = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_color = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_lottie = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_magicleap_demo = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_ui = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_svg = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_metal = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_swf = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_text = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }
pathfinder_web_canvas = { commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder" }

And the sub-crate defines the deps as normally:


pathfinder_canvas = { version="0.5", features=["pf-text"] }
pathfinder_geometry = "0.5.1"
pathfinder_content = "0.5"
pathfinder_renderer = "0.5"
pathfinder_export = {commit="9e0331742dedfed41d9e7791a9afbead0e0fbcd5", git = "https://github.com/servo/pathfinder"}