texttoimage

Summary

Renders a string as an image using a truetype font.

Usage

$input_string|texttoimage( style )

Parameters

NameTypeDescriptionRequired
style string Name of style to use. Yes.

Returns

Image layer.

Description

This operator creates an image that contains the text which was specified using the input parameter. The text is rendered using a truetype font. The style parameter must specify the name of the style that the operator should use when rendering the text. If the style doesn't exist or the parameter is omitted (although it is required), the default style will be used.

The various style settings are set up in the "texttoimage.ini" configuration file. Each style is simply just a block of settings. For each style it it possible to specify the following:

  • The name of the style
  • Font family
  • Point size
  • Background color
  • Text color
  • Angle/rotation
  • X adjustment
  • Y adjustment
  • Width adjustment
  • Height adjustment
  • Absolute width
  • Absolute height

The configuration file comes with a couple of basic styles. It is possible to create custom styles. The configuration file also specifies the location where Exponential should look for the truetype font files. An Exponential distribution comes with a small collection of truetype fonts ready for use. These fonts are located in the "/design/standard/fonts" directory. The fonts included in this directory are free when it comes to costs and distribution. Information regarding the author and other things can be found within the text file that is placed in a directory with the same name as the font itself.

When using fonts that are located outside the "/design/standard/fonts" directory, for example "/design/my_company/fonts", the FontDir[] array within the "texttoimage.ini" file (or an override) has to include an additional FontDir[] line that specifies this directory.

This operator creates and returns an image object. The operator basically flattens/merges the image layers that were provided using the parameters. However, a parameter can be something else than an image layer. A parameter to this operator can be one of three things:

  • String
  • Image layer
  • Array

If a parameter is a string, the text will be used as the alternative image text for the image object that is returned by the operator.

If a parameter is an image layer then the layer will simply be merged into the image object that is to be returned by the operator.

If a parameter is an array, the operator will assume that the first array element (element zero) is the image itself (an image layer created by either the imagefile or the texttoimage operator), and that the second element is a hash (associative array) containing parameters for that layer. The following parameters can be used:

  • transparency: float value ranging from 0 to 1.0 (0 = 0% and 1 = 100%)
  • halign: horizontal alignment, use left, right or center
  • valign: vertical alignment, use top, bottom or center
  • x: absolute placement (works with left and right align)
  • y: absolute placement (works with top and bottom align)
  • xrel: relative placement, float value ranging from 0 to 1.0.
    (works with left and right align)
  • xrel: relative placement, float value ranging from 0 to 1.0.
    (works with top and bottom align)

The x and xrel parameters can not be used at the same time. The same goes for the y and the yrel parameters.

When right or bottom alignment is used, the coordinate system will shift to accommodate the alignment. This is useful for doing alignment and placement since the placement is relative to the current coordinate system. Right alignment will start the axis at the right (0) and go on to the left (width).
Bottom alignment will start the axis at the bottom (0) and go on to the top (height).

If the operator is called directly, the "/design/standard/templates/image/imageobject.tpl" template will be used to display the image object that is returned by the operator. It is possible to override this template using the template override system.

Images created with this operator will be cached inside the "cache/texttoimage" folder, within the var-directory that is used for the siteaccess.

Examples

{'Exponential'|texttoimage( 'sketchy' )}

This will render the string "Exponential" using the truetype font, size, rotation, etc. that is defined in the sketchy style.

Comments

Contents

Reference

Database diagram
Template operators
    PDF
    Arrays
    Data extraction
    Formatting
    Images
       image
       imagefile
       texttoimage
    Logic
    Mathematics
    Miscellaneous
    Strings
    URLs
    Variables
Template functions
Data fetching
Modules
XML tags


Created

05/02/2004
11:38:21 am
by Balazs Halasy

Last updated

12/02/2004
9:48:07 am
by Balazs Halasy

Authors

Balazs Halasy



This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.