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

switch to yeslogic-fontconfig-sys instead of servo-fontconfig #192

Merged
merged 2 commits into from
Mar 28, 2022

Conversation

Be-ing
Copy link
Contributor

@Be-ing Be-ing commented Feb 15, 2022

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.

To get rid of a compiler warning
@Be-ing Be-ing marked this pull request as draft February 15, 2022 23:38
@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 15, 2022

This is a draft until yeslogic/fontconfig-rs#12 is merged upstream.

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 15, 2022

See also:
servo/libfontconfig#65
yeslogic/fontconfig-rs#11

Having two different -sys crates for fontconfig has created a messy situation because Cargo will refuse to build if two -sys crates link the same library by specifying link = "fontconfig" in Cargo.toml. It would be great if we could converge on one and deprecate the other. If you agree to drop servo-fontconfig, I'd be happy to make pull request's for servo-fontconfig's other reverse dependencies to switch them to yeslogic-fontconfig-sys.

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 16, 2022

PR to switch Slint to yeslogic-fontconfig-sys from servo-fontconfig: slint-ui/slint#956

@Be-ing Be-ing force-pushed the dlopen branch 3 times, most recently from 0b61077 to 68d461e Compare February 22, 2022 04:56
@Be-ing Be-ing marked this pull request as ready for review February 22, 2022 04:56
@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 22, 2022

This is a draft until yeslogic/fontconfig-rs#12 is merged upstream.

That was merged and released upstream. This is ready for review.

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 22, 2022

Hi @jdm are you still maintaining this crate?

@jdm
Copy link
Member

jdm commented Mar 27, 2022

This seems like a reasonable path forwards. Thanks!
@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 68d461e has been approved by jdm

@bors-servo
Copy link
Contributor

⌛ Testing commit 68d461e with merge 60812fd...

bors-servo added a commit that referenced this pull request Mar 27, 2022
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.
@bors-servo
Copy link
Contributor

💔 Test failed - checks-github

@jdm
Copy link
Member

jdm commented Mar 27, 2022

Can you run cargo fmt?

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.
@Be-ing
Copy link
Contributor Author

Be-ing commented Mar 28, 2022

Okay, I ran cargo fmt.

@jdm
Copy link
Member

jdm commented Mar 28, 2022

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 4130e14 has been approved by jdm

@bors-servo
Copy link
Contributor

⌛ Testing commit 4130e14 with merge 75f99cf...

@bors-servo
Copy link
Contributor

☀️ Test successful - checks-github
Approved by: jdm
Pushing 75f99cf to master...

@bors-servo bors-servo merged commit 75f99cf into servo:master Mar 28, 2022
@Be-ing
Copy link
Contributor Author

Be-ing commented Mar 28, 2022

Thanks for merging. Could you publish a new release of the crate?

@jdm
Copy link
Member

jdm commented Mar 28, 2022

Done.

@Be-ing Be-ing deleted the dlopen branch April 5, 2022 01:52
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

Successfully merging this pull request may close these issues.

3 participants