Re: Wanted: Help centering Text

Robert Longson <[email protected]>
Newsgroups gmane.comp.mozilla.devel.svg
Organization http://groups.google.com
Message-ID <[email protected]>
On Sep 2, 5:07 am, "Siegfried Heintze" <[email protected]> wrote:
> Woops! sorry. I did not read everything. I don't understand this
> alignment-baseline. Athttp://www.w3.org/TR/SVG/text.html#AlignmentBaselinePropertyI read that it
> does not appy <text but only <tspan. That does not seem logical.
>
> So I have a rectangle whose upper right corner is at 0,0 and width=12.5 and
> height=12.5. The following code does not center it horizontally or
> vertically:
>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="middle" >&#57350;</tspan></text>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="central" >&#57350;</tspan></text>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="before-edge" >&#57350;</tspan></text>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="text-before-edge" >&#57350;</tspan></text>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="after-edge" >&#57350;</tspan></text>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="text-after-edge" >&#57350;</tspan></text>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="ideographic" >&#57350;</tspan></text>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="alphabetic" >&#57350;</tspan></text>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="hanging" >&#57350;</tspan></text>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="central" >&#57350;</tspan></text>
> <text x="6.25" y="6.25" text-anchor="middle" class="common-segoe"><tspan
> alignment-baseline="mathematical" >&#57350;</tspan></text>
>
> Could it be a problem with custom font I'm using? OK, I tried the default
> font and removed the class="common-segoe" and that did not help with the
> vertical centering. It looks like the alignment-baseline has no affect! Is
> this a bug? But the horizontal alignment looks good. So maybe there is a
> problem with the custom font I am using? Uggghh... I'm not sure how to fix
> that.
> Thanks!
> Siegfried

My mistake it's dominant-baseline we partially support, not alignment-
baseline :-).

central and middle do the same thing at the moment which is presumably
incorrect but one of those is the one you want. The only others that
do anything are hanging (treated as text-before-edge) text-before-edge
and text-after-edge. The others you are trying e.g. mathematical,
ideographic are not implemented and do nothing.

Best regards

Robert
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.