1 # RPM macros for font packages.
3 # © 2008-2009 Nicolas Mailhot <nim at fedoraproject dot org>
7 # Font installation directory root
8 %_fontbasedir %{_datadir}/fonts
10 # Actual font installation directory
11 %_fontdir %{_fontbasedir}/%{?fontname:%{fontname}}%{?!fontname:%{name}}
13 # Master fontconfig configuration directory
14 # Only needed to avoid a circular directory dependency with the fontconfig
15 # package — you should *not* use this
16 %_fontconfig_masterdir %{_sysconfdir}/fonts
18 # Fontconfig directory for active configuration snippets
19 %_fontconfig_confdir %{_sysconfdir}/fonts/conf.d
21 # Fontconfig configuration template directory
22 # Templates are activated by symlinking in _fontconfig_confdir
23 %_fontconfig_templatedir %{_datadir}/fontconfig/conf.avail
27 # Utility macro that computes a canonical font (sub)package name
29 # Expects an (optional) subpackage name as argument
31 %_font_pkg_name() %{lua:
32 local function rpmeval(name)
33 local sname = rpm.expand(name)
37 sname = string.lower("-" .. sname .. "-")
38 sname = string.gsub(sname, "[_%-]+", "-")
39 sname = string.gsub(sname, "%-font(s?)%-", "-")
40 sname = string.gsub(sname, "^%-", "")
41 sname = string.gsub(sname, "%-$", "")
45 local function meld(name1,name2)
46 local name3 = "-" .. name2 .. "-"
47 for token in string.gmatch(name1 .. "-" , "..-%-") do
48 token = string.gsub(token, "%-", "%%-")
49 name3 = string.gsub(name3, "%-" .. token, "-")
51 return string.gsub( name1 .. name3 , "%-+$", "")
53 local pkgname = rpmeval("%{name}")
54 local fontname = rpmeval("%{fontname}")
55 local subname = rpmeval("%1")
56 print(meld(meld(pkgname,fontname),subname) .. "-fonts")
60 # Macro to generate file sections and scriptlets for font (sub)packages
63 # – an (optional) subpackage name as argument: -n <name>
64 # without -n the macro will work on the core package
65 # – an (optional) fontconfig file pattern as argument: -f <pattern>
66 # — a variable number of file patterns corresponding to the font files
67 # installed in _fontdir and associated to this (sub)package
69 # Files corresponding to the file pattern must be installed in
70 # _fontconfig_templatedir and symlinked to _fontconfig_confdir
72 # If you want to install a configuration template disabled by default, make
73 # the corresponding symlink point to /dev/null
76 %define spn %_font_pkg_name %{-n:%{-n*}} \
78 if [ -x %{_bindir}/fc-cache ]; then \
79 %{_bindir}/fc-cache %{_fontdir} || : \
84 if [ $1 -eq 0 -a -x %{_bindir}/fc-cache ] ; then \
85 %{_bindir}/fc-cache %{_fontdir} || : \
90 %defattr(0644,root,root,0755) \
94 for arg=1,rpm.expand("%#") do \
95 print(rpm.expand("%{_fontdir}/%" .. arg) .. "\\n") \
97 %{-f:%{_fontconfig_templatedir}/%{-f*}} \
98 %{-f:%config(noreplace) %{_fontconfig_confdir}/%{-f*} \