NP_GraphicText

General Plugin info Replace text by text images
Author:xiffy
Current Version: 1.0
Download: GraphicText version 1.0
Code: not available; please download
Demo: http://xiffy.nl/weblog/
Forum Thread: Plugin announced

This plugin can replace 'any' text by text images containing the text. This is extremly useful for lot's of purposes. Skin designers now can use a special font to render labels and buttons. You can render your item titles with your own font and more. In the example below, both the date and the itemtitle have been replaced by images. The font used is Impact :mwsnap001.png

Installation

Unpack the zip archive and leave the folders intact. The plugin comes with 1 sample font included so you can use it out of the box. The cache directory inside the graphictext subdirectory must be writable for the webserver The plugin will fail if this is not the case.

Usage

The plugin can be used on both your skin and inside your template. By calling it with

<%GraphicText(My fancy text)%>

the plugin will render three images with the text 'My', 'fancy' and 'text'1). Then it will insert the correct html code to display the rendered images. This includes both alt and title attributes. The alt attribut will contain the text of the image; the title attribute will contain the complete text that is displayed.

Special text like title and dates

The plugin is capable to render some special instances of text. Most importantly the item title and dates. When placed inside a template not skin

<%GraphicText(title)%>

will convert the title of the item to images. Other currently implemented 'keywords' are

  • relevance
  • category
  • author
  • date

These will triger the plugin to display the actual content of the item's relevance (score when doing a search), current categoryname or the current author. The last 'keyword' date replaces

<%date%>

. The dateheaders and datefooters in archives and on the index will be a bit trickier as you'll see later on.

Plugin Options

The plugin has quite a few options. These handle the defaults to use for rendering the images and a couple of options that are needed to render date headers and footers.

FontThe exact name of the fontfile that should be on the disk. Included with the plugin is ROLLERCO.TTF (in capitals). The name should be an exact match to what is on disk.
SizeThe size in points to use for rendering the images. Defaults to 20
Color The color to use when rendering the images. defaults to #000000 (black)
Backgroundcolor The color to use as a backgroundcolor. This is important even if you use transparancy. Be sure it contrasts to the foregroundcolor. Defaults to #ffffff (white)
Transparent Should the images have a transparent background? Defaults to yes

The rest of the options involve rendering of dates. You can ignore these if you don't want GraphicText to do this. Now onwards with the explanation. There are three options that involve rendering

<%GraphicText(date)%>

and they are exactly the same as the ones you would use inside your templates; a start, the format and the end.

Date start Text that will be displayed as plain text. Here you can use markup and add <div class='date'> stuff
Datetemplate The format that needs to be used for rendering the date. example %e %B %Y , after the date is formatted to this format, the images are created
Date end Text that will be displayed as text. You should close all htnl tags opened in the datestart

More date stuff. But there's more involving the date. Because with nucleus you can show the date when it changes it's value. If you want these dates rendered by GraphicText, you should use the final 6 options.

Date header / footerIf set to yes, Graphic text will render the date header instead of nucleus. It will adhere your template settings
Template options overrideThere are 5 of these and here you can specify colors, size and font for all different templates you use. More about these later

Overriding default

When you've set your defaults, it can of course happen that a particular word or text should be rendered at a different size / color / font.
This is all possible. The order of the options is:
size, color, backgroundcolor, font, transparancy parameters can be omitted from right to left. To get the defaults you set in the plugin options you can pass 'default' as parameter. Some examples:

<%GraphicText(text)%>
<%GraphicText(text,30)%> fontsize will be 30
<%GraphicText(text,default,#0f0f0f)%> default fontsize, color #0f0f0f
<%GraphicText(text,26,default,#ffffff)%> fontsize 26, color default, backgroundcolor white
<%GraphicText(text,default,default,default,ARIAL.TTF)%> all defaults, but ARIAL.TTF will be used as the font. 
<%GraphicText(text,default,default,default,default, no)%> all defaults but the background will NOT be transparent.. 

Dateheaders

When you let the plugin render the dateheaders, the normal template dateparsing is done. However the date itself will be shown as images. Because rendering is done by plugin events it's not possible to override the defaults of the font by passing parameters. You can however control the size, color and font in this special case by template options. By default they are filled with the non-working but hopefully explanatory value:
templatename=size,color,bgcolor,fontname,transparent
If your template is called 'leaf' and want white fonts on a black background you can alter on of the five options into:
leaf=default,#ffffff,#000000
The order is off course identical to the order you can control the plugin normally.

Environment

This plugin only works if GD is installed on your webserver. Besides that, the freefonts library must be installed.

Plugin review

NP_GraphicText version 1.0 works with Nucleus CMS version 3.31 - 2007-11-11 kg (very nice toy ;-))

1) actually, there are four images because for a space an extra image will be created
graphictext.txt · Last modified: 2007/12/08 02:20 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki