Re: Proper vertical centering of text

Hello,

to generalise this use case, one whats somehow to center
a text object in relation to another object.

Problems I see:
a) most viewers seem to have a problem to find a precise boundingBox not only 
for text, but in this case it would be essential to get especially the 
vertical dimensions of such a box somehow precisely.
b) one needs to define the center of a general graphical object, if one needs 
to center text to it - how to do this? Again the boundingBox? 
Some viewers have problems as well to get the right boundingBox for 
arbitrary objects or a group of objects.
c) one needs to refer the object with the center from the text to be centered.
This can be done obviously with some XLink construction, however, how
do other positioning, alignment, transformation issues for the text 
have influence on this?

Another approach would be to leave the question of the center of
something to the authors, but to enable them to center the text according
to a text position, as available now for horizontal centering of the text 
relative to this point due to text-anchor.
This should be somehow related to the baseline of the text to avoid
problems with the boundingBox complexity for text objects.
dominant-baseline and alignment-baseline provide such an access 
approximately with central or middle.
Why is this not sufficient, is it a general problem or just the usual
problem with implementation bugs or gaps in some viewers?
However, just to introduce new features will not help to get current
implementations to a good state.
Obviously to get it more precisely done as with a shift of the baseline,
one needs the boundingBox of the current text, not just the general
information about the complete font, but obviously this is quite difficult
for viewers, maybe more in the vertical direction than in horizontal
direction, at least for latin like text structures. 
My assumption is, that if authors really need perfect control about this,
they want to have perfect control about the dimension of the text object
as well, they need to scale it in relation to the object, the text has to be
centered to. Because SVG fonts are not supported in all viewers
(again the problem with bugs and gaps in viewers), the only
successfull approach currently is to convert the text into arbitrary path 
data, determine somehow, what the center might be for all objects, that
need to centered to each other with an algorithms dependent on the
aesthetic opinions of the specific author, and to position everything
according to this.

To center something is some kind of a philosophical problem, 
not only a technical question. And not just in CSS fun for authors
already for many years, in SVG for non trivial objects as well ;o)


Olaf 

Received on Wednesday, 4 March 2015 18:07:42 UTC