1. Computing & Technology

Optimal Use of Fonts on Linux

From

6.3. Step 3: Create a .spec File With This Template

To build an RPM package you'll have to create a .spec file that provides instructions to the package builder on how to organize the files, package description, author, copyright, etc. We provide a template here that you can use to start your work. The template looks like this:

Example 1. The .spec file template


   

Name: myfonts

Summary: Collection of My Funny Fonts

Version: 1.0

Release: 1
License: GPL

Group: User Interface/X
Source: %{name}.tar.gz
BuildRoot: %{_tmppath}/build-root-%{name}
BuildArch: noarch
Requires: freetype
Packager: Avi Alkalay <avi unix sh>

Prefix: /usr/share/fonts
Url: http://myfonts.com/


%description

These are the fonts used in our marketing campaign, designed by our marketing agency specially for us.
The package includes the following fonts: Bodoni, Bodoni Black, Company Logo, Outline Company Logo, etc.


%prep

%setup -q -n %{name}

%build

%install
mkdir -p $RPM_BUILD_ROOT/%{prefix}
cp -r %{name}/ $RPM_BUILD_ROOT/%{prefix}


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,0755)
%{prefix}/%{name}


%post
{
ttmkfdir -d %{prefix}/%{name} \
-o %{prefix}/%{name}/fonts.scale
umask 133
/usr/X11R6/bin/mkfontdir %{prefix}/%{name}
/usr/sbin/chkfontpath -q -a %{prefix}/%{name}
[ -x /usr/bin/fc-cache ] && /usr/bin/fc-cache
} &> /dev/null || :


%preun
{
if [ "$1" = "0" ]; then
cd %{prefix}/%{name}
rm -f fonts.dir fonts.scale fonts.cache*
fi
} &> /dev/null || :

%postun
if [ "$1" = "0" ]; then
/usr/sbin/chkfontpath -q -r %{prefix}/%{name}
fi
[ -x /usr/bin/fc-cache ] && /usr/bin/fc-cache



%changelog

* Thu Dec 14 2002 Avi Alkalay <avi unix sh> 1.0
- Tested
- Ready for deployment
* Thu Dec 10 2002 Avi Alkalay <avi unix sh> 0.9
- First version of the template

You must change the following items to meet your package characteristic's (leave everything else untouched):

  •    Put the name of your package or font collection here.
  •    Put a brief summary about your package here.
  •    The version of the package.
  •    The usage license of your package here.
  •    The name of the person responsible for this package here.
  •    URL to get more info about this package or fonts here. This entire line can be removed if there is no URL to point to.
  •    A more detailed description about this fonts here.
  •    The evolution history of this package here. Must follow this layout.

This file must be named as the name of the package - myfonts.spec in our example. And you must put it under the main directory of the package. So in the end we'll have something like this:


   

bash$ cd ~/src
bash$ find myfonts
myfonts/
myfonts/myfonts.spec
myfonts/myfonts/
myfonts/myfonts/font1.ttf
myfonts/myfonts/font2.ttf
myfonts/myfonts/font3.ttf
...

* License

* Optimal Use of Fonts on Linux Index

©2012 About.com. All rights reserved.

A part of The New York Times Company.