label wrap and centering

thomas bonfort thomas.bonfort at GMAIL.COM
Thu Nov 29 10:15:09 EST 2007


hi all.

I've opened this bug a few weeks ago
http://trac.osgeo.org/mapserver/ticket/2383 and implementing it shouldn't be
too difficult. It sure isn't a perfect solution but imho still much better
that the current way of treating the label WRAP parameter, by ensuring that
no wrapping occurs until the current line length has reached a specified
length. It would avoid breaking after short words, i.e.

"This is a long label" with wrap=' '

could be rendered by

"This is a
long label"


instead of
"This
is
a
long
label"

of course labels with very long words following short ones would be somewhat
messed up
for example "this is a verlylongwordinthelabel" would not be wrapped at all
if minwraplength was set longer than "this is a"

complementary or not to this, I've also tried out some rather naive text
centering for multiline labels, that works by padding each line with a
number of 'space' characters. As you might expect, the results are much
better with monospace fonts, but aren't /too/ horrible when using non
monospaced font AND all the lines are roughly the same length. The same
approach could also be used for aligning text to the right, although in that
case a monospace font would be mandatory.
 Doing *real* centering would be really much harder, and would have to be
done seperately for each renderer as the exact line lengths need to be
known, and the starting offsets adjusted accordingly.

each of these two additions would require an additional keyword, for example
"MINWRAPLENGTH" for the first, and maybe "TEXTALIGN" (LEFT|CENTER|RIGHT) for
the second.

thoughts / ideas / comments welcome !

cheers,
thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20071129/9a7effa7/attachment.html


More information about the mapserver-dev mailing list