fontconfig: Branch 'main' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 17 02:56:39 UTC 2025


 .gitlab-ci/build.sh                          |    2 
 .gitlab-ci/other.yml                         |    4 -
 Cargo.lock                                   |   95 ++++++++++++++++++++++++++-
 Cargo.toml                                   |    9 ++
 fc-fontations/meson.build                    |    6 +
 fc-fontations/pattern_bindings/fc_wrapper.rs |    2 
 fc-fontations/pattern_bindings/mod.rs        |   16 +++-
 meson.build                                  |   40 +++++++++++
 src/meson.build                              |   71 +++++++-------------
 test/meson.build                             |    7 +
 10 files changed, 196 insertions(+), 56 deletions(-)

New commits:
commit bf8067f55facf838f40933827837011b016311c5
Merge: c1bdf4f 02b835b
Author: Akira TAGOH <akira at tagoh.org>
Date:   Thu Apr 17 02:56:33 2025 +0000

    Merge branch 'buildSteps' into 'main'
    
    [Fontations] Factor out fcpat.c to library and add Fontations
    
    See merge request fontconfig/fontconfig!376

commit 02b835b622d8ec43030c649dbdb03b98393520d2
Author: Dominik Röttsches <drott at chromium.org>
Date:   Fri Apr 4 18:20:37 2025 +0300

    [Fontations] Factor out fcpat.c - add Fontations dependencies
    
    * Add Fontations dependencies to build steps
    * Update Cargo.toml to include Fontations
    * Clamp meson to 1.6.1, to address Cargo autolib issue, see
      https://github.com/mesonbuild/meson/commit/9ce23e8a199288a9b5edff91e134fe1188eb2af2
    * Factor out fcpat.c into its own static library to be able to
      share it between the FontConfig C code and the Fontations adapter
      code
    
    Changelog: added

diff --git a/.gitlab-ci/build.sh b/.gitlab-ci/build.sh
index 9d1e71b..765ddf4 100755
--- a/.gitlab-ci/build.sh
+++ b/.gitlab-ci/build.sh
@@ -139,7 +139,7 @@ if [ x"$buildsys" == "xautotools" ]; then
     fi
 elif [ x"$buildsys" == "xmeson" ]; then
     TASK="pip install"
-    pip install meson
+    pip install meson==1.6.1
 #   tomli not required for Python >= 3.11
     pip install tomli
     pip install pytest pytest-tap requests
diff --git a/.gitlab-ci/other.yml b/.gitlab-ci/other.yml
index 36d50d7..3424d6d 100644
--- a/.gitlab-ci/other.yml
+++ b/.gitlab-ci/other.yml
@@ -19,7 +19,7 @@
     #   -Dbar=disabled
   before_script:
     # Make sure meson is up to date, so we don't need to rebuild the image with each release
-    - pip3 install -U meson certifi tomli requests
+    - pip3 install -U meson==1.6.1 certifi tomli requests
     # Test Rust availability. As of 11/25/2024, according to
     # https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/ci/docker/windows/Dockerfile
     # Rust 1.82 is already installed.
@@ -72,7 +72,7 @@ meson vs2019 x86:
   before_script:
     - pip3 install --upgrade pip
     # Make sure meson is up to date
-    - pip3 install -U meson
+    - pip3 install -U meson==1.6.1
     # For Python < 3.11 we need tomli for Rust build support
     - pip3 install -U tomli
     # Need to install certificates for python
diff --git a/Cargo.lock b/Cargo.lock
index 156bffc..a54014f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,13 +1,38 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
-version = 3
+version = 4
+
+[[package]]
+name = "bytemuck"
+version = "1.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540"
+dependencies = [
+ "bytemuck_derive",
+]
+
+[[package]]
+name = "bytemuck_derive"
+version = "1.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ecc273b49b3205b83d648f0690daa588925572cc5063745bfe547fe7ec8e1a1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
 
 [[package]]
 name = "fc-fontations"
 version = "0.1.0"
 dependencies = [
+ "bytemuck",
+ "bytemuck_derive",
  "fc-fontations-bindgen",
+ "font-types",
  "libc",
+ "read-fonts",
+ "skrifa",
 ]
 
 [[package]]
@@ -17,8 +42,72 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "font-types"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b3971f9a5ca983419cdc386941ba3b9e1feba01a0ab888adf78739feb2798492"
+dependencies = [
+ "bytemuck",
+]
+
 [[package]]
 name = "libc"
-version = "0.2.165"
+version = "0.2.171"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.94"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.40"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "read-fonts"
+version = "0.23.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a252609f83421102bf1b7f08936f5a24e4f9568256e2015fbd027790caf3dcb"
+dependencies = [
+ "bytemuck",
+ "font-types",
+]
+
+[[package]]
+name = "skrifa"
+version = "0.24.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "69a99d1c6428e12bcf538d34fd4b78a4e6a4556db29f319a1cecfc33f466e64c"
+dependencies = [
+ "bytemuck",
+ "read-fonts",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fcb4d3d38eab6c5239a362fa8bae48c03baf980a6e7079f063942d563ef3533e"
+checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
diff --git a/Cargo.toml b/Cargo.toml
index 6feaf0c..56bcb91 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,10 +1,17 @@
 [package]
 name = "fc-fontations"
 version = "0.1.0"
+edition = "2021"
 
 [dependencies]
 fc-fontations-bindgen = { path = "./fc-fontations-bindgen" }
-libc = "0.2"
+libc = "0.2.150"
+read-fonts = { version = "0.23", features = [ "experimental_traverse" ]}
+font-types = { version = "0.7", features = ["bytemuck"]}
+skrifa = "0.24"
+bytemuck = { version = "1.19.0" , features = [ 'derive', 'min_const_generics'] }
+bytemuck_derive = "1"
+
 
 [lib]
 path = "fc-fontations/mod.rs"
diff --git a/fc-fontations/meson.build b/fc-fontations/meson.build
index fd06081..213671e 100644
--- a/fc-fontations/meson.build
+++ b/fc-fontations/meson.build
@@ -41,12 +41,16 @@ if (fontations.enabled())
   fc_fontations = static_library(
     'fc_fontations',
     sources: ['mod.rs'],
-    link_with: [bindgen_lib, libfontconfig],
+    link_with: [bindgen_lib, pattern_lib],
     rust_abi: 'c',
     dependencies: [
       dependency('libc-0.2-rs'),
+      dependency('read-fonts-0.23-rs'),
+      dependency('skrifa-0.24-rs'),
+      dependency('libc-0.2-rs')
 
     ],
+    install: true,
 
   )
 
diff --git a/fc-fontations/pattern_bindings/fc_wrapper.rs b/fc-fontations/pattern_bindings/fc_wrapper.rs
index e3ad063..d7f034c 100644
--- a/fc-fontations/pattern_bindings/fc_wrapper.rs
+++ b/fc-fontations/pattern_bindings/fc_wrapper.rs
@@ -22,7 +22,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
- use fc_fontations_bindgen::fcint::{
+use fc_fontations_bindgen::fcint::{
     FcPattern, FcPatternCreate, FcPatternDestroy, FcRange, FcRangeCopy, FcRangeCreateDouble,
     FcRangeDestroy,
 };
diff --git a/fc-fontations/pattern_bindings/mod.rs b/fc-fontations/pattern_bindings/mod.rs
index 0174487..62efe16 100644
--- a/fc-fontations/pattern_bindings/mod.rs
+++ b/fc-fontations/pattern_bindings/mod.rs
@@ -22,7 +22,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
- extern crate fc_fontations_bindgen;
+extern crate fc_fontations_bindgen;
 
 mod fc_wrapper;
 
@@ -46,6 +46,18 @@ pub enum PatternValue {
     Range(FcRangeWrapper),
 }
 
+impl From<CString> for PatternValue {
+    fn from(item: CString) -> Self {
+        PatternValue::String(item)
+    }
+}
+
+impl From<bool> for PatternValue {
+    fn from(item: bool) -> Self {
+        PatternValue::Boolean(item)
+    }
+}
+
 #[derive(Debug)]
 pub struct PatternElement {
     object_id: i32,
@@ -54,7 +66,7 @@ pub struct PatternElement {
 
 impl PatternElement {
     #[allow(unused)]
-    fn new(object_id: i32, value: PatternValue) -> Self {
+    pub fn new(object_id: i32, value: PatternValue) -> Self {
         Self { object_id, value }
     }
 }
diff --git a/meson.build b/meson.build
index c7c5406..c710b16 100644
--- a/meson.build
+++ b/meson.build
@@ -1,12 +1,16 @@
 project('fontconfig', 'c',
   version: '2.16.2',
-  meson_version : '>= 1.6.0',
+  meson_version : '>= 1.6.1',
   default_options: [
     'c_std=c11,c99',
     'buildtype=debugoptimized',
+  'bytemuck-1-rs:feature-derive=true',
+  'bytemuck-1-rs:feature-min_const_generics=true',
+  'read-fonts-0.23-rs:feature-experimental_traverse=true',
   ]
 )
 
+
 fs = import('fs')
 
 fc_version = meson.project_version()
@@ -493,6 +497,7 @@ ft_alias_headers = custom_target('ft_alias_headers',
 
 tools_man_pages = []
 
+
 # Do not reorder
 subdir('fc-case')
 subdir('fc-lang')
@@ -500,8 +505,41 @@ subdir('src')
 
 if get_option('fontations').enabled()
   subdir('fc-fontations')
+  lib_fontconfig_link_with_libs += [fc_fontations]
+endif
+
+if get_option('default_library') in ['both', 'shared']
+  libfontconfig = both_libraries('fontconfig',
+    lib_fontconfig_sources,
+    c_shared_args: win_export_args,
+    soversion: soversion,
+    version: libversion,
+    darwin_versions: osxversion,
+    kwargs: lib_fontconfig_kwargs)
+  libfontconfig_internal = libfontconfig.get_static_lib()
+else
+  libfontconfig = static_library('fontconfig', lib_fontconfig_sources, kwargs: lib_fontconfig_kwargs)
+  libfontconfig_internal = libfontconfig
 endif
 
+fontconfig_dep = declare_dependency(link_with: libfontconfig,
+  include_directories: incbase,
+  dependencies: deps,
+)
+
+pkgmod.generate(libfontconfig,
+  description: 'Font configuration and customization library',
+  filebase: 'fontconfig',
+  name: 'Fontconfig',
+  requires_private: ['freetype2 ' + freetype_req],
+  version: fc_version,
+  variables: [
+    'sysconfdir=@0@'.format(join_paths(prefix, get_option('sysconfdir'))),
+    'localstatedir=@0@'.format(join_paths(prefix, get_option('localstatedir'))),
+    'confdir=@0@'.format(fc_baseconfigdir),
+    'cachedir=@0@'.format(fc_cachedir),
+  ])
+
 if not get_option('tools').disabled()
   subdir('fc-cache')
   subdir('fc-cat')
diff --git a/src/meson.build b/src/meson.build
index 2680c5b..fe585eb 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,4 +1,23 @@
-fc_sources = [
+
+win_export_args = []
+# Define FcPublic appropriately for exports on windows
+if host_machine.system() == 'windows'
+  win_export_args += '-DFcPublic=__declspec(dllexport)'
+  win_export_args += '-DDLL_EXPORT'
+endif
+
+# Factor our pattern manipulation code into its own library
+# to break the depedency cycle:
+# FontConfig pattern handling - Fontations code - FontConfig.
+pattern_sources = [ 'fcpat.c', fcstdint_h.to_list() ]
+pattern_lib = static_library('patternlib_internal',
+                                    pattern_sources,
+                                    include_directories: incbase,
+                                    dependencies: [deps],
+                                    c_args: win_export_args
+                    )
+
+fc_sources = files([
   'fcatomic.c',
   'fccache.c',
   'fccfg.c',
@@ -19,7 +38,6 @@ fc_sources = [
   'fcmatrix.c',
   'fcname.c',
   'fcobjs.c',
-  'fcpat.c',
   'fcrange.c',
   'fcserialize.c',
   'fcstat.c',
@@ -27,7 +45,8 @@ fc_sources = [
   'fcweight.c',
   'fcxml.c',
   'ftglue.c',
-]
+])
+
 
 fcobjshash_h = cc.preprocess('fcobjshash.gperf.h', include_directories: incbase)
 fcobjshash_gperf = custom_target(
@@ -43,48 +62,14 @@ fcobjshash_h = custom_target('fcobjshash.h',
   command: [gperf, '--pic', '-m', '100', '@INPUT@', '--output-file', '@OUTPUT@']
 )
 
-lib_sources = [fc_sources, alias_headers, ft_alias_headers, fclang_h, fccase_h, fcobjshash_h, fcstdint_h]
-lib_kwargs = {
+lib_fontconfig_link_with_libs =  [pattern_lib]
+
+
+lib_fontconfig_sources = [fc_sources, alias_headers, ft_alias_headers, fclang_h, fccase_h, fcobjshash_h, fcstdint_h]
+lib_fontconfig_kwargs = {
   'include_directories': incbase,
   'dependencies': [deps, math_dep],
+  'link_with': lib_fontconfig_link_with_libs,
   'install': true,
 }
 
-if get_option('default_library') in ['both', 'shared']
-  # Define FcPublic appropriately for exports on windows
-  fc_c_shared_args = []
-  if host_machine.system() == 'windows'
-    fc_c_shared_args += '-DFcPublic=__declspec(dllexport)'
-    fc_c_shared_args += '-DDLL_EXPORT'
-  endif
-
-  libfontconfig = both_libraries('fontconfig',
-    lib_sources,
-    c_shared_args: fc_c_shared_args,
-    soversion: soversion,
-    version: libversion,
-    darwin_versions: osxversion,
-    kwargs: lib_kwargs)
-  libfontconfig_internal = libfontconfig.get_static_lib()
-else
-  libfontconfig = static_library('fontconfig', lib_sources, kwargs: lib_kwargs)
-  libfontconfig_internal = libfontconfig
-endif
-
-fontconfig_dep = declare_dependency(link_with: libfontconfig,
-  include_directories: incbase,
-  dependencies: deps,
-)
-
-pkgmod.generate(libfontconfig,
-  description: 'Font configuration and customization library',
-  filebase: 'fontconfig',
-  name: 'Fontconfig',
-  requires_private: ['freetype2 ' + freetype_req],
-  version: fc_version,
-  variables: [
-    'sysconfdir=@0@'.format(join_paths(prefix, get_option('sysconfdir'))),
-    'localstatedir=@0@'.format(join_paths(prefix, get_option('localstatedir'))),
-    'confdir=@0@'.format(fc_baseconfigdir),
-    'cachedir=@0@'.format(fc_cachedir),
-  ])
diff --git a/test/meson.build b/test/meson.build
index 2daf683..a7b2637 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -29,6 +29,10 @@ if host_machine.system() != 'windows'
   endif
 endif
 
+link_with_libs = [libfontconfig_internal]
+if get_option('fontations').enabled()
+  link_with_libs += [fc_fontations]
+endif
 
 foreach test_data : tests + tests_not_parallel
   fname = test_data[0]
@@ -37,10 +41,11 @@ foreach test_data : tests + tests_not_parallel
   extra_deps = opts.get('dependencies', [])
 
   test_name = fname.split('.')[0].underscorify()
+
   exe = executable(test_name, fname,
     c_args: c_args + extra_c_args,
     include_directories: incbase,
-    link_with: [libfontconfig_internal],
+    link_with: link_with_libs,
     dependencies: extra_deps,
   )
 


More information about the Fontconfig mailing list