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.

eZ debug

Timing: Jan 18 2025 10:20:27
Script start
Timing: Jan 18 2025 10:20:27
Module start 'layout'
Timing: Jan 18 2025 10:20:27
Module start 'content'
Timing: Jan 18 2025 10:20:28
Module end 'content'
Timing: Jan 18 2025 10:20:28
Script end

Main resources:

Total runtime0.7681 sec
Peak memory usage4,096.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0086 589.1641152.6406
Module start 'layout' 0.00860.0041 741.804739.4766
Module start 'content' 0.01270.7536 781.2813643.8281
Module end 'content' 0.76630.0017 1,425.109416.1250
Script end 0.7680  1,441.2344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4274160.0002
Check MTime0.00140.1782160.0001
Mysql Total
Database connection0.00090.121110.0009
Mysqli_queries0.684789.1379670.0102
Looping result0.00060.0835650.0000
Template Total0.728494.820.3642
Template load0.00200.258820.0010
Template processing0.726494.567420.3632
Template load and register function0.00020.031810.0002
states
state_id_array0.00180.232610.0018
state_identifier_array0.00190.250520.0010
Override
Cache load0.00170.2224430.0000
Sytem overhead
Fetch class attribute can translate value0.00100.130040.0002
Fetch class attribute name0.00170.222280.0002
XML
Image XML parsing0.00660.863840.0017
class_abstraction
Instantiating content class attribute0.00000.002380.0000
General
dbfile0.00620.8087290.0002
String conversion0.00000.001440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 26
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs