Andreas,

just to follow up and show that I have not forgotten your recent email :)

Am 29.05.2008 um 19:01 schrieb Andreas Delmelle:
There is still an open issue: When the font is changed, the metrics
for the line are not. E.g. when i have something like

test SIGMA test
<fo:block>test  &#x2211; test</fo:block>

the SIGMA character is set lower than it should be. At this time I was unable to find the cause of this behavior. Maybe someone has a hint as
to why this happens?

To further investigate, compare the behavior with:

<fo:block>test <fo:inline font-family="Symbol">&#x2211;</fo:inline> test</fo:block> <fo:block>test <fo:character font-family="Symbol" character="&#x2211;" /> test</fo:block>

The fo:inline or fo:character trigger the creation of a new org.apache.fop.layoutmgr.inline.AlignmentContext, which is taken into account by the LineLayoutManager associated to the fo:block. That context is used to determine the alignment point for the content of the fo:inline vis-à-vis the dominant-baseline of the enclosing line.

The above would expand to:

<fo:block alignment-adjust="auto"
         alignment-baseline="auto"
         baseline-shift="baseline"
         dominant-baseline="auto">
 test  <fo:inline font-family="Symbol"
                 alignment-adjust="auto"
                 alignment-baseline="auto"
                 baseline-shift="baseline"
                 dominant-baseline="auto">&#x2211;</fo:inline> test
</fo:block>

(analogously for the fo:character)

Strictly following the XSL-FO Rec, the behavior for the initial sample should be identical to using a fo:character, so most likely, something similar should happen when the font is switched in the TextLayoutManager internally. TextLayoutManager.AreaInfo does not carry a reference to any AlignmentContext like LeafNodeLayoutManager.AreaInfo. Instead the used AlignmentContext is always the one passed by the parent. (see TextLayoutManager.getNextKnuthElements(), third line in the method:
 alignmentContext = context.getAlignmentContext()

This is definitely the right place, thanks for pointing this out!


-> that context is used in addElementsForAWordFragment() when creating the corresponding KnuthInlineBox)

If we can simply make sure that each box gets the alignment context appropriate for the font used for the word-fragment, that should suffice. This could be done either by passing the AlignmentContext via the AreaInfo, as is done in the superclass, or by having the TextLM hold a reference to a collection of AlignmentContexts (one for each effectively used font), and use the appropriate one when creating the boxes.

I tried this, and it failed. At this point, there are too many variables called "aligmnmentContext". The superclass (LeafNodeManager) has one, TextLayoutManager has one, and LNM has a function "makeAlignmentContext" which is supposed to be overridden to supply a new AlignmentContext. This is confusing and needs to be cleaned up. I'll try investigating here.

I've tried modifying the alignmentContext by creating a child algnment context, and even by creating a direct clone (copying of all attributes) of the parent alignment context, and it always failed the testsuite. So at this point I belive there are some calles to setters which throw it off.

HTH!

Cheers

Andreas

Max

Reply via email to