-
Notifications
You must be signed in to change notification settings - Fork 14
add dlopen Cargo feature using dlib to load fontconfig at runtime #12
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
Conversation
bada199
to
0b9008c
Compare
instead of servo-fontconfig servo-fontconfig statically links a vendored fontconfig library if fontconfig is not found by pkgconfig. Using a vendored fontconfig library instead of the system fontconfig library doesn't actually work well though: slint-ui/slint#88 Building a vendored copy of fontconfig is also problematic because fontconfig has a lot of C dependencies, which makes it difficult to cross compile the vendored copy of fontconfig: $ pkg-config fontconfig --static --libs -lfontconfig -lfreetype -lz -lbz2 -lpng16 -lm -lm -lz -lharfbuzz -lm -lglib-2.0 -lm -lpcre -lsysprof-capture-4 -pthread -lgraphite2 -lbrotlidec -lbrotlicommon -lxml2 -lz -llzma -lm Instead of using a vendored copy, with yeslogic/fontconfig-rs#12 yeslogic-fontconfig-sys will have a Cargo feature to dlopen fontconfig at runtime instead of linking it at build time. This is exposed in font-kit with the new source-fontconfig-dlopen feature, which is disabled by default. This feature makes it considerably easier to cross compile by avoiding the need to cross compile fontconfig and all its dependencies.
instead of servo-fontconfig servo-fontconfig statically links a vendored fontconfig library if fontconfig is not found by pkgconfig. Using a vendored fontconfig library instead of the system fontconfig library doesn't actually work well though: slint-ui/slint#88 Building a vendored copy of fontconfig is also problematic because fontconfig has a lot of C dependencies, which makes it difficult to cross compile the vendored copy of fontconfig: $ pkg-config fontconfig --static --libs -lfontconfig -lfreetype -lz -lbz2 -lpng16 -lm -lm -lz -lharfbuzz -lm -lglib-2.0 -lm -lpcre -lsysprof-capture-4 -pthread -lgraphite2 -lbrotlidec -lbrotlicommon -lxml2 -lz -llzma -lm Instead of using a vendored copy, with yeslogic/fontconfig-rs#12 yeslogic-fontconfig-sys will have a Cargo feature to dlopen fontconfig at runtime instead of linking it at build time. This is exposed in font-kit with the new source-fontconfig-dlopen feature, which is disabled by default. This feature makes it considerably easier to cross compile by avoiding the need to cross compile fontconfig and all its dependencies.
instead of servo-fontconfig servo-fontconfig statically links a vendored fontconfig library if fontconfig is not found by pkgconfig. Using a vendored fontconfig library instead of the system fontconfig library doesn't actually work well though: slint-ui/slint#88 Building a vendored copy of fontconfig is also problematic because fontconfig has a lot of C dependencies, which makes it difficult to cross compile the vendored copy of fontconfig: $ pkg-config fontconfig --static --libs -lfontconfig -lfreetype -lz -lbz2 -lpng16 -lm -lm -lz -lharfbuzz -lm -lglib-2.0 -lm -lpcre -lsysprof-capture-4 -pthread -lgraphite2 -lbrotlidec -lbrotlicommon -lxml2 -lz -llzma -lm Instead of using a vendored copy, with yeslogic/fontconfig-rs#12 yeslogic-fontconfig-sys will have a Cargo feature to dlopen fontconfig at runtime instead of linking it at build time. This is exposed in font-kit with the new source-fontconfig-dlopen feature, which is disabled by default. The feature can be enabled by setting the RUST_FONTCONFIG_DLOPEN environment variable to avoid needing to propagate the Cargo feature all the way through downstream Cargo.toml's. This feature makes it considerably easier to cross compile by avoiding the need to cross compile fontconfig and all its dependencies.
I added build.rs's so setting the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall seems ok, a few things to fix up. I'd probably want sign off from the Slint folks that they will accept slint-ui/slint#956 so that we have a concrete use case before merging.
.travis.yml
Outdated
@@ -13,7 +13,7 @@ rust: | |||
- nightly | |||
- beta | |||
- stable | |||
- 1.38.0 | |||
- 1.43.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're going to need additional CI builds to check that it works with and without the dlopen
feature enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the beta and nightly CI jobs? If it works with stable, why wouldn't it work with beta and nightly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that sometimes incompatibilities are introduced in newer versions and this might catch that. However, that requires a CI cron job, which hasn't been set up so may as well remove them and speed up the build.
@@ -27,6 +27,11 @@ name = "fontconfig_sys" | |||
|
|||
[dependencies] | |||
const-cstr = "0.3" | |||
dlib = "0.5.0" | |||
lazy_static = "1.4.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to allow using any lazy_static
version in the >1.4 series so this version requirement can be 1.4
. Having said that there's ongoing work (See rust-lang/rfcs#2788 and rust-lang/rust#74465) to integrate once_cell into Rust so I would prefer to use that instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5029ed8
to
5a966c9
Compare
I find it confusing how fontconfig-sys has a use crate::fontconfig_sys::fontconfig as sys;
use crate::fontconfig_sys::ffi_dispatch;
#[cfg(feature = "dlopen")]
use sys::{LIB, LIB_RESULT};
#[cfg(not(feature = "dlopen"))]
use sys::*; I'd like to change this to: use crate::fontconfig_sys as sys;
use crate::fontconfig_sys::ffi_dispatch;
#[cfg(feature = "dlopen")]
use sys::{LIB, LIB_RESULT};
#[cfg(not(feature = "dlopen"))]
use sys::*; by moving the contents of fontconfig-sys/src/fontconfig.rs into fontconfig-sys/src/lib.rs. What do you think about this? |
It was confusing to have a fontconfig crate which depends on the fontconfig-sys crate which in turn has a module called fontconfig. This simplifies the paths so fontconfig-sys does not have any submodules; everything is in its lib.rs now. So import paths change from use fontconfig_sys::fontconfig::* to use fontconfig_sys::*
Seems fine, I think that structure was just inherited from the original project it was forked from. |
I have been discussing this with them and got the impression that they intend to merge slint-ui/slint#956 after this PR is merged. @tronical, @ogoffart, can one of you confirm this? |
instead of servo-fontconfig servo-fontconfig statically links a vendored fontconfig library if fontconfig is not found by pkgconfig. Using a vendored fontconfig library instead of the system fontconfig library doesn't actually work well though: slint-ui/slint#88 Building a vendored copy of fontconfig is also problematic because fontconfig has a lot of C dependencies, which makes it difficult to cross compile the vendored copy of fontconfig: $ pkg-config fontconfig --static --libs -lfontconfig -lfreetype -lz -lbz2 -lpng16 -lm -lm -lz -lharfbuzz -lm -lglib-2.0 -lm -lpcre -lsysprof-capture-4 -pthread -lgraphite2 -lbrotlidec -lbrotlicommon -lxml2 -lz -llzma -lm Instead of using a vendored copy, with yeslogic/fontconfig-rs#12 yeslogic-fontconfig-sys will have a Cargo feature to dlopen fontconfig at runtime instead of linking it at build time. This is exposed in font-kit with the new source-fontconfig-dlopen feature, which is disabled by default. The feature can be enabled by setting the RUST_FONTCONFIG_DLOPEN environment variable to avoid needing to propagate the Cargo feature all the way through downstream Cargo.toml's. This feature makes it considerably easier to cross compile by avoiding the need to cross compile fontconfig and all its dependencies.
I think switching Slint over to use yeslogic's fontconfig crate would be an improvement. I love you how folks are actively maintaining it and responding to feedback. |
Thanks for reviewing! Could you publish a new release to crates.io? |
Yes, once I have #13 passing on CI |
New crates have been published. |
instead of servo-fontconfig servo-fontconfig statically links a vendored fontconfig library if fontconfig is not found by pkgconfig. Using a vendored fontconfig library instead of the system fontconfig library doesn't actually work well though: slint-ui/slint#88 Building a vendored copy of fontconfig is also problematic because fontconfig has a lot of C dependencies, which makes it difficult to cross compile the vendored copy of fontconfig: $ pkg-config fontconfig --static --libs -lfontconfig -lfreetype -lz -lbz2 -lpng16 -lm -lm -lz -lharfbuzz -lm -lglib-2.0 -lm -lpcre -lsysprof-capture-4 -pthread -lgraphite2 -lbrotlidec -lbrotlicommon -lxml2 -lz -llzma -lm Instead of using a vendored copy, with yeslogic/fontconfig-rs#12 yeslogic-fontconfig-sys will have a Cargo feature to dlopen fontconfig at runtime instead of linking it at build time. This is exposed in font-kit with the new source-fontconfig-dlopen feature, which is disabled by default. The feature can be enabled by setting the RUST_FONTCONFIG_DLOPEN environment variable to avoid needing to propagate the Cargo feature all the way through downstream Cargo.toml's. This feature makes it considerably easier to cross compile by avoiding the need to cross compile fontconfig and all its dependencies.
switch to yeslogic-fontconfig-sys instead of servo-fontconfig servo-fontconfig statically links a vendored fontconfig library if fontconfig is not found by pkgconfig. Using a vendored fontconfig library instead of the system fontconfig library doesn't actually work well though: slint-ui/slint#88 Building a vendored copy of fontconfig is also problematic because fontconfig has a lot of C dependencies, which makes it difficult to cross compile the vendored copy of fontconfig: ``` $ pkg-config fontconfig --static --libs -lfontconfig -lfreetype -lz -lbz2 -lpng16 -lm -lm -lz -lharfbuzz -lm -lglib-2.0 -lm -lpcre -lsysprof-capture-4 -pthread -lgraphite2 -lbrotlidec -lbrotlicommon -lxml2 -lz -llzma -lm ``` Instead of using a vendored copy, with yeslogic/fontconfig-rs#12 yeslogic-fontconfig-sys will have a Cargo feature to dlopen fontconfig at runtime instead of linking it at build time. This is exposed in font-kit with the new source-fontconfig-dlopen feature, which is disabled by default. This feature makes it considerably easier to cross compile by avoiding the need to cross compile fontconfig and all its dependencies.
instead of servo-fontconfig servo-fontconfig statically links a vendored fontconfig library if fontconfig is not found by pkgconfig. Using a vendored fontconfig library instead of the system fontconfig library doesn't actually work well though: slint-ui/slint#88 Building a vendored copy of fontconfig is also problematic because fontconfig has a lot of C dependencies, which makes it difficult to cross compile the vendored copy of fontconfig: $ pkg-config fontconfig --static --libs -lfontconfig -lfreetype -lz -lbz2 -lpng16 -lm -lm -lz -lharfbuzz -lm -lglib-2.0 -lm -lpcre -lsysprof-capture-4 -pthread -lgraphite2 -lbrotlidec -lbrotlicommon -lxml2 -lz -llzma -lm Instead of using a vendored copy, with yeslogic/fontconfig-rs#12 yeslogic-fontconfig-sys will have a Cargo feature to dlopen fontconfig at runtime instead of linking it at build time. This is exposed in font-kit with the new source-fontconfig-dlopen feature, which is disabled by default. The feature can be enabled by setting the RUST_FONTCONFIG_DLOPEN environment variable to avoid needing to propagate the Cargo feature all the way through downstream Cargo.toml's. This feature makes it considerably easier to cross compile by avoiding the need to cross compile fontconfig and all its dependencies.
switch to yeslogic-fontconfig-sys instead of servo-fontconfig servo-fontconfig statically links a vendored fontconfig library if fontconfig is not found by pkgconfig. Using a vendored fontconfig library instead of the system fontconfig library doesn't actually work well though: slint-ui/slint#88 Building a vendored copy of fontconfig is also problematic because fontconfig has a lot of C dependencies, which makes it difficult to cross compile the vendored copy of fontconfig: ``` $ pkg-config fontconfig --static --libs -lfontconfig -lfreetype -lz -lbz2 -lpng16 -lm -lm -lz -lharfbuzz -lm -lglib-2.0 -lm -lpcre -lsysprof-capture-4 -pthread -lgraphite2 -lbrotlidec -lbrotlicommon -lxml2 -lz -llzma -lm ``` Instead of using a vendored copy, with yeslogic/fontconfig-rs#12 yeslogic-fontconfig-sys will have a Cargo feature to dlopen fontconfig at runtime instead of linking it at build time. This is exposed in font-kit with the new source-fontconfig-dlopen feature, which is disabled by default. This feature makes it considerably easier to cross compile by avoiding the need to cross compile fontconfig and all its dependencies.
Fixes #11
I modernized the code a bit along the way.