Re: Center block if less than two lines
- --- In XSL-FO@yahoogroups.com, "W. Eliot Kimber" <eliot@i...> wrote:
> louis_meigret wrote:want
> > Is it possible in Fo that implement this logic («say what you
> > not how to do it») :text
> > the fo:block should have its text content centered if the block
> > content is less than 3 lines long (1 or 2) otherwise indeed thethe
> > second and subsequent lines of this block ?
> No. The best you can do is try to guess at the content length in
> generation of the FO instance.that
> In theory, it would be possible to write an XSLT extension function
> used some font metrics implementation to calculate reasonablyaccurate
> width measurements for text. This would allow you to do some copyYes, this is what I did.
> fitting in an XSLT process.
> My main barrier to implementing this is lack of an easily-availableWell, I use a BufferedImage, that allowed me to skip the
> metrics Java library--Java has a FontMetrics class but the only
> implementation shipped with Java out of the box only works in the
> context of an AWT (user interface) window.
Window part, although this is also in AWT.
>RenderX has said that theyInteresting, I am actually using RenderX, I will ask them.
> intend to make their FontMetrics implementation available to the
> community at some point.
> This approach could not solve all layout problems but it wouldenable
> simple copy fitting, such as finding the width of the longest termof
> definition list or calculating the number of lines a string might
> require. It would be limited since it couldn't have full knowledge
> the rendering context. It would also require that you know in theXSLT
> what the current font characteristics are (font family and size,and
> possibly line height).Yes, I'm passing these parameters to my extension function (I know
them). BTW Is there a way to query FO properties (I don't think so).
To be able at run time when calling my extension function
to say this is the font size, this is the current block width,
block indentation. Would really be neat, after all it seems that
FO is best suited for automated generation of dynamic documents,
why not add these query functions to increase the automaticity
(and quality) aspects.
> Essentially, I'm thinking of an extension function like this:Yes, my function looks very close to this, but it
> <xsl:value-of name="formatted-length"
takes an additional parameter the line size and returns
the number of lines needed to display it.