What is the purpose ?
Sometimes a writer may need to use a different font for one part of his text and in the meantime he doesn’t want this change to occur on all or on any other texts.
For the needs of EVA 3 we had to find a way to use hand writting fonts for such partial texts.
What is the problem ?
A Spip feature aldready allows to turn a single text string into an image, wich easily increases creativity. It’s the typographical image filter.
[(#TITRE|image_typo)]
turns a text string into an image .
[(#TITRE|image_typo{police=my_font.ttf})]
turns a text string into an image using the specified font.
This is exactely what we need ; although it can’t work with #TEXT unless we want to turn all the text into an image .
Here is the solution
It comes from spip’s models. As a matter of fact spip comes with the features we need.
<imagetypo|texte=my partial text>
This code lets us change font in a partial text, actually returning an image img of the writtings, and that’s exactly what we need.
Setting up
Since we only need a part of text to be processed by imagetypo we are going to let spip do the work elsewhere _that will be a task for ecriture.html_ and then return the final img.
Let’s begin by specifying exactly what we want. If we mean to change only the first sentence of a text, then we need to write the following code in our body text :
<ecriture1|texte=My first sentence|police=my_font.ttf|left>
[(#ENV{texte}|image_typo{police=#ENV**{police}})]
Technically speaking
You will need to place the file ecriture.html in the /modeles directory of your templates folder : /modeles/ecriture.html
Then of course, make sure you’ll add the fonts you need in your template’s fonts directory [1] at the root of your site : /polices/my_font.ttf, or in the templates directory : /your_templates/polices/my_font.ttf
Make sure to create those directories if they do not already exist.
Aucune discussion
Ajouter un commentaire
Avant de faire part d’un problème sur un plugin X, merci de lire ce qui suit :
Merci d’avance pour les personnes qui vous aideront !
Par ailleurs, n’oubliez pas que les contributeurs et contributrices ont une vie en dehors de SPIP.
Suivre les commentaires : |