I havent been able to find a way to change (or activate), text wrapping with the text overlay effect.

I found this, however it didnt give me any clues: http://drupal.org/node/375086

Im using a simple
1. scale and crop
2. text effect

Im choosing to use the ALT tag as the text for simplicity at the moment.

Is their anyway to set or define text wrapping?

CommentFileSizeAuthor
#2 wrap-text.php_.txt1.49 KBfietserwin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dman’s picture

text wrap with GD is really really hard.
I've done it, but we have to:
define a bounding box,
Write text into it, given the font, size and effect.
See if the text is bigger than the box, if so, trim the words back from the end, then repeat until it fits.
And repeat with the leftover string, taking care to position the next line (by pixel) at a point where the leading is probably OK

... all because we just don't know how much space a rendered font will take up on the image until we've called the font library and had it render for us.

This same sort of problem is probably why SVG had/has such god-awful text handling.

The routine describes above did actually work in the earler textactions module, but hasn't been activated in 2 years.

fietserwin’s picture

FileSize
1.49 KB

Full text handling capabilities should support this. but that was not the intention of the current text effect. Text handling is difficult and just a lot of work, The mentioned code e.g. does not retain existing line breaks, double spaces, "do not break here" language rules, etc. I have implemented it myself once, though that was in a non Drupal project. It does retain existing line breaks, that is about the most important difference with the mentioned code.

I'll post it here, so you can use it if you want to. But I have not looked at the implications for the UI (and a possible update function) when adding this to the existing effect.

Alternatives for what you are looking for might be the html5 caption or the image caption Drupal module together with some CSS to move the caption over the image. Even rotation is possible with CSS, but unfortunately the results are ugly to put it mildly. Image processors rotate much nicer than browsers...

d.clarke’s picture

Text wrapping would be a really nice feature. While I don't think it works within the Image API (I think it is coded specifically for GD), it might be worth checking out the textimage module's code. They support text wrapping using a user defined max width. The code to handle the processing is in textimage.utils.inc.... textimage_text_to_image().

fietserwin’s picture

Category: support » feature

Well, then we make it a feature request.

mondrake’s picture

Hi, Textimage 7.x-3.x has been developed to change from the 'presets' logic into full blown image effects that integrate with any other image effects in the image system. The 'Textimage text' effect provides text wrapping capabilities.

Leeteq’s picture

Issue summary: View changes

Is this a different challenge from what was fixed in the D6 version?
Ref. #375086: Automatic text wrapping

If this is hard to "get right", given some external factors, I think it would be enough with just a way to specify how many characters each line can have max, then have ImageCache_actions go from there (right side) and find the closest/last space or dash (or any special character including dots etc.) and force a line break there.

When adjusting fonts/font sizes and image dimensions in the settings, one would then just test some nodes and visually calculate what is the new max number of characters and adjust the settings accordingly.

That would be better than not having automatic text wrapping at all, which is a showstopper in several situations.