Text wrapping at a specific width in texttoimage

Author Message

Frode Marton Meling

Wednesday 15 October 2003 6:42:45 am

eZp v3.2
It would be nice to be able to specify a max width in pixels when using texttoimage. Then the text is wrapped automatically.

Is this possible?
Should this be an enhancement bug?

Frode

Jan Borsodi

Thursday 16 October 2003 3:48:20 am

This is quite hard to do, we use the PHP extension Image to do the text to image conversion. Unfortunately the extension is quite limited with what you can do with the text.

The only way to get this is done is to fix the ImageGD library AND the Image extension, something which is outside of the scope of eZ publish.

The function that we use in eZ publish is.
http://no.php.net/manual/en/function.imagettftext.php

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Frode Marton Meling

Thursday 16 October 2003 11:44:53 am

Thanks.
What I need is a way to determin the pictures width and if it is over a given width, return it as two images (i don't know if I need a <br/> inbetween the pictures.)
My problem is that if editors enter a too large heading, it destroys my design (table based)...

Is this possible from tpl programming?

Frode

Marco Zinn

Thursday 16 October 2003 2:09:56 pm

I think, you can limit your header text to "n" characters, before sending it to "texttoimage".
There is an operator in ez for that (shorten, see http://ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/operators/string_handling#shorten)
See, your template would be something like
{$header|shorten(20)|texttoimage('arial')}

Maybe you could even "wrap" your header (will insert \n ) and then send it to imagetotext. I don't know, if imagetotext is able to create multi-line-images.
(see http://ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/operators/string_handling#wrap )

Marco
http://www.hyperroad-design.com

Ronan Guilloux

Wednesday 27 August 2008 3:29:08 am

You can use wrap operator on texttoimage :

{$node.name|wrap(20)|texttoimage( 'arial',,20,,,'#064D95',,,,5 )}

or use a special character (like '$') to introduce a word wrap at a specific place in the string :

{if $node.name.content|contains('$')}
{def $wrappedTitleArr = $node.name.content|explode( '$' )}
<h2>
{for 0 to $wrappedTitleArr|count|dec as $counter}
{$wrappedTitleArr[$counter]|texttoimage( 'arial',,20,,,'#064D95',,,,5 )}
{delimiter}<br />{/delimiter}
{/for}
</h2>
{undef $wrappedTitleArr}
{/if}

--
Ronan Guilloux
www.mazedia.fr
www.coolforest.net

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.