Albedo Systems




CFX_FONT V2.0

Generate text graphics on the fly or from a database source

Copyright Albedo Systems Ltd 1997
http://www.albedo.co.uk/
24 October 1997

CONTENTS SUMMARY
CFX_FONT is a C++ extension tag to Allaire's Cold Fusion active web page language that allows the generation of multi-coloured, anti-aliased text graphics within Cold Fusion web pages.

Provided that a set of the appropriate font graphics is available (some are supplied, but they can be created to order), the tag allows vertical and horizontal alignment, spacing, and background and foreground colours all to be specified. The background can also be rendered transparent. This version (2.0) also allows a starter GIF to be input and enables absolute X/Y placing of both the starter gif and the text. It also includes a random 'jiggle' factor for producing crazy text. A demo of the tag is available at http://www.albedo.co.uk/goodies/cfusion.cfm

The program makes use of Tom Boutell's excellent GD1.2 GIF graphics library - for more information on this see http://www.boutell.com/. Please try to credit, or link, to the boutell.com site somewhere, because they really deserve it. It is recommended that the tag designation be CFX_FONT.

CONDITIONS
CFX_font 2.0 is shareware/linkware. It may be freely distributed in the form of this zip file, provided this readme file is retained. The standard fee for use is $15 (US), or £10 (UK). On a linkware basis, if you provide a link to our site, and tell us about it, we will waive the fee.

We're afraid that we must ask for snail-mail international money orders or UK cheques (primitive we know, but it's early days). Please make them payable to Albedo Systems Ltd and send them to...

Albedo Systems Ltd
268 Amhurst Road
Stoke Newington
London N16 7UP
United Kingdom

All technical queries with regard to the use of CFX_FONT should be addressed to admin@albedo.co.uk. If you use our software we'd, of course, appreciate it if you credited us/linked to us, but you know you don't have to. We'll be doing more stuff soon, so please do drop by our website at http://www.albedo.co.uk/

For more information on Cold Fusion itself, check out Allaire's site at http://www.allaire.com/

WHY USE CFX_FONT?
There are two reasons you might want to use this tag:

1. To generate pretty text (as opposed to jaggy old HTML) dynamically on the fly in order to impress the hell out of users. Text gifs are small (don't overdo it and remember to use ALT tags), and this program shouldn't give your server too much grief, providing you don't go mad. If in doubt, ask your server administrator.

2. Even better, you can generate a whole slew of (for example) text headings offline, say from a database. Believe me, this can save you days. Time is money...

INSTALLATION
The zip file that contains this file should contain:

readme.txt: this file.
readme.htm: HTML version of this file
cfx_font.dll: the Cold Fusion extension.
Three ready made fonts (85 gifs each):
Courier Bold (24pt)
Times New Roman (24pt)
Arial Bold (48pt)

Note that with a decent graphics package such as Adobe Photoshop, you can create your own fonts.

To get started, decide, or get your server admin person to decide, where you are going to put extension Cold Fusion tags on your server, then put cfx_font.dll in that directory. Then fire up the Cold Fusion administrator program - With Cold Fusion 2 on O'Reilly Website, it's called cfmadm20.exe in website/cfusion/bin. Cold Fusion 3 uses a different method - the administrator program is itself written in Cold Fusion, and is in website/cfide/administrator.

Click on the 'cfx tags' tab or button, then click on Add. Enter your chosen name (we recommend CFX_FONT), and decide if the library is to be persistent - if you're using it on the Web to generate graphics on the fly, you may only want to run it once in a session - whereas if you're generating a whole slew of graphics from a database, you may want to keep it memory-resident to optimise the batch run.


USAGE
Here's an example, with all the attributes on separate lines to make it clear... (Bear in mind that not all of these parameters are mandatory).

<CFX_FONT
STRING="#username#"
FONT="d:\FONTS\ArialB48\"
GIF="d:\MYSITE\HTDOCS\myname.gif"
WIDTH=300
HEIGHT=200
TRACK="1"
ALIGN="LEFT"
VALIGN="CENTER"
BGCOLOR="##FF0000"
FGCOLOR="##000000"
TRANSPARENT="N"
INPUT_GIF="d:\MYSITE\HTDOCS\input.gif"
ABS_X=20
ABS_Y=60
IN_X=50
IN_Y=100
TILE="N"
JIGGLE=3
>

...which can then be followed some time later, if you are generating these dynamically...

<CFOUTPUT>
<IMG SRC="myname.gif" WIDTH=#text_width# HEIGHT=#text_height# BORDER=0 ALT="#username#">
</CFOUTPUT>

...depending on where your site root directory is.

Taking the last first, note that #text_width# and #text_height# are variables returned by the tag that hold the true width/height of the output gif (I'll explain why these are needed shortly). If you are using these names they will be overwritten.
But to the parameters...

STRING (mandatory) is the text you want to render. In the example above, I'm assuming that you have captured the user's name as a CF variable to display it. This string could of course be a field from an database query.

FONT (mandatory) points to the directory containing your chosen font. Don't forget the trailing slash.

GIF (mandatory) is the specification for the output GIF.

WIDTH and HEIGHT (both optional, default to the minimum needed) need some explanation. If you leave these out, the tag will create a gif just big enough to contain the specified string. This will still be the minimum-sized gif if you put them in and they are smaller than the size needed (i.e. this program never truncates letters), but you can create a much larger gif, and have the text (say) in the top right corner. This will be especially important to v2.0 users, who will be able to use this program as a multi-pass facility and feed the output from one operation into the next.

TRACK (optional, defaults to 1). Distance in pixels between the characters - can be negative, if you want to get weird.

ALIGN (optional, defaults to LEFT): Horizontal alignment of the text within the gif. Can take the values LEFT, CENTER or RIGHT.

VALIGN (optional, defaults to CENTER): Vertical alignment of the text within the gif. Can take the values TOP, CENTER or BOTTOM.

BGCOLOR (optional, defaults to FFFFFF (white)). Background colour for the text, expressed as ##rrggbb hex value. Note the Cold Fusion double hash.

FGCOLOR (optional, defaults to 000000 (black)). Foreground colour for the text, expressed as ##rrggbb hex value. Note the Cold Fusion double hash.

TRANSPARENT (optional, defaults to NO). If set to "YES" makes the gif's background colour transparent. You may still want to set the BGCOLOR to something similar to your page background, as this will give your text better anti-aliasing.

Extra Version 2.0 parameters...
INPUT_GIF (optional, defaults to nothing). The path spec for an input gif that is used as the background for the new design. With this attribute, progressive layers of text can be built up. The gif can be positioned and/or tiled (see later).

ABS_X (optional, defaults to NULL). X coordinate of the text generated. If an ALIGN parameter was specified, this attribute overrides it.

ABS_Y (optional, defaults to NULL). Y coordinate of the text generated. If a VALIGN parameter was specified, this attribute overrides it.

IN_X (optional, defaults to NULL). X coordinate of the input gif.

IN_Y (optional, defaults to NULL). Y coordinate of the input gif.

TILE (optional, defaults to "N"). If Yes, the input gif is tiled across the background, starting at its x,y coordinates.

JIGGLE (optional, defaults to 0). A fun parameter. This specifies a maximum random number n. If non-zero, each text character is shifted by a random amount x where -n <= x <= n on the x axis and y where -n <= y <= n on the y axis. Oh well, just try it and see.

A WORD ON FONTS
The toughest part of the process with CFX_font (as you might have noticed) is that you have to generate a whole bunch of GIFs every time you want a new font. With upper and lower case, numbers and most of the punctuation, that means more than 80 gifs. Three sets are supplied, and we'll supply more to V2.0 users, but you may want to consider making your own, so bear the following in mind.

  • Use a decent graphics package that anti-aliases the fonts properly.
  • Each character must be named according to its ASCII code, with leading zero. Hence A is 065.gif and 6 is 054.gif.
  • All characters for a given font must be in the same directory.
  • Very importantly - if you want to recolour the fonts, they must be created as black on white. Otherwise use of BGCOLOR and FGCOLOR will have strange results. It would also be helpful, particularly if you close up the characters a lot, to make the white background transparent.
  • If all else fails, we may be persuaded to create a custom font. We're busy and it's a rather dull task (i.e. grease our palms).
  • Finally, you might consider sharing your fonts - we will be happy to make shareware/freeware fonts available for download on our pages. A fund of font graphics would be to everyone's gain.

Use and enjoy.

Fin Fahey
Fiona Daly

LEGAL DISCLAIMER
Neither Albedo Systems Ltd. nor anyone else who has been involved in the creation, production or delivery of this product shall be liable for any direct, indirect, consequential or incidental damages (including damages for loss of business profits, business interruption, loss of business information, and the like) arising out of the use or inability to use this product even if Albedo Systems Ltd. has been advised of the possibility of such damages.