If GD2 and Freetype are installed on your server , SPIP can automatically convert titles (or other text elements from the database) into images, using the font of your choice.
To do this, you need to use the
image_typo filter that is documented on this page.
If you do not provide any parameters,
image_typo will use the default font provided by SPIP: Dustismo, which is a GPL font by Dustin Norlander. It is stored in the
polices sub-directory of the
squelettes-dist folder for SPIP 2 (in previous version of SPIP , this was called the
You can specify the name of another font to use by using the
police parameter (the font needs, of course, to be installed on your site):
(Dustismo-bold is also provided by default by SPIP.)
You can, in theory, use many font formats: TrueType, PostScript Type 1, OpenType... However, depending on your server configuration, some formats may not be accepted.
The fonts have to be installed in a sub-directory:
/polices underneath the
/ecrire directory, or — even better — underneath your template directory.
If, for example, you install a TrueType file:
it will be possible to use this new font .
You can specify the size of the font by using the
Note: do not use “36pt”, but only “36” — without specifying the units.
couleur parameter can be used to specify the colour of the font. By default, the colour will be black. This parameter takes an hexadecimal RGB value with the notation: «3399BB». Note: do not use the # usually added to the colour notations in HTML and CSS.
largeur parameter gives you a control over the maximum width of the generated image. Note: this is a maximum value, the image will be automatically reframed afterwards to fit the real dimensions of the text.
The first block in the following example is made with a maximum width of 300 pixels, the second block with a width of 400 pixels.
align parameter sets the alignment of multiple lines of text (if applicable) to the left, right or center.
hauteur_ligne fixes the height of each line (if the images contains multiple line of texts).
Some fonts will “overflow” the assigned box and the result looks really bad (the font will be “cut”). The
padding parameter makes it possible, in such cases, to force extra space around the typographical image.
Filtering the image
The result of
image_typo is an image and therefore can be processed by the image filters. For example, the following code applies a semi-transparency and a texture mask.