servo / font-kit

A cross-platform font loading library written in Rust
Apache License 2.0
660 stars 98 forks source link

font-kit fails to compile with slint #212

Closed tp971 closed 3 weeks ago

tp971 commented 1 year ago

When trying to build a project that depends on this project and slint at the same time, compilation fails.

Cargo.toml:

[package]
name = "something"
version = "0.1.0"
edition = "2021"

[dependencies]
font-kit = "0.11.0"
slint = "1.0.2"

Compilation errors:

error[E0425]: cannot find function, tuple struct or tuple variant `FcInitLoadConfigAndFonts` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:320:25
    |
320 |                         FcInitLoadConfigAndFonts,
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcConfigDestroy` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:333:21
    |
333 |                     FcConfigDestroy,
    |                     ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcPatternCreate` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:359:21
    |
359 |                     FcPatternCreate,
    |                     ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcNameParse` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:371:21
    |
371 |                     FcNameParse,
    |                     ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcPatternAddString` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:384:21
    |
384 |                     FcPatternAddString,
    |                     ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcConfigSubstitute` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:401:21
    |
401 |                     FcConfigSubstitute,
    |                     ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcDefaultSubstitute` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:415:21
    |
415 |                     FcDefaultSubstitute,
    |                     ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcFontSort` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:428:21
    |
428 |                     FcFontSort,
    |                     ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcFontList` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:452:21
    |
452 |                     FcFontList,
    |                     ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcPatternDestroy` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:473:21
    |
473 |                     FcPatternDestroy,
    |                     ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcPatternGetString` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:493:21
    |
493 |                     FcPatternGetString,
    |                     ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0699]: the type of this value must be known to call a method on a raw pointer on it
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:503:27
    |
503 |                 if string.is_null() {
    |                           ^^^^^^^

error[E0425]: cannot find function, tuple struct or tuple variant `FcPatternGetInteger` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:521:21
    |
521 |                     FcPatternGetInteger,
    |                     ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcFontSetDestroy` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:577:21
    |
577 |                     FcFontSetDestroy,
    |                     ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcObjectSetCreate` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:593:81
    |
593 |                     d: ffi_dispatch!(feature = "source-fontconfig-dlopen", LIB, FcObjectSetCreate,),
    |                                                                                 ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcObjectSetAdd` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:607:25
    |
607 |                         FcObjectSetAdd,
    |                         ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `FcObjectSetDestroy` in this scope
   --> /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/font-kit-0.11.0/src/sources/fontconfig.rs:623:21
    |
623 |                     FcObjectSetDestroy,
    |                     ^^^^^^^^^^^^^^^^^^ not found in this scope

Some errors have detailed explanations: E0425, E0699.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `font-kit` due to 17 previous errors
nununoisy commented 1 year ago

I can reproduce this on the latest stable Linux toolchain (1.70 at the time of writing). Weirdly enough, the build works as expected on the latest stable MSVC toolchain - normally I'd expect Windows to be more broken than Linux for build issues. Maybe Slint uses a different dependency on MSVC that doesn't cause a conflict?

tronical commented 1 year ago

The reason why this doesn't happen on Windows is because fontconfig is not a dependency for Slint on Windows. I suspect that this might be caused due to slint enabling the dynamic opening of fontconfig and perhaps that's why the functions aren't there. Could you try enabling the source-fontconfig-dlopen feature of font-kit?

tronical commented 1 year ago

With slint 1.1.0 release this should not be an issue anymore as the font logic dependency was removed.

jayvdb commented 3 weeks ago

@mrobinson @tp971 , this issue can be closed?