Zrinka Bilusic-Vezmar on wrote...
| Hi,
|
| I am trying to fit some text in a limited box and I understand I can
| do this by using "caption" without specifying "-pointsize". I tried it
| and it worked. However, I have one more problem - I have to use
| Arial-Black font and at larger pointsize (most of the text will be
| between 30 and 40) the space between the lines is very wide. After
| reading everythign I could on ImageMagick website I understand that
| this is a feature of the type, and that it cannot be changed in
| ImageMagick (well at least it is not straight forward), correct?
|
Yes. The font is designed specifically for easy reading of test
documents. Lots of text. and that means a good line spacing is needed.
The pointsize actually defines the line spacing rather than the actual
letter heights.
You will need to find an alturnative font that does not have such a big
line spacing. Or re-design Arial-Black for this purpose.
There are lots of fonts available in font servers around the web, so
something must be availabel for you to use.
Does anyone on the web have any suggestions for minimal line spaced
fonts?
| I could solve this problem by separating the text into several strings
| (as many as there are lines of text that were fit into the box by
| "caption"), and then placing each string (or line) separately within
| the box. However, for that I would need to know the pointsize
| "caption" finally chose. Is there a way to get to that information -
| the font size "caption' chose to fit the text inside the box with word
| wrap?
|
| If I cannot get that, then I am out of ideas, at least easiers ones.
| Any suggestion/examples would be greatly appreciated.
|
Not at this time. sorry.
But the caption algorithm is relativally straight forward.
Captions hard requirement is line length (image width).
Basically it internally tries different pointsizes (using maths rather
than actual drawing) to find the largest pointsize that just fits the
user supplied height requirement
That is
final number of lines due to word wrapping * pointsize in pixels
is less than or equal to the user supplied image height.
This is a binary search, so only 4 to 5 'guesses' is needed to figure out the
final pointsize for the caption. Once it has that it draws the text.
This can be done yourself in an API, and you could even lookup the
source code to find out how IM does it internally.
| By the way - I am working with PerlMagick. But I could switch to
| another API if that would solve my problem (and if somebody already
| did this and can share some code :o)
|
PerlMagick can retrieve the font attributes needed.
I don't know how myself.
Actually I have been thinking about a 'caption' like auto-size
but for fitting text into a oddly shaped area (as defined by a mask),
rather than a rectangular area.
This needs two parts. One to 'best fill a shaped area' with words at a
specific point size, and return success or failure. And the same outer
loop that normal auto-size caption uses.
It is fitting words into a shaped area that is the real puzzle.
It is currently just a mind puzzle for me at this point, but if someone
likes to try to work this out. It would be a great little program, that
could make IM text handling a cut about the rest.
Anthony Thyssen ( System Programmer ) <[EMAIL PROTECTED]>
-----------------------------------------------------------------------------
\
@ |\
(===B---------------------------------/__\
\|==B--------------------------------\ /
)) |/
________LL____ Watch those ground passes! ___ / ________
-----------------------------------------------------------------------------
Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users