[Mapcss] text-offset
Sebastian Klein
bastikln at googlemail.com
Wed Jul 21 11:12:37 BST 2010
Sebastian Spaeth wrote:
> 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
I haven't implemented multi-line text, but some alignments relative to
the node icon (which can have different sizes from 3x3 to 20x20).
text-align-x: left, right, start, end, center
text-align-y: above, top, center, bottom, below
text-offset-x: 2 ex;
text-offset-y: -3 px;
Here a little ASCII art, hope it survives reformatting:
left-above ______________ right-above
left-top| |right-top
| |
left-center| ctr-ctr |right-center
| |
left-bottom|______________|right-bottom
left-below center-below right-below
start/end depends on the font flow: for left to right flow it is
left/right and for right to left text flow it is right/left.
I think this works quite the same for multi line text.
Sebastian
More information about the Mapcss
mailing list