/***************************************************************************
 * fcbanner - banner using fontconfig
 * (C) Nicolas George - 2004-03-02
 ***************************************************************************/

/*
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 *  1. Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *  3. The name of the author may not be used to endorse or promote products
 *     derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*

About:

fcbanner is a variant on the banner program that uses fontconfig and
freetype to draw its characters. Thus, it can easily draw using various
fonts -- any font you can get in Gnome or Mozilla for example -- and handles
non-ASCII characters if they are present in the font.

Supported environment:

fcbanner runs on Unix-like systems provided that:
- they support the fontconfig and freetype libraries, of course;
- they support the wide characters API (wchar.h);
- the wchar_t coding coincides with Unicode.

This includes GNU/Linux, Solaris >= 8 with UTF-8 locales (but NOT on
monobyte locales!), FreeBSD >= 5.0, and maybe some other/older systems I
could not test.

If wchar_t is not Unicode-based, fcbanner will work but will probably give
strange results on non-ASCII characters.

Build:

gcc -Wall -W -std=c99 -D_XOPEN_SOURCE=600 -g -O3 -o fcbanner \
  `pkg-config --cflags freetype2 fontconfig` fcbanner.c \
  `pkg-config --libs freetype2 fontconfig`

Usage:

echo text | fcbanner -f font

See the Fontconfig User Guide for the generic syntax of the font
specification. The supported features for now are font size and font matrix.

The encoding of the input text is determined by the LC_CTYPE category of the
locale settings (LC_ALL, LC_CTYPE ou LANG environment variable).

Examples:

echo '&#x7121;' | recode html..utf8 | \
  LC_CTYPE=en_US.UTF-8 fcbanner -f 'AR PL KaitiM Big5:size=64'

Changes:

2005-06-15 Support font matrix. Version 1.0 release.

*/
