%global         freetype_version 2.9.1

Name:           fontconfig
Version:        2.13.1
Release:        2
Summary:        Fontconfig is a library for configuring and customizing font access
License:        MIT and Public Domain and UCD
URL:            http://fontconfig.org
Source0:        http://fontconfig.org/release/%{name}-%{version}.tar.bz2
Source1:        25-no-bitmap-fedora.conf
Source2:        fc-cache

#PATCH-FIX-https://bugzilla.redhat.com/show_bug.cgi?id=140335
Patch0:         %{name}-sleep-less.patch
Patch1:         %{name}-required-freetype-version.patch

BuildRequires:  expat-devel freetype-devel >= %{freetype_version} fontpackages-devel libuuid-devel
BuildRequires:  autoconf automake libtool gettext itstool gperf
Requires:       fontpackages-filesystem freetype >= 2.9.1  grep coreutils glibc font(:lang=en)
Suggests:       dejavu-sans-fonts

Provides:       %{name}-devel-doc
Obsoletes:      %{name}-devel-doc

%description
Fontconfig  provide different font according to requirements specified by applications,discover new fonts when installed automatically
be used in concert with the X Render Extension and FreeType to implement high quality, anti-aliased and subpixel rendered text on a display

%package        devel
Summary:        Font configuration and customization library
Requires:       %{name}%{?_isa} = %{version}-%{release} freetype-devel >= %{freetype_version} pkgconfig gettext

%description    devel
The fontconfig-devel package includes the header files,and developer docs for the fontconfig package.
Install fontconfig-devel if you want to develop programs which will use fontconfig.

%package        help
Summary:        Development Documentation files for fontconfig library
Buildarch:      noarch
Requires:       %{name}-devel = %{version}-%{release}

%description    help
The fontconfig-devel-doc package contains the documentation files which is useful for developing
applications that uses fontconfig.

%prep
%autosetup -n %{name}-%{version} -p1

%build
export HASDOCBOOK=no
autoreconf
%configure      --with-add-fonts=/usr/share/X11/fonts/Type1,/usr/share/X11/fonts/TTF,/usr/local/share/fonts \
                --disable-static --with-cache-dir=/usr/lib/fontconfig/cache
%make_build

%install
%make_install

find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'

install -p -m 0644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/fonts/conf.d
ln -s %{_fontconfig_templatedir}/25-unhint-nonlatin.conf $RPM_BUILD_ROOT%{_fontconfig_confdir}/

mv $RPM_BUILD_ROOT%{_docdir}/fontconfig/* .
rmdir $RPM_BUILD_ROOT%{_docdir}/fontconfig/

mv $RPM_BUILD_ROOT%{_bindir}/fc-cache $RPM_BUILD_ROOT%{_bindir}/fc-cache-%{__isa_bits}

install -p -m 0755 %{SOURCE2} $RPM_BUILD_ROOT%{_bindir}/fc-cache

%find_lang %{name}
%find_lang %{name}-conf
cat %{name}-conf.lang >> %{name}.lang

%check
make check

%post
%{?ldconfig: %ldconfig}

umask 0022

install -d /usr/lib/fontconfig/cache

[[ -d %{_localstatedir}/cache/fontconfig ]] && rm -rf %{_localstatedir}/cache/fontconfig/* 2> /dev/null || :

HOME=/root /usr/bin/fc-cache -f

%ldconfig_postun

%transfiletriggerin -- /usr/share/fonts /usr/share/X11/fonts/Type1 /usr/share/X11/fonts/TTF /usr/local/share/fonts
HOME=/root /usr/bin/fc-cache -s

%transfiletriggerpostun -- /usr/share/fonts /usr/share/X11/fonts/Type1 /usr/share/X11/fonts/TTF /usr/local/share/fonts
HOME=/root /usr/bin/fc-cache -s

%files -f %{name}.lang
%defattr(-,root,root)
%doc README AUTHORS
%doc fontconfig-user.txt fontconfig-user.html
%doc %{_fontconfig_confdir}/README
%license COPYING
%config %{_fontconfig_masterdir}/fonts.conf
%config(noreplace) %{_fontconfig_confdir}/*.conf
%dir /usr/lib/fontconfig/cache
%{_libdir}/libfontconfig.so.*
%{_bindir}/fc-*
%{_fontconfig_templatedir}/*.conf
%{_datadir}/xml/fontconfig

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

%files help
%doc fontconfig-devel.txt fontconfig-devel
%{_mandir}/man1/*
%{_mandir}/man5/*
%{_mandir}/man3/*

%changelog
* Wed Sep 11 2019 openEuler jimmy<dukaitian@huawei.com> - 2.13.1-2
- Package init jimmy
