[Mapcss] text-offset

Sebastian Spaeth spaetz at sspaeth.de
Thu Jul 15 12:23:40 BST 2010


I implemented max-width for text and that leads to multi-line
texts. Usually I center text vertically and horizontally around the node
which is supposed to display it.

However, text-offset breaks with that as a fixed (pixel) offset won't
work for multi-line text (in which the height is unknown).

What should be the best strategy to cope with that?

1) Make text-offset be relative to the text extents. So a text-offset:1,
leads to text appearing below the node, text-offset:0 centers it and
text-offset:-1 has it appearing above the node (even when multi-line
text).

2) Naturally center text around line 1, so a text-offset of 6 for a 12
font text would still lead to text apearing 6 pixels below the node. But
this way you would never know how to center a text on a node.

I tend to favour 1 now. But that has disadvantage that I can never do
"let text appear 16 pixels below icon of height 14". I think what I
ultimately would need for that is a combination of:

text-valign: top|center|bottom
text-offset: 12

Any comments?
Spaetz




More information about the Mapcss mailing list