From Fedora Project Wiki

No edit summary
No edit summary
Line 3: Line 3:
The following annotated template is intended to help you understand the Fedora fonts packaging policy. A plain-text version without formatting or annotations is available in the [https://fedorahosted.org/rpmdevtools/browser/spectemplate-fonts.spec rpmdevtools package].
The following annotated template is intended to help you understand the Fedora fonts packaging policy. A plain-text version without formatting or annotations is available in the [https://fedorahosted.org/rpmdevtools/browser/spectemplate-fonts.spec rpmdevtools package].


== Conventions ==


{| style="font-family:monospace; background-color:#FFFAE9; font-family:monospace;"
{| style="font-family:monospace; background-color:#FFFAE9; font-family:monospace;"
|-
|+ Conventions
| Common directives
|- valign="top"
| style="font-family:sans-serif; font-style:italic; color:#00578E;" | Comment
| style="border-style:hidden;" | Common directives
|- style="background-color:#ffdebc;"
| style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" | Comment
| Only if you declare fontconfig rules
|- valign="top" style="background-color:#ffdebc;"
| style="font-family:sans-serif; font-style:italic; color:#990033;" | Comment
| style="border-style:hidden;" | Only if you declare [[Fontconfig_packaging_tips | fontconfig]] rules
|- style="background-color:#ffe4f5;"
| style="font-family:sans-serif; font-style:italic; color:#990033; border-style:hidden;" | Comment
| Some other optional part
|- valign="top" style="background-color:#ffe4f5;"
| style="font-family:sans-serif; font-style:italic; color:#663366;" | Comment
| style="border-style:hidden;" | Some other optional part
| style="font-family:sans-serif; font-style:italic; color:#663366; border-style:hidden;" | Comment
|}
|}


== Spec ==


{| style="font-family:monospace; background-color:#FFFAE9; font-family:monospace;"
{| style="font-family:monospace; background-color:#FFFAE9; font-family:monospace; border-style:hidden;"
|-
|+ Annotated fonts spec template
| width="60%" | %define fontname xxx
|- valign="top"
| width="40%" style="font-family:sans-serif; font-style:italic; color:#00578E;" | Upstream lowercased project name.
| width="60%" style="border-style:hidden;" | %define fontname ''…''
| width="40%" style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" | Upstream lowercased project name, without any '''fonts''' or '''font''' affix.
|-
|-
|
| style="border-style:hidden;" |
|
| style="border-style:hidden;" |
|-
|- valign="top"
| %define fontdir %{_datadir}/fonts/%{fontname}
| style="border-style:hidden;" | %define fontdir %{_datadir}/fonts/%{fontname}
| style="font-family:sans-serif; font-style:italic; color:#00578E;" | '''%{_datadir}/fonts''' is owned by the '''filesystem''' package.
| style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" | '''%{_datadir}/fonts''' is owned by the '''filesystem''' package.
|- style="background-color:#ffdebc;"
|- valign="top" style="background-color:#ffdebc;"
| %define fontconfdir %{_sysconfdir}/fonts/conf.d
| style="border-style:hidden;" | %define fontconfdir %{_sysconfdir}/fonts/conf.d
| style="font-family:sans-serif; font-style:italic; color:#990033;" | Owned by the filesystem package.
| style="font-family:sans-serif; font-style:italic; color:#990033; border-style:hidden;" | Owned by the '''filesystem''' package.
|-
|- valign="top"
|
| style="border-style:hidden;" |
|
| style="border-style:hidden;" |
|- style="background-color:#ffe4f5;"
|- valign="top" style="background-color:#ffe4f5;"
| %define archivename xxx
| style="border-style:hidden;" | %define archivename ''…''
| style="font-family:sans-serif; font-style:italic; color:#663366;" | Usually a mix of '''%{fontname}''' and '''%{version}'''.
| style="font-family:sans-serif; font-style:italic; color:#663366; border-style:hidden;" | Usually a mix of '''%{fontname}''' and '''%{version}'''.
|-
|- valign="top"
|
| style="border-style:hidden;" |
|
| style="border-style:hidden;" |
|-
|- valign="top"
| Name: %{fontname}-fonts
| style="border-style:hidden;" | Name: %{fontname}-fonts
| style="font-family:sans-serif; font-style:italic; color:#00578E;" | See also our grouping conventions.
| style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" | See also our [[Fonts_packaging_policy#grouping | grouping]] conventions.
|-
|- valign="top"
| Version:
| style="border-style:hidden;" | Version: ''…''
| style="font-family:sans-serif; font-style:italic; color:#00578E;" | When in doubt check the version field embedded in TTF files<ref>For example unsing '''nautilus'''</ref>. If upstream is not updating this field regularly, you'll have to resort to '''%{alphatag}s'''. If upstream is never updating this field, use the date of the most recent font file as version.
| style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" |
|-
* When in doubt check the '''version''' field embedded in TTF or OTF files<ref>For example by double-clicking on them in ''Nautilus''.</ref>.
| Release: X%{?dist}
* If upstream is not updating this field regularly, you'll have to resort to [[Packaging/NamingGuidelines#NonNumericRelease | %{alphatag}s]].
|
* If upstream is never updating this field, use the date of the most recent font file as version.
|-
|- valign="top"
| Summary: Xxx fonts
| style="border-style:hidden;" | Release: ''…''%{?dist}
|
| style="border-style:hidden;" |
|-
|- valign="top"
|
| style="border-style:hidden;" | Summary: ''…'' fonts
|
| style="border-style:hidden;" |
|-
|- valign="top"
| Group: User Interface/X
| style="border-style:hidden;" |
|
| style="border-style:hidden;" |
|-
|- valign="top"
| License: XXX
| style="border-style:hidden;" | Group: User Interface/X
| style="font-family:sans-serif; font-style:italic; color:#00578E;" | Make sure you've read and understand our legal page.
| style="border-style:hidden;" |
|-
|- valign="top"
URL:
| style="border-style:hidden;" | License: ''''
| style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" | Make sure you've read and understand our [[Legal_considerations_for_fonts | legal page]].
 
|- valign="top"
Source0: …/%{archivename}.xxx
| style="border-style:hidden;" | URL: ''…''
 
| style="border-style:hidden;" |
Source1: %{name}-fontconfig.conf
|- valign="top"
| style="border-style:hidden;" | Source0: ''…''/%{archivename}.''…''
 
| style="border-style:hidden;" |
Fontconfig ruleset for the fonts being packaged.
|- valign="top" style="background-color:#ffdebc;"
 
| style="border-style:hidden;" | Source1: %{name}-fontconfig.conf
| style="font-family:sans-serif; font-style:italic; color:#990033; border-style:hidden;" | [[Fontconfig_packaging_tips | Fontconfig ruleset]] for the fonts being packaged.
 
|- valign="top"
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
| style="border-style:hidden;" |
| style="border-style:hidden;" |
 
|- valign="top"
Or any other approved choice.
| style="border-style:hidden;" | BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 
| style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" | Or any other [[Packaging/Guidelines#BuildRoot | approved choice]].
BuildArch: noarch
|- valign="top"
| style="border-style:hidden;" | BuildArch: noarch
 
| style="border-style:hidden;" |
Conflicts: fontconfig<xxx
|- valign="top" style="background-color:#ffdebc;"
| style="border-style:hidden;" | Conflicts: fontconfig<''…''
 
| style="font-family:sans-serif; font-style:italic; color:#990033; border-style:hidden;" |
This directive will ensure concurrent fontconfig updating if your ruleset uses some new syntax fontconfig versions shipped in previous Fedora releases do not understand.
* This directive will ensure concurrent [[Fontconfig_packaging_tips | fontconfig]] updating if your ruleset uses some new syntax fontconfig versions shipped in previous Fedora releases do not understand.
Do not use a versioned Requires, as this will force fontconfig installation unconditionally.
* '''Do not''' use a versioned Requires, as this will force fontconfig installation unconditionally. Resources like fonts [[Fonts_packaging_policy#no-handler-deps | must not]] force the installation of a particular handler.
Resources like fonts must not force the installation of a particular handler.
|- valign="top"
 
| style="border-style:hidden;" | %description
| rowspan="2" style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" | Is the font style unusual, does it cover remarkable unicode blocks? Is the font intended for screen or print media, plain-text or fancy decoration uses?
 
|- valign="top"
%description
| style="border-style:hidden;" | ''…''
|- valign="top"
 
| style="border-style:hidden;" |
Is the font style unusual, does it cover remarkable unicode blocks? Is the font intended for screen or print media, plain-text or fancy decoration uses?
| style="border-style:hidden;" |
 
|- valign="top"
XXX…
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
|- valign="top"
 
| style="border-style:hidden;" | %prep
| style="border-style:hidden;" |
 
|- valign="top"
%prep
| style="border-style:hidden;" | %setup -q -n %{archivename}
| style="border-style:hidden;" |
 
|- valign="top"
%setup -q -n %{archivename}
| style="border-style:hidden;" |
| style="border-style:hidden;" |
 
|- valign="top"
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
|- valign="top"
 
| style="border-style:hidden;" | %build
%build
| rowspan="2" style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" | Try to [[Fonts_packaging_policy#build-from-sources | build fonts from source]].
|- valign="top"
 
| style="border-style:hidden;" |
Try to build fonts from source.
| style="border-style:hidden;" |
 
|- valign="top"
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
|- valign="top"
 
| style="border-style:hidden;" |
%install
| style="border-style:hidden;" |
|- valign="top"
 
| style="border-style:hidden;" | %install
rm -fr %{buildroot}
| style="border-style:hidden;" |
|- valign="top"
 
| style="border-style:hidden;" | rm -fr %{buildroot}
| style="border-style:hidden;" |
 
|- valign="top"
install -m 0755 -d %{buildroot}%{fontdir}
| style="border-style:hidden;" |
| style="border-style:hidden;" |
 
|- valign="top"
install -m 0644 -p xxx/*.ttf xxx/*.otf %{buildroot}%{fontdir}
| style="border-style:hidden;" | install -m 0755 -d %{buildroot}%{fontdir}
| style="border-style:hidden;" |
 
|- valign="top"
| style="border-style:hidden;" | install -m 0644 -p ''…/*.ttf'' ''…/*.otf'' %{buildroot}%{fontdir}
 
| style="border-style:hidden;" |
install -m 0755 -d %{buildroot}%{fontconfdir}
|- valign="top"
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
install -m 0644 -p %{SOURCE1} %{buildroot}%{fontconfdir}/XX-%{fontname}.conf
|- valign="top"
|- valign="top" style="background-color:#ffdebc;"
 
| style="border-style:hidden;" | install -m 0755 -d %{buildroot}%{fontconfdir}
For a discussion on the choice of XX, visit our fontconfig section.
| rowspan="2" style="font-family:sans-serif; font-style:italic; color:#990033; border-style:hidden;" | For a discussion on the choice of ''…'' visit our [[Fontconfig_packaging_tips | fontconfig page]].
 
|- valign="top" style="background-color:#ffdebc;"
| style="border-style:hidden;" | install -m 0644 -p %{SOURCE1} %{buildroot}%{fontconfdir}/''…''-%{fontname}.conf
 
|- valign="top"
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
%clean
|- valign="top"
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
rm -fr %{buildroot}
|- valign="top"
| style="border-style:hidden;" | %clean
 
| style="border-style:hidden;" |
|- valign="top"
 
| style="border-style:hidden;" | rm -fr %{buildroot}
| style="border-style:hidden;" |
 
|- valign="top"
%post
| style="border-style:hidden;" |
| style="border-style:hidden;" |
 
|- valign="top"
This ensures fontconfig indexes are refreshed if fontconfig is present on the system; if not the fontconfig package will create them itself on installation3. Note that while the use of %{fontdir} ensures fc-cache does not waste time on other fonts, it also makes any later %{fontdir} renaming unsafe.
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
The -f parameter forces a refresh in all cases4. It must be used in packages targeting pre-Fedora 9 releases.
|- valign="top"
 
| style="border-style:hidden;" | %post
if [ -x %{_bindir}/fc-cache ]; then
| rowspan="10" style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" |
 
* This ensures fontconfig indexes are refreshed if fontconfig is present on the system; if not the fontconfig package will create them itself on installation<ref>In compliance of our [[Fonts_packaging_policy#no-handler-deps | no-dependency]] policy.</ref>.
%{_bindir}/fc-cache -f %{fontdir} || :
* Note that while the use of '''%{fontdir}''' ensures '''fc-cache''' does not waste time on other fonts, it also makes any later '''%{fontdir}''' renaming unsafe.
 
* The '''-f''' parameter forces a refresh in all cases<ref>For example '''fc-cache''' currently relies on timestamps to detect if the font cache needs to be regenenerated, and they're not a reliable reference if the system clock was misconfigured in the past (if the BIOS clock was wrong at install-time). This should be fixed in fontconfig-2.5.</ref>. It must be used in packages targeting pre-Fedora 9 releases.
fi
|- valign="top
 
| style="border-style:hidden;" | if [ -x %{_bindir}/fc-cache ] ; then
%postun
|- valign="top
 
| style="border-style:hidden;" |    %{_bindir}/fc-cache -f %{fontdir} <nowiki>|| :</nowiki>
if [ "$1" = "0" ]; then
|- valign="top
 
| style="border-style:hidden;" | fi
if [ -x %{_bindir}/fc-cache ]; then
|- valign="top
 
| style="border-style:hidden;" |
%{_bindir}/fc-cache -f %{fontdir} || :
|- valign="top
 
| style="border-style:hidden;" |
fi
|- valign="top
 
| style="border-style:hidden;" | %postun
fi
|- valign="top
 
| style="border-style:hidden;" | if [ $1 -eq 0 -a -x %{_bindir}/fc-cache ] ; then
|- valign="top
 
| style="border-style:hidden;" |    %{_bindir}/fc-cache -f %{fontdir} <nowiki>|| :</nowiki>
|- valign="top
 
| style="border-style:hidden;" | fi
%files
|- valign="top"
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
%defattr(0644,root,root,0755)
|- valign="top"
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
Any other set of permission is almost certain to be a fonts packaging bug.
|- valign="top"
 
| style="border-style:hidden;" | %files
%doc *.txt
| style="border-style:hidden;" |
|- valign="top"
 
| style="border-style:hidden;" | %defattr(0644,root,root,0755)
| style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" | Any other set of permission is almost certain to be a fonts packaging bug.
 
|- valign="top"
%config(noreplace) %{fontconfdir}/XX-%{fontname}.conf
| style="border-style:hidden;" | %doc ''*.txt''
| style="border-style:hidden;" |
 
|- valign="top"
This is sufficient to drop a fontconfig ruleset that will be evaluated if fontconfig is installed, and will have no effects otherwise5.
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
|- valign="top" style="background-color:#ffdebc;"
 
| style="border-style:hidden;" | %config(noreplace) %{fontconfdir}/XX-%{fontname}.conf
%dir %{fontdir}
| style="font-family:sans-serif; font-style:italic; color:#990033; border-style:hidden;" | This is sufficient to drop a [[Fontconfig_packaging_tips | Fontconfig ruleset]] that will be evaluated if fontconfig is installed, and will have no effects otherwise<ref>See also our [[Fonts_packaging_policy#no-handler-deps | no-dependency]] policy.</ref>.
|- valign="top"
 
| style="border-style:hidden;" |
%{fontdir}/*.ttf
| style="border-style:hidden;" |
|- valign="top"
 
| style="border-style:hidden;" | %dir %{fontdir}
%{fontdir}/*.otf
| style="border-style:hidden;" |
|- valign="top"
 
| style="border-style:hidden;" | %{fontdir}/*.ttf
| style="border-style:hidden;" |
 
|- valign="top"
| style="border-style:hidden;" | %{fontdir}/*.otf
 
| style="border-style:hidden;" |
%changelog
|- valign="top"
| style="border-style:hidden;" |
 
| style="border-style:hidden;" |
Changelog in approved format.  
|- valign="top"
|- valign="top"
| style="border-style:hidden;" |
| style="border-style:hidden;" |
|- valign="top"
| style="border-style:hidden;" | %changelog
| rowspan="2" style="font-family:sans-serif; font-style:italic; color:#00578E; border-style:hidden;" | Changelog in [[Packaging/Guidelines#Changelogs | approved format]].
|- valign="top"
| style="border-style:hidden;" | ''…''
|}
|}


{{:Fonts_SIG_signature}}
{{:Fonts_SIG_signature}}
[[Category:Fonts packaging|Spec template]]
[[Category:Fonts packaging|Spec template]]

Revision as of 18:10, 15 June 2008

A page on Fedora Fonts

The following annotated template is intended to help you understand the Fedora fonts packaging policy. A plain-text version without formatting or annotations is available in the rpmdevtools package.


Conventions
Common directives Comment
Only if you declare fontconfig rules Comment
Some other optional part Comment


Annotated fonts spec template
%define fontname Upstream lowercased project name, without any fonts or font affix.
%define fontdir %{_datadir}/fonts/%{fontname} %{_datadir}/fonts is owned by the filesystem package.
%define fontconfdir %{_sysconfdir}/fonts/conf.d Owned by the filesystem package.
%define archivename Usually a mix of %{fontname} and %{version}.
Name: %{fontname}-fonts See also our grouping conventions.
Version:
  • When in doubt check the version field embedded in TTF or OTF files[1].
  • If upstream is not updating this field regularly, you'll have to resort to  %{alphatag}s.
  • If upstream is never updating this field, use the date of the most recent font file as version.
Release: %{?dist}
Summary: fonts
Group: User Interface/X
License: Make sure you've read and understand our legal page.
URL:
Source0: /%{archivename}.
Source1: %{name}-fontconfig.conf Fontconfig ruleset for the fonts being packaged.
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) Or any other approved choice.
BuildArch: noarch
Conflicts: fontconfig<
  • This directive will ensure concurrent fontconfig updating if your ruleset uses some new syntax fontconfig versions shipped in previous Fedora releases do not understand.
  • Do not use a versioned Requires, as this will force fontconfig installation unconditionally. Resources like fonts must not force the installation of a particular handler.
%description Is the font style unusual, does it cover remarkable unicode blocks? Is the font intended for screen or print media, plain-text or fancy decoration uses?
%prep
%setup -q -n %{archivename}
%build Try to build fonts from source.
%install
rm -fr %{buildroot}
install -m 0755 -d %{buildroot}%{fontdir}
install -m 0644 -p …/*.ttf …/*.otf %{buildroot}%{fontdir}
install -m 0755 -d %{buildroot}%{fontconfdir} For a discussion on the choice of visit our fontconfig page.
install -m 0644 -p %{SOURCE1} %{buildroot}%{fontconfdir}/-%{fontname}.conf
%clean
rm -fr %{buildroot}
%post
  • This ensures fontconfig indexes are refreshed if fontconfig is present on the system; if not the fontconfig package will create them itself on installation[2].
  • Note that while the use of %{fontdir} ensures fc-cache does not waste time on other fonts, it also makes any later %{fontdir} renaming unsafe.
  • The -f parameter forces a refresh in all cases[3]. It must be used in packages targeting pre-Fedora 9 releases.
if [ -x %{_bindir}/fc-cache ] ; then
%{_bindir}/fc-cache -f %{fontdir} || :
fi
%postun
if [ $1 -eq 0 -a -x %{_bindir}/fc-cache ] ; then
%{_bindir}/fc-cache -f %{fontdir} || :
fi
%files
%defattr(0644,root,root,0755) Any other set of permission is almost certain to be a fonts packaging bug.
%doc *.txt
%config(noreplace) %{fontconfdir}/XX-%{fontname}.conf This is sufficient to drop a Fontconfig ruleset that will be evaluated if fontconfig is installed, and will have no effects otherwise[4].
%dir %{fontdir}
%{fontdir}/*.ttf
%{fontdir}/*.otf
%changelog Changelog in approved format.


Idea.png
Fonts in Fedora
The Fonts SIG takes loving care of Fedora fonts. Please join this special interest group if you are interested in creating, improving, packaging, or just suggesting a font. Any help will be appreciated.
  1. For example by double-clicking on them in Nautilus.
  2. In compliance of our no-dependency policy.
  3. For example fc-cache currently relies on timestamps to detect if the font cache needs to be regenenerated, and they're not a reliable reference if the system clock was misconfigured in the past (if the BIOS clock was wrong at install-time). This should be fixed in fontconfig-2.5.
  4. See also our no-dependency policy.