You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Manuel Mall <mm...@arcus.com.au> on 2005/09/24 16:46:07 UTC

inline alignment question

Take the following fo snippet:

<fo:block font-size="24pt">
  BIG
  <fo:inline font-size="12pt" vertical-align="top">
    small top
    <fo:inline font-size="18pt" vertical-align="bottom">
      medium bottom
    </fo:inline>
  </fo:inline>
</fo:block>

Would one expect the text "medium bottom" to be aligned 
a) with the bottom of the text "small top" 
or 
b) with the bottom of the text "BIG"?

I am asking this because my initial reaction was a), then my 
interpretation of the spec says the answer is b), and then testing it 
against RenderX gave a). Why b) - because according to section 7.13 
(and this is well into the section) 'just changing the "font-size" 
property does not change the baseline-table in effect in the inner 
inline formatting object'. This means all 3 sections of text are 
aligned according to the baselines established by the fo:block.

What do others think a) or b)?

Manuel

Re: inline alignment question

Posted by Manuel Mall <mm...@arcus.com.au>.
FWIW I just downloaded the evaluation version of the Antennahouse 
Formatter and it generates as per my option b). For all to see here is 
the fo:
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" 
xmlns:svg="http://www.w3.org/2000/svg">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="normal" page-width="5in" 
page-height="5in">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="normal" 
white-space-collapse="true">
        <fo:flow flow-name="xsl-region-body">
          <fo:block font-size="24pt">
            Start-p<fo:inline font-size="12pt" background-color="yellow" 
vertical-align="top">top<fo:inline font-size="18pt" 
background-color="red" 
vertical-align="bottom">p-bottom-g</fo:inline></fo:inline>g-End
          </fo:block>
          <fo:block font-size="24pt">
            Start<fo:inline font-size="12pt" background-color="yellow" 
vertical-align="top">top<fo:inline font-size="18pt" 
background-color="red" 
vertical-align="bottom">p-bottom-g</fo:inline></fo:inline>End
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>

and I'll attach both the RenderX and AntennaHouse pdf outputs (I did put 
those strange letters 'g' in 'p' in to be able to see the font 
descenders clearly).

IMO, AntennaHouse got the vertical alignment right but, and this was 
discussed in another thread mainly between me and Finn, I think RenderX 
got the highlight correct, i.e. the inline with the word "top" has only 
the small line-height. Note also that in the AntennaHouse PDF the red 
background does not quite reach to the bottom of the descenders.

Now, the BIG question is, what should FOP do or 'what is the right way'?

Manuel

On Sun, 25 Sep 2005 09:49 am, Manuel Mall wrote:
> Andreas,
>
> let me start with thanking you for taking the time to look into this
> and respond so quickly. This is much appreciated. This post arrived
> here after midnight by which time I was sound asleep. I only got to
> look at it this morning.
>
> On Sun, 25 Sep 2005 12:39 am, Andreas L Delmelle wrote:
> > On Sep 24, 2005, at 17:39, Manuel Mall wrote:
> > > On Sat, 24 Sep 2005 11:27 pm, Andreas L Delmelle wrote:
> > >> Anyway, the full description would be:
> > >> The alignment-baseline on the first inline is aligned with the
> > >> before-edge baseline of the outer block. Now, IIC, this has an
> > >> impact on its own after-edge baseline, which is then in its turn
> > >> the basis for the alignment-baseline of the innermost inline (?)
> > >
> > > You are right - this is exactly the question: Does it have an
> > > impact on its after-edge baseline or not? Intuitively I would say
> > > YES but the spec says NO the baseline table is not recalculated
> > > (rescaled) when the font-size changes.
> >
> > I think I got it. Correct me if I'm wrong...
> >
> > The description in the Rec applies to cases where only the
> > font-size changes, and all the alignment-related properties have a
> > value of "auto"...
> >
> > > The baseline-table seems to only be recalculated on
> > > a baseline-shift but not otherwise.
> >
> > ... but the baseline-shift value for the first inline is non-zero
> > (value "baseline" is not equal to value "0"), so the Rec says in
> > 7.13.3:
>
> I think that is the core point. IMO the baseline-shift for the first
> inline is 0. Yes, there is a change of alignment-baseline but NO
> shift of any baseline. As you pointed out before vertical-align="top"
> is equivalent to:
>     alignment-baseline="before-edge"
>     alignment-adjust="auto"
>     baseline-shift="baseline"
>     dominant-baseline="auto"
> And 7.13.3. says for baseline-shift="baseline": There is no
> baseline-shift; the dominant baseline remains in its original
> position.
>
> So neither changing the font-size nor changing the vertical-align to
> "top" or "bottom" involves a baseline-shift and therefore the
> original baseline-table stays in place.
>
> > "When the value of 'baseline-shift' is other than '0', then the
> > baseline-table font-size component of the 'dominant-baseline'
> > property is re-computed to use the 'font-size' applicable to the
> > formatting object on which the non-zero 'baseline-shift' property
> > is specified."
> >
> > So, the dominant-baseline *is* re-computed for the first inline it
> > seems, although this isn't apparent if you look only at the
> > description for the "baseline" value:
> >
> > "There is no baseline shift; the dominant-baseline remains in its
> > original position."
> >
> > Easy to get confused by this, but still, I think your original a)
> > applies here.
> >
> > Problem solved? :-)
>
> I still think according to the spec its b). :-)
>
> > Cheers,
> >
> > Andreas
>
> Manuel

Re: inline alignment question

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Sep 25, 2005, at 13:27, Manuel Mall wrote:

>
> This is where we disagree and I think I have the spec "on my side" as 
> it
> says in 7.13.3 that a value of "0" is equivalent to
> "baseline" ("baseline" == "0"). This is mentioned under both
> <percentage> and <length>. Therefore IMO the spec does not make a
> semantic distinction between a value of "baseline" and a value of "0".
> Actually I would argue that the computed value of the specified value
> "baseline" is "0".

Aarrrghh... *smacks head*
Now I get you! My mistake. It seems indeed that I didn't look at all 
the possible values. I was too focused on that "baseline" value.

In that case: you are *absolutely* right (as is AntennaHouse).

Cheers,

Andreas


Re: inline alignment question

Posted by Manuel Mall <mm...@arcus.com.au>.
On Sun, 25 Sep 2005 06:12 pm, Andreas L Delmelle wrote:
> On Sep 25, 2005, at 03:49, Manuel Mall wrote:
<snip/>
> >> ... but the baseline-shift value for the first inline is non-zero
> >> (value "baseline" is not equal to value "0"), so the Rec says in
> >> 7.13.3:
> >
> > I think that is the core point. IMO the baseline-shift for the
> > first inline is 0. Yes, there is a change of alignment-baseline but
> > NO shift of any baseline. As you pointed out before
> > vertical-align="top" is equivalent to:
> >     alignment-baseline="before-edge"
> >     alignment-adjust="auto"
> >     baseline-shift="baseline"
> >     dominant-baseline="auto"
> > And 7.13.3. says for baseline-shift="baseline": There is no
> > baseline-shift; the dominant baseline remains in its original
> > position.
>
> Exactly the source of the confusion. If it had been:
>
> alignment-baseline="before-edge"
> baseline-shift="0"
>
> That would have been something different. As I understand, the
> "baseline" value for baseline-shift is precisely meant to distinguish
> between the 'no-shift' cases where the baseline-table component does
> or does not need to be re-computed... ("baseline" != "0")
> First, the baseline-table component is re-computed, and then 'the
> dominant-baseline remains in its original position' (= after the
> re-computation)
>

This is where we disagree and I think I have the spec "on my side" as it 
says in 7.13.3 that a value of "0" is equivalent to 
"baseline" ("baseline" == "0"). This is mentioned under both 
<percentage> and <length>. Therefore IMO the spec does not make a 
semantic distinction between a value of "baseline" and a value of "0". 
Actually I would argue that the computed value of the specified value 
"baseline" is "0".

> > So neither changing the font-size nor changing the vertical-align
> > to "top" or "bottom" involves a baseline-shift and therefore the
> > original baseline-table stays in place.
>
> I hate to be a such pest, but I disagree :-P
>

That's OK and no your are not a pest because if you are I would be an 
even worse pest (what a horrible thought...). But I really think this a 
quite important stuff. In the end positioning a glyph correctly, that 
is in accordance with the rules of the specification given a set of 
formatting instructions provided by the user, is the core function of a 
formatter. If we can't get that right why do we bother? And to get this 
right we have to understand it first which is what this exchange is all 
about. So keep coming... :-)

> BTW: Where's all the others? Ah well, it's weekend after all... :-)
>
> Cheers,
>
> Andreas

Cheers

Manuel

Re: inline alignment question

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Sep 25, 2005, at 03:49, Manuel Mall wrote:
>
> On Sun, 25 Sep 2005 12:39 am, Andreas L Delmelle wrote:

> let me start with thanking you for taking the time to look into this 
> and
> respond so quickly. This is much appreciated. This post arrived here
> after midnight by which time I was sound asleep. I only got to look at
> it this morning.

Well, I always like these kinds of questions that make me dive into 
parts of the Rec I haven't read before --we like to learn :-)

>>> The baseline-table seems to only be recalculated on
>>> a baseline-shift but not otherwise.
>>
>> ... but the baseline-shift value for the first inline is non-zero
>> (value "baseline" is not equal to value "0"), so the Rec says in
>> 7.13.3:
>
> I think that is the core point. IMO the baseline-shift for the first
> inline is 0. Yes, there is a change of alignment-baseline but NO shift
> of any baseline. As you pointed out before vertical-align="top" is
> equivalent to:
>     alignment-baseline="before-edge"
>     alignment-adjust="auto"
>     baseline-shift="baseline"
>     dominant-baseline="auto"
> And 7.13.3. says for baseline-shift="baseline": There is no
> baseline-shift; the dominant baseline remains in its original position.

Exactly the source of the confusion. If it had been:

alignment-baseline="before-edge"
baseline-shift="0"

That would have been something different. As I understand, the 
"baseline" value for baseline-shift is precisely meant to distinguish 
between the 'no-shift' cases where the baseline-table component does or 
does not need to be re-computed... ("baseline" != "0")
First, the baseline-table component is re-computed, and then 'the 
dominant-baseline remains in its original position' (= after the 
re-computation)

> So neither changing the font-size nor changing the vertical-align to
> "top" or "bottom" involves a baseline-shift and therefore the original
> baseline-table stays in place.

I hate to be a such pest, but I disagree :-P

BTW: Where's all the others? Ah well, it's weekend after all... :-)

Cheers,

Andreas


Re: inline alignment question

Posted by Manuel Mall <mm...@arcus.com.au>.
Andreas,

let me start with thanking you for taking the time to look into this and 
respond so quickly. This is much appreciated. This post arrived here 
after midnight by which time I was sound asleep. I only got to look at 
it this morning.

On Sun, 25 Sep 2005 12:39 am, Andreas L Delmelle wrote:
> On Sep 24, 2005, at 17:39, Manuel Mall wrote:
> > On Sat, 24 Sep 2005 11:27 pm, Andreas L Delmelle wrote:
> >> Anyway, the full description would be:
> >> The alignment-baseline on the first inline is aligned with the
> >> before-edge baseline of the outer block. Now, IIC, this has an
> >> impact on its own after-edge baseline, which is then in its turn
> >> the basis for the alignment-baseline of the innermost inline (?)
> >
> > You are right - this is exactly the question: Does it have an
> > impact on its after-edge baseline or not? Intuitively I would say
> > YES but the spec says NO the baseline table is not recalculated
> > (rescaled) when the font-size changes.
>
> I think I got it. Correct me if I'm wrong...
>
> The description in the Rec applies to cases where only the font-size
> changes, and all the alignment-related properties have a value of
> "auto"...
>
> > The baseline-table seems to only be recalculated on
> > a baseline-shift but not otherwise.
>
> ... but the baseline-shift value for the first inline is non-zero
> (value "baseline" is not equal to value "0"), so the Rec says in
> 7.13.3:

I think that is the core point. IMO the baseline-shift for the first 
inline is 0. Yes, there is a change of alignment-baseline but NO shift 
of any baseline. As you pointed out before vertical-align="top" is 
equivalent to:
    alignment-baseline="before-edge"
    alignment-adjust="auto"
    baseline-shift="baseline"
    dominant-baseline="auto"
And 7.13.3. says for baseline-shift="baseline": There is no 
baseline-shift; the dominant baseline remains in its original position.

So neither changing the font-size nor changing the vertical-align to 
"top" or "bottom" involves a baseline-shift and therefore the original 
baseline-table stays in place.

>
> "When the value of 'baseline-shift' is other than '0', then the
> baseline-table font-size component of the 'dominant-baseline'
> property is re-computed to use the 'font-size' applicable to the
> formatting object on which the non-zero 'baseline-shift' property is
> specified."
>
> So, the dominant-baseline *is* re-computed for the first inline it
> seems, although this isn't apparent if you look only at the
> description for the "baseline" value:
>
> "There is no baseline shift; the dominant-baseline remains in its
> original position."
>
> Easy to get confused by this, but still, I think your original a)
> applies here.
>
> Problem solved? :-)

I still think according to the spec its b). :-)

>
>
> Cheers,
>
> Andreas

Manuel

Re: inline alignment question

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Sep 24, 2005, at 17:39, Manuel Mall wrote:

> On Sat, 24 Sep 2005 11:27 pm, Andreas L Delmelle wrote:
>> Anyway, the full description would be:
>> The alignment-baseline on the first inline is aligned with the
>> before-edge baseline of the outer block. Now, IIC, this has an impact
>> on its own after-edge baseline, which is then in its turn the basis
>> for the alignment-baseline of the innermost inline (?)
>
> You are right - this is exactly the question: Does it have an impact on
> its after-edge baseline or not? Intuitively I would say YES but the
> spec says NO the baseline table is not recalculated (rescaled) when the
> font-size changes.

I think I got it. Correct me if I'm wrong...

The description in the Rec applies to cases where only the font-size 
changes, and all the alignment-related properties have a value of 
"auto"...

> The baseline-table seems to only be recalculated on
> a baseline-shift but not otherwise.

... but the baseline-shift value for the first inline is non-zero 
(value "baseline" is not equal to value "0"), so the Rec says in 
7.13.3:

"When the value of 'baseline-shift' is other than '0', then the 
baseline-table font-size component of the 'dominant-baseline' property 
is re-computed to use the 'font-size' applicable to the formatting 
object on which the non-zero 'baseline-shift' property is specified."

So, the dominant-baseline *is* re-computed for the first inline it 
seems, although this isn't apparent if you look only at the description 
for the "baseline" value:

"There is no baseline shift; the dominant-baseline remains in its 
original position."

Easy to get confused by this, but still, I think your original a) 
applies here.

Problem solved? :-)


Cheers,

Andreas


Re: inline alignment question

Posted by Manuel Mall <mm...@arcus.com.au>.
On Sat, 24 Sep 2005 11:27 pm, Andreas L Delmelle wrote:
> On Sep 24, 2005, at 17:22, Manuel Mall wrote:
> > On Sat, 24 Sep 2005 11:04 pm, Andreas L Delmelle wrote:
> >> It seems then that the vertical-align on the innermost inline
> >> actually refers to the after-edge, which IIC would be relative to
> >> the after-edge of its parent (and not that of the block ancestor).
> >>
> >> So I'd agree with your hunch and RenderX here...
> >
> > Andreas, thanks for the quick response. And yes I agree with your
> > expansion. And yes this means "aligned with the 'after-edge'
> > baseline of the parent area". But what is the 'after-edge' baseline
> > of the parent area? (Note it doesn't say "aligned with the
> > 'after-edge' of the parent" is says "aligned with the 'after-edge'
> > baseline of the parent")
>
> Yeah, sorry, I was being too fast here and forgot a few important
> terms.
>
> Anyway, the full description would be:
> The alignment-baseline on the first inline is aligned with the
> before-edge baseline of the outer block. Now, IIC, this has an impact
> on its own after-edge baseline, which is then in its turn the basis
> for the alignment-baseline of the innermost inline (?)

You are right - this is exactly the question: Does it have an impact on 
its after-edge baseline or not? Intuitively I would say YES but the 
spec says NO the baseline table is not recalculated (rescaled) when the 
font-size changes. The baseline-table seems to only be recalculated on 
a baseline-shift but not otherwise.

>
> That was actually more the point I wanted to make.
>
> Cheers,
>
> Andreas

Manuel

Re: inline alignment question

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Sep 24, 2005, at 17:22, Manuel Mall wrote:

> On Sat, 24 Sep 2005 11:04 pm, Andreas L Delmelle wrote:
>> It seems then that the vertical-align on the innermost inline
>> actually refers to the after-edge, which IIC would be relative to the
>> after-edge of its parent (and not that of the block ancestor).
>>
>> So I'd agree with your hunch and RenderX here...
>>
> Andreas, thanks for the quick response. And yes I agree with your
> expansion. And yes this means "aligned with the 'after-edge' baseline
> of the parent area". But what is the 'after-edge' baseline of the
> parent area? (Note it doesn't say "aligned with the 'after-edge' of the
> parent" is says "aligned with the 'after-edge' baseline of the parent")

Yeah, sorry, I was being too fast here and forgot a few important terms.

Anyway, the full description would be:
The alignment-baseline on the first inline is aligned with the 
before-edge baseline of the outer block. Now, IIC, this has an impact 
on its own after-edge baseline, which is then in its turn the basis for 
the alignment-baseline of the innermost inline (?)

That was actually more the point I wanted to make.

Cheers,

Andreas


Re: inline alignment question

Posted by Manuel Mall <mm...@arcus.com.au>.
On Sat, 24 Sep 2005 11:04 pm, Andreas L Delmelle wrote:
> On Sep 24, 2005, at 16:46, Manuel Mall wrote:
>
> Hi Manuel,
>
> > Take the following fo snippet:
> >
> > <fo:block font-size="24pt">
> >   BIG
> >   <fo:inline font-size="12pt" vertical-align="top">
> >     small top
> >     <fo:inline font-size="18pt" vertical-align="bottom">
> >       medium bottom
> >     </fo:inline>
> >   </fo:inline>
> > </fo:block>
> >
> > Would one expect the text "medium bottom" to be aligned
> > a) with the bottom of the text "small top"
> > or
> > b) with the bottom of the text "BIG"?
>
> <snip />
>
> I'm not an expert here, but maybe it may make things a bit clearer if
> you expand the vertical-align shorthand into:
>
> top:
> alignment-baseline="before-edge"
> alignment-adjust="auto"
> baseline-shift="baseline"
> dominant-baseline="auto"
>
> bottom:
> alignment-baseline="after-edge"
> alignment-adjust="auto"
> baseline-shift="baseline"
> dominant-baseline="auto"
>
> It seems then that the vertical-align on the innermost inline
> actually refers to the after-edge, which IIC would be relative to the
> after-edge of its parent (and not that of the block ancestor).
>
> So I'd agree with your hunch and RenderX here...
>
Andreas, thanks for the quick response. And yes I agree with your 
expansion. And yes this means "aligned with the 'after-edge' baseline 
of the parent area". But what is the 'after-edge' baseline of the 
parent area? (Note it doesn't say "aligned with the 'after-edge' of the 
parent" is says "aligned with the 'after-edge' baseline of the parent") 
Any baseline is determined by the actual-baseline-table. And that 
hasn't changed from the fo:block as changing the font-size doesn't 
change the baseline-table. So I am back to b) and still confused.

> HTH!
>
> Cheers,
>
> Andreas

Manuel

Re: inline alignment question

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Sep 24, 2005, at 16:46, Manuel Mall wrote:

Hi Manuel,

> Take the following fo snippet:
>
> <fo:block font-size="24pt">
>   BIG
>   <fo:inline font-size="12pt" vertical-align="top">
>     small top
>     <fo:inline font-size="18pt" vertical-align="bottom">
>       medium bottom
>     </fo:inline>
>   </fo:inline>
> </fo:block>
>
> Would one expect the text "medium bottom" to be aligned
> a) with the bottom of the text "small top"
> or
> b) with the bottom of the text "BIG"?
<snip />

I'm not an expert here, but maybe it may make things a bit clearer if 
you expand the vertical-align shorthand into:

top:
alignment-baseline="before-edge"
alignment-adjust="auto"
baseline-shift="baseline"
dominant-baseline="auto"

bottom:
alignment-baseline="after-edge"
alignment-adjust="auto"
baseline-shift="baseline"
dominant-baseline="auto"

It seems then that the vertical-align on the innermost inline actually 
refers to the after-edge, which IIC would be relative to the after-edge 
of its parent (and not that of the block ancestor).

So I'd agree with your hunch and RenderX here...

HTH!

Cheers,

Andreas