<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
  <HEAD>
    <META name="generator" content="HTML Tidy, see www.w3.org">
    <TITLE></TITLE>
  </HEAD>

  <BODY>
    <H1>Freefont, TrueType and patterns with The Gimp</H1>

    <H4>ArticleCategory:</H4>
    Graphics 

    <H4>AuthorImage:</H4>
    <IMG src="../../common/images/Andre-Pascual.jpg" alt=
    "[Photo of the author]" height="147" width="132"><BR>

    <H4>TranslationInfo:[Author + translation history. mailto: or http://homepage]</H4>
    <P>Original in fr <A href=
    "mailto:apascual@club-internet.fr">Andr&eacute; Pascual</A></P>

    <P>fr to en <A href="http://www.sarutherford.com">Scott
    Rutherford</A></P>

    <H4>AboutTheAuthor:</H4>

    <P>Originally an draughtsman, and now a teacher for manufacturing
    technology, specifically CAD.<BR>
    Design and desktop publishing, principally in 3D, is one of his
    passions.</P>

    <H4>Abstract:</H4>

    <P>The tutorials <A href="../July2000/article113.shtml">"Pseudo
    3D"</A> and <A href="../November1999/article112.html">"Effects of
    fire"</A> caused me to receive many emails, for the large part
    because of the difficulty of the proposed exercises. In fact, it
    was only a matter of difficulty for beginners. The experienced
    Linux user is not stopped by a missing font or pattern: he would
    soon install the fonts, or find a suitable path for saving, that
    wasn't the case with my correspondents. Everybody has been a
    beginner, and who still isn't in some area of Linux? So this
    article is aimed at the beginner, although even the purists won't
    be offended by the methods described.</P>
    <BR>
     

    <H4>ArticleIllustration:</H4>
    <IMG src="../../common/images/illustration99.gif" alt=
    "[Illustration]" hspace="10" height="100" width="100"> 

    <H4>ArticleBody:</H4>

    <H2>Preliminaries</H2>

    <P>Mandrake 8.0 and The Gimp 1.2.1 served as the reference packages
    for this article. If using different versions, directory structure,
    indexes or drop down menus may be different from those stated in
    this text. Should this be the case, adaptation to the specific
    configuration will be required.<BR>
    When discussing printed characters, I shall use the terms fonts and
    styles completely interchangeably. Fill patterns shall be referred
    to as either patterns or motifs. Instead of referring to XFree86,
    the official name, I shall say simply X.<BR>
     Similarly when referring to the Midnight Commander, which allows
    the management of files without in depth knowledge of the base
    functions of Linux and their plethora of options, I shall say MC.
    Users of Norton Commander and Xtree Gold under DOS, or WinCommander
    under Windows will find themselves on familiar territory. Right up
    to the function buttons which have the same allocations in MC as in
    WinCommander! Remember to be pragmatic. It is without doubt better
    to do something functional and clumsy than something sophisticated
    and non-functional.</P>
    <BR>
     

    <H2>Installation of Freefont and Sharefont</H2>

    <P>The script-fu's from Gimp use by default fonts that the different
    distributions may not install automatically. These fonts come in
    two packages: Freefont and Sharefont. The former is free, and the
    later is distributed under the shareware licence, but both are very
    interesting. Without a doubt they make a great difference to the
    presentation abilities of X.</P>

    <CENTER>
      <BR>
      <BR>
      <IMG src="../../common/images/article116/fig1_t1.jpg" alt=
      "[Figure 1]" width="619" height="573"><BR>
      Figure 1.
    </CENTER>
    <BR>
    <BR>

    <P>These two packages are available in .tgz archives thanks to <A
    href="mailto:clameter@waterf.org">Christoph Lameter</A> at the
    following address:<BR>
    Several sites on the internet (e.g <A href=
    "http://ibiblio.org/pub/Linux/X11/fonts/">http://ibiblio.org/pub/Linux/X11/fonts/</A>,
    ibiblio was formerly known as metalab or sunsite), and you can
    sometimes get them on the CD's found on the covers on magazines.
    Linux Magazine France number 9 provides them in a directory of it's
    accompanying CD, called /Gimp/fonts.<BR>
     Taking this as an example, the fonts can be installed as
    follows:</P>

    <UL>
      <LI>1.1 "mount" the CD</LI>

      <LI>1.2 launch MC</LI>

      <LI>1.3 in the right window, select the directory /Gimp/fonts
      from the CD or the directory to where you downloaded the
      files</LI>

      <LI>1.4 In the left window (or visa versa) select the directory
      /usr/X11R6/lib/X11/fonts on the hard drive</LI>

      <LI>1.5 Copy (F5) the archives freefont.tgz and sharefont.tgz to
      the selected directory on the hard drive</LI>

      <LI>1.6 Decompress the archives (F2 opens a menu, then choose to
      decompress the archive into the directory)</LI>
    </UL>

    <P>If this option is not on the menu, exit MC (F10), the cursor
    still pointing at the window containing the copied files. If you
    then take the trouble to add the following line to .bashrc:<BR>
    <CODE>mc () MC=`/usr/bin/mc -P "$@"`; [ -n "$MC" ] &amp;&amp; cd
    "$MC"; unset MC ;</CODE><BR>
    you will find yourself in the selected directory. If not, go there
    using<BR>
    <CODE>cd /usr/X11R6/lib/X11/fonts</CODE><BR>
    and then decompress directly using:<BR>
    <CODE>tar xvfz *.tgz</CODE><BR>
    </P>

    <P>This leaves you with two new directories, one called: freefont
    and the other called: sharefont. The .tgz archives can now be
    deleted.<BR>
    Freefont contains 79 fonts, nearly all usable, and Sharefont
    contains 22.</P>

    <CENTER>
      <BR>
      <BR>
      <IMG src="../../common/images/article116/fig2_t1.jpg" alt=
      "[Figure 2]" width="420" height="320"><BR>
      Figure 2.
    </CENTER>
    <BR>
    <BR>

    <P>Each directory also includes a special file called fonts.dir,
    which describes the characteristics of each font to X. This means
    that you don't need to run mkfontdir to generate this file.<BR>
    The fonts will be loaded by X the next time it is launched, but
    only if you first tell it that it needs to use them. In older
    distributions you had to add the following lines to
    /etc/X11/XF86Config, in the section labelled "Files":<BR>
    <CODE>FontPath "/usr/X11R6/lib/X11/fonts/freefont"<BR>
    FontPath "/usr/X11R6/lib/X11/fonts/sharefont"<BR>
    </CODE> However in Mandrake 8.0 a font server is used. To add the
    fonts to the font server path using the chkfontpath utility:<BR>
    <BR>
    chkfontpath --add /usr/X11R6/lib/X11/fonts/freefont/<BR>
    chkfontpath --add /usr/X11R6/lib/X11/fonts/sharefont/<BR>
    Restart the font server:<BR>
    <BR>
    /etc/rc.d/init.d/xfs restart</P>

    <P>If you are in graphical mode, and not in console mode, the
    instructions above are still valid if entered into a terminal
    (rxvt, kvt, wmterm...). However the fonts will not be available
    immediately; they will not be loaded without restarting X, or
    entering the following commands into the still open terminal:<BR>
    <CODE>xset fp+ /usr/X11R6/lib/X11/fonts/freefont<BR>
    xset fp rehash<BR>
    xset fp+ /usr/X11R6/lib/X11/fonts/sharefont<BR>
    Xset fp rehash</CODE></P>

    <H2>Results</H2>

    <P>In order to check that the fonts have been loaded run<BR>
    <BR>
    xlsfonts | egrep 'sharefont|freefont'<BR>
     or launch xfontsel, or simply the KDE font manager.<BR>
     The fonts are now usable by all (well not really) X
    applications.<BR>
     The fonts can be gathered into a table, like in this article, by
    using Gimp with the following commands:<BR>
    <CODE>xtns&gt; Script-Fu&gt; Utils&gt; Font Map.</CODE><BR>
    Important: it's a merciless tool. One error when entering the name
    of a font and you will be sent back to start again. The best way
    round this is to work with the KDE font manager open at the same
    time as the Gimp. That way you can see the name of the font in the
    manager at the same time as seeing it in the sample field. Figure 3
    shows several of these fonts, which are useful for creating
    whimsical logos or reference letters.<BR>
    </P>

    <CENTER>
      <BR>
      <IMG src="../../common/images/article116/fig3_t1.jpg" alt=
      "[Figure 3]" width="498" height="608"><BR>
      Figure 3.
    </CENTER>
    <BR>
    <BR>
     

    <H2>Using True Type</H2>

    <P>These newly installed fonts are interesting, but maybe you have
    a Windows partition on the hard drive, with it's legions of
    beautifully crafted True Type fonts? If you don't have windows then
    you can as well download True Type fonts from various sites on the
    net such as <A href=
    "http://hugemcgriffin.com/fonts/a/">http://hugemcgriffin.com/fonts/a/</A>,
    <A href="http://www.fontguy.com/">http://www.fontguy.com/</A>, <A
    href=
    "http://www.freepcfonts.com/index.html">http://www.freepcfonts.com/index.html</A>,
    ... It's possible to use them.<BR>
    The latest Linux distributions, and those still to come, naturally
    envisage their use. It is not the same in older distributions, like
    Mandrake 5.3<BR>
    That said, a least a solution exists. It comes in the form of a
    server called Xfstt (a simple executable file of a round 130 Kb
    after compilation) available at the following address (among
    others): <A href=
    "ftp://sunsite.unc.edu/pub/Linux/X11/fonts/">ftp://sunsite.unc.edu/pub/Linux/X11/fonts/</A>.</P>

    <P>The archive you want is called Xfstt-0.9.10.tgz (or the latest
    version) and is around 80Kb. The version numbers show that the
    program is still under development, but it functions without any
    major problems.<BR>
    Before compiling, it is necessary to prepare the terrain by
    creating a directory to receive the True Type fonts, such as
    /usr/share/fonts/truetype/ (mkdir /usr/share/fonts/truetype/ or F7
    in MC). Then, copy the required fonts into this directory, or
    create a symbolic link (F9 in MC, followed by File then Symlink)
    pointing towards the Fonts directory under Windows. In my setup,
    /usr/share/fonts/truetype/ contains the link winfonts which points
    towards /mnt/Win98/windows/fonts, where /mnt/Win98 is the mount
    point of my windows partition.<BR>
    The compilation of the program can now begin; to do this change to
    the directory created by decompressing the archive (/tmp/xfstt0910)
    and execute the following commands: <CODE>make xfstt &amp;&amp;
    make install<BR>
    </CODE> When the compilation has finished, the executable binary
    <CODE>xfstt</CODE> will be installed in /usr/X11R6/bin. It remains
    now to tell the server xfstt which fonts it will be using. Execute
    the command:<BR>
    <CODE>xfstt --sync --dir /usr/share/fonts/truetype</CODE><BR>
    This will have the effect of creating two description files in
    <CODE>/usr/share/fonts/truetype</CODE> called
    <CODE>ttinfo.dir</CODE> and <CODE>ttname.dir.</CODE><BR>
     The server is launched by using the command: <CODE>xfstt --dir
    /usr/share/fonts/truetype &amp;</CODE>.<BR>
    However on execution, it will appear that nothing has happened:
    these fonts are only available to X, not in text mode, and if you
    are in X then it will be necessary to tell X to load them. This can
    be achieved by entering the following command:<BR>
    <CODE>xset +fp unix/:7100</CODE><BR>
    Afterwards verify with "xlsfonts | grep ttf-" or xfontsel or the
    KDE font manager that the TrueType fonts are available; they should
    be usable by all (well nearly) applications that run under X.
    StarOffice5 allows their use in StarDraw, StarImpress, StarCalc,
    but strangely not in StarWriter, perhaps there is an option to
    activate it, but if so I couldn't find it. In any case, they are
    usable in the Gimp as you can see in figure 4. There is as well a
    freefont plugin for Gimp. If you have this plugin installed then
    you have yet another method to use TrueType fonts in Gimp. Unlinke
    the xfstt server the freefont plugin makes of course the fonts not
    generally available to all applications.</P>

    <CENTER>
      <BR>
      <BR>
      <IMG src="../../common/images/article116/fig4_t1.jpg" alt=
      "[Figure 4]" width="664" height="504"><BR>
      Figure 4.
    </CENTER>
    <BR>
    <BR>
     The program documentation states that it is possible to add to
    XF86Config, in the Files section the following line: FontPath
    "unix/:7100"; this however has never worked for me; it also talks
    about launching xfstt before starting X, then carrying out the
    other commands in a terminal, but at risk of forgetting them. The
    simplest approach is to automate things by writing 2 small scripts,
    one to launch the server and the other to close it. Don't forget to
    make the scripts executable (in MC, F9 then File and Chmod), and
    then save them in /usr/local/bin for example. The activation script
    could be called something like ttf, and the deactivation one dttf.
    The first contains the following lines: 
<PRE>
#!/bin/sh
xfstt --sync --dir /usr/share/fonts/truetype
xfstt &amp;
xfstt +fp unix/:7100
</PRE>

    <P>And the second contains simply:</P>
<PRE>
#!/bin/sh
xset -fp unix/:7100
</PRE>

    <P>This is the solution I use: it works.</P>

    <H2>Creating Patterns</H2>

    <P>The patterns (images) are nothing more than image bitmap files
    in the .pat format specific (but not actually copyrighted) to the
    Gimp, which are used to fill a surface with the aid of the "paint
    pot" tool. They are saved in the directory
    /usr/share/gimp/1.2/patterns/. Any further patterns created can be
    saved in this place, which will give all other users access, or in
    your home directory at ~/.gimp/patterns, in which case only you
    will be able to use these fonts.</P>

    <P>Suppose that we wanted to use the image in figure 5 to "paper"
    the background of an image.</P>

    <CENTER>
      <BR>
      <BR>
      <IMG src="../../common/images/article116/fig5_t1.jpg" alt=
      "[Figure 5]" width="144" height="143"><BR>
      Figure 5.
    </CENTER>
    <BR>
    <BR>
     

    <P>We could do it manually be coping and pasting but that is a bit
    longwinded and not very precise: the patterns will be moved to the
    nearest pixel! It is better to let the Gimp do it, and it will if
    the file to be repeated is of the right format, i.e. a .pat
    file.<BR>
    If this is not the case, you can remidy it as follows:<BR>
    </P>

    <UL>
      <LI>Load the candidate pattern into the Gimp</LI>

      <LI>Save it in one of the directories above, and take care to
      indicate that you want to save the file in the .pat format, like
      this:<BR>
      right click in the image&gt; Save as&gt; By extension&gt; Pat
      &gt; ~/.gimp/patterns/Tux1.pat&gt; ok</LI>

      <LI>Before saving, Gimp will ask for a name for the pattern, this
      is not the saving name, but an identifier; by default, the
      pattern is defined as GIMP Pattern. Call it Tuxdor.</LI>
    </UL>

    <P>Quit the Gimp, since the new pattern will be available on
    restarting, and re-launch it.<BR>
    In the tool box, click on File&gt;Dialogs&gt;Patterns. The Patterns
    Selection box appears and shows samples of all the available
    patterns; if you click on a sample, that one will be enlarged
    temporarily. Also, clicking on a sample selects the current
    pattern.<BR>
    Find the pattern Tuxdor, near the end of the list, as the patterns
    are listed alphabetically and select it for use.<BR>
    Create a new workspace with File&gt;New&gt;Width 288 Height 286
    (space for 4 patterns)<BR>
    double click on Fill with a colour or pattern (the paint pot) and
    select Pattern Fill.<BR>
    Click anywhere on the empty image and it will be filled by the
    golden Tuxdor:</P>

    <CENTER>
      <BR>
      <BR>
      <IMG src="../../common/images/article116/fig6_t1.jpg" alt=
      "[Figure 6]" width="330" height="358"><BR>
      Figure 6.
    </CENTER>
    <BR>
    <BR>
     

    <P>However the filling is not very aesthetically pleasing: the
    "seams" between the patterns are visible. This comes from the
    pattern itself, which wasn't created to enable tiling like this.
    Lets change that. Reopen the original figure 5. Right click on the
    image then<BR>
    &gt;Filters&gt; Map&gt; Make Seamless, we get a new image.</P>

    <CENTER>
      <BR>
      <BR>
      <IMG src="../../common/images/article116/fig7_t1.jpg" alt=
      "[Figure 7]" width="144" height="143"><BR>
      Figure 7.
    </CENTER>
    <BR>
    <BR>
     

    <P>Save this in the same place as Tux2.pat, with the identifier
    TuxTile. Quit the Gimp, re-launch, and make a new image of 432x392
    pixels. Fill this new image with the TuxTile pattern. Now we have a
    new image without seams, but looking a little military (of course
    that has it's place depending on the destination of the pattern).
    However the quality of the image is much better than the previous
    one.</P>

    <CENTER>
      <BR>
      <BR>
      <IMG src="../../common/images/article116/fig8_t1.jpg" alt=
      "[Figure 8]" width="474" height="471"><BR>
      Figure 8.
    </CENTER>
    <BR>
    <BR>
     

    <P>All the same one could want a softer image, more melded. In
    order to make an adequate pattern:</P>

    <UL>
      <LI>Reopen the original figure 5</LI>

      <LI>Right click on the image&gt; Filters &gt; Map&gt;
      Illusion&gt; 8&gt; OK</LI>

      <LI>we get a new image</LI>
    </UL>

    <CENTER>
      <BR>
      <BR>
      <IMG src="../../common/images/article116/fig9_t1.jpg" alt=
      "[Figure 9]" width="144" height="143"><BR>
      Figure 9.
    </CENTER>
    <BR>
    <BR>

    <UL>
      <LI>Save this again in the same place as Tux3.pat, with the
      identifier TuxIllus</LI>

      <LI>Quit the gimp, re-launch, and again prepare a new 432x392
      image</LI>

      <LI>Fill the new image with the TuxIllus pattern</LI>

      <LI>Now we have a colony of Tuxes. Is it attractive? Well that is
      a matter of taste!</LI>
    </UL>

    <CENTER>
      <BR>
      <BR>
      <IMG src="../../common/images/article116/fig10_t1.jpg" alt=
      "[Figure 10]" width="474" height="471"><BR>
      Figure 10.
    </CENTER>
    <BR>
    <BR>
     

    <H2>Provisional Conclusion</H2>

    <P><A href="../../common/images/article116/fig11_t1.jpg">The final
    image</A> shows what you can do with these charcter fonts, and the
    patterns other than those that come with the Gimp. The text was
    created using the Script-Fu logo; for sure it took some work to get
    it to look like that, but the same thing could be achieved by
    anybody. It is sufficient to explore the numerous possibilities the
    software offers, and to amuse yourself with them.</P>
  </BODY>
</HTML>