File fontconfig.spec of Package fontconfig

#
# spec file for package fontconfig
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           fontconfig
%define lname   libfontconfig1
Version:        2.16.0
Release:        0
Summary:        Library for Font Configuration
License:        MIT
Group:          System/Libraries
URL:            https://www.freedesktop.org/wiki/Software/fontconfig/
Source0:        https://www.freedesktop.org/software/fontconfig/release/fontconfig-%{version}.tar.xz
Source4:        baselibs.conf
Source5:        local.conf
# Patches available at https://github.com/bohoomil/fontconfig-ultimate/archive/master.zip
Source6:        fontconfig-ultimate-master.tar.bz2
Patch1:         skip-network-test.patch
Patch2:         fontconfig-autoconf269.patch
BuildRequires:  automake >= 1.11
BuildRequires:  gperf
BuildRequires:  libtool
BuildRequires:  pkgconfig
BuildRequires:  python3-base
BuildRequires:  pkgconfig(expat)
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(json-c)
BuildRequires:  pkgconfig(uuid)
Provides:       ipa-fonts-config = 003.02
Obsoletes:      ipa-fonts-config < 003.02
Provides:       IPA-fonts-config = 003.02
Obsoletes:      IPA-fonts-config < 003.02

%description
Fontconfig is a library for configuring and customizing font access. It
contains two essential modules: the configuration module, which builds
an internal configuration from XML files, and the matching module,
which accepts font patterns and returns the nearest matching font.

%lang_package

%package -n %{lname}
Summary:        Library for font configuration
Group:          System/Libraries
Requires:       %{name}

%description -n %{lname}
Fontconfig is a library for configuring and customizing font access. It
contains two essential modules: the configuration module, which builds
an internal configuration from XML files, and the matching module,
which accepts font patterns and returns the nearest matching font.

%package doc
Summary:        Documentation for fontconfig
Group:          Documentation/Other
BuildArch:      noarch

%description doc
Extended documentation for the fontconfig library.

%package devel
Summary:        Header files for fontconfig
Group:          Development/Libraries/C and C++
Requires:       %{lname} = %{version}
Requires:       gettext-devel
Requires:       glibc-devel
Requires:       pkgconfig(freetype2)

%description devel
This package countains all include files, libraries, configuration
files needed for compiling applications which use the fontconfig
library.

%package devel-doc
Summary:        Developer documentation for libfontconfig
Group:          Documentation/Other
BuildArch:      noarch

%description devel-doc
HTML documentation and manual pages for developers using the
fontconfig library.

%prep
%setup -q
tar -xf %{SOURCE6} --strip-components=1
cp -r fontconfig_patches_git/*.patch .

%patch -P 1 -p1

# bohoomil.com infinality-ultimate patches
patches=(
         01-configure.patch
         02-configure.ac.patch
         03-Makefile.in.patch
         04-Makefile.conf.d.patch
         05-Makefile.am.in.patch)

# infinality & post release fixes
for patch in "${patches[@]}"; do
    patch -Np1 -i ${patch}
done

# use suse-specific doc path:
find -name \*.1 -o -name \*.sgml -exec sed -i -e 's/usr\/share\/doc\/fontconfig/usr\/share\/doc\/packages\/fontconfig/g' {} +
autoreconf -fi

%build
# We don't want to rebuild the docs, but we want to install the included ones.
export HASDOCBOOK=no
%configure \
        --docdir=%{_docdir}/%{name} \
        --disable-silent-rules \
        --with-arch=%{_host_cpu} \
        --disable-static \
  	--disable-libxml2 \
  	--with-templateinfdir=%{_datadir}/%{name}/conf.avail.infinality \
  	--with-templatedir=%{_datadir}/%{name}/conf.avail \
  	--with-add-fonts=%{_prefix}/X11R6/lib/X11/fonts,/opt/kde3/share/fonts,%{_prefix}/local/share/fonts
make %{?_smp_mflags}

%check
export MALLOC_CHECK_=2
make %{?_smp_mflags} check
unset MALLOC_CHECK_

%install
%make_install
find %{buildroot} -type f -name "*.la" -delete -print
# package /etc/fonts/conf.avail for compatibility reasons
mkdir %{buildroot}%{_sysconfdir}/fonts/conf.avail

# copy presets
cp -r fontconfig_patches/{combi,free,ms} %{buildroot}%{_datadir}/fontconfig/conf.avail.infinality

# install fc-presets
install -m755 fontconfig_patches/"fc-presets" %{buildroot}/usr/bin/"fc-presets"

# copy font settings
install -m755 -d %{buildroot}/%{_docdir}/%{name}/fonts-settings
cp fontconfig_patches/fonts-settings/*.conf %{buildroot}/%{_docdir}/%{name}/fonts-settings

install -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/fonts
for i in 1 3 5
do
    mkdir -p %{buildroot}/%{_mandir}/man${i}/
    for j in fc-*/*.${i} doc/*.${i} doc/*/*.${i}
    do
        test -f ${j} && install -m 644 ${j} %{buildroot}/%{_mandir}/man${i}/
    done
    gzip --best %{buildroot}/%{_mandir}/man${i}/*.${i}
done

install -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/fonts
# tune links in conf.d
#pushd %{buildroot}%{_sysconfdir}/fonts/conf.d
#    mv 50-user.conf 56-user.conf
#    rm 51-local.conf
#    ln -s ../local.conf 55-local.conf
    # leave place for 60-family-prefer.conf from fonts-config
#    mv 60-latin.conf 61-latin.conf
#popd

mkdir -p %{buildroot}/%{_docdir}/%{name}
%find_lang %{name}
%find_lang %{name}-conf

%post   -n %{lname} -p /sbin/ldconfig
%postun -n %{lname} -p /sbin/ldconfig

%files
%license COPYING
%{_bindir}/*
%dir %{_sysconfdir}/fonts
%dir %{_sysconfdir}/fonts/conf.d
# packaging /etc/fonts/conf.avail for compatibility reasons
%dir %{_sysconfdir}/fonts/conf.avail
%config %{_sysconfdir}/fonts/fonts.conf
%config %{_sysconfdir}/fonts/conf.d/*.conf
%config(noreplace) %{_sysconfdir}/fonts/local.conf
%{_sysconfdir}/fonts/conf.d/README
%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/conf.avail
%dir %{_datadir}/%{name}/conf.avail.infinality
%dir %{_datadir}/%{name}/conf.avail.infinality/ms
%dir %{_datadir}/%{name}/conf.avail.infinality/combi
%dir %{_datadir}/%{name}/conf.avail.infinality/free
%{_datadir}/%{name}/conf.avail/*.conf
%{_datadir}/%{name}/conf.avail.infinality/*.conf
%{_datadir}/%{name}/conf.avail.infinality/ms/*.conf
%{_datadir}/%{name}/conf.avail.infinality/combi/*.conf
%{_datadir}/%{name}/conf.avail.infinality/free/*.conf
%dir %{_datadir}/xml/%{name}
%{_datadir}/xml/%{name}/fonts.dtd
%dir %{_localstatedir}/cache/fontconfig/
%dir %{_docdir}/%{name}
%dir %{_docdir}/%{name}/fonts-settings
%doc %{_docdir}/%{name}/fonts-settings/*.conf
%{_mandir}/man5/fonts-conf.5%{ext_man}
%{_mandir}/man1/*

%files lang -f %{name}.lang -f %{name}-conf.lang

%files doc
%doc AUTHORS NEWS README.md
%dir %{_docdir}/%{name}
%{_docdir}/%{name}/fontconfig-user.html
%{_docdir}/%{name}/fontconfig-user.pdf
%{_docdir}/%{name}/fontconfig-user.txt

%files devel
%{_libdir}/pkgconfig/fontconfig.pc
%{_libdir}/libfontconfig.so
%{_includedir}/fontconfig/
%dir %{_datadir}/gettext/its/
%{_datadir}/gettext/its/fontconfig.*

%files devel-doc
%{_docdir}/%{name}/fontconfig-devel.html
%{_docdir}/%{name}/fontconfig-devel.pdf
%{_docdir}/%{name}/fontconfig-devel.txt
%{_mandir}/man3/*

%files -n %{lname}
%{_libdir}/libfontconfig.so.*

%changelog
openSUSE Build Service is sponsored by