Loading ...
Sorry, an error occurred while loading the content.

Re: Center block if less than two lines

Expand Messages
  • louis_meigret
    ... want ... text ... the ... that ... accurate ... Yes, this is what I did. ... Well, I use a BufferedImage, that allowed me to skip the Window part, although
    Message 1 of 3 , Aug 23, 2003
    • 0 Attachment
      --- In XSL-FO@yahoogroups.com, "W. Eliot Kimber" <eliot@i...> wrote:
      > louis_meigret wrote:
      > > Is it possible in Fo that implement this logic («say what you
      > > not how to do it») :
      > >
      > > the fo:block should have its text content centered if the block
      > > content is less than 3 lines long (1 or 2) otherwise indeed the
      > > 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.
      > In theory, it would be possible to write an XSLT extension function
      > used some font metrics implementation to calculate reasonably
      > width measurements for text. This would allow you to do some copy
      > fitting in an XSLT process.

      Yes, this is what I did.

      > My main barrier to implementing this is lack of an easily-available
      > 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.

      Well, I use a BufferedImage, that allowed me to skip the
      Window part, although this is also in AWT.

      >RenderX has said that they
      > intend to make their FontMetrics implementation available to the
      > community at some point.

      Interesting, I am actually using RenderX, I will ask them.

      > This approach could not solve all layout problems but it would
      > simple copy fitting, such as finding the width of the longest term
      >in a
      > 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 the
      > what the current font characteristics are (font family and size,
      > 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:
      > <xsl:value-of name="formatted-length"
      > select="fontfuncs:calcFormattedLength($stringToCheck,
      > $fontFamily,
      > $fontSize,
      > $fontWeight)

      Yes, my function looks very close to this, but it
      takes an additional parameter the line size and returns
      the number of lines needed to display it.

      Many Thanks,

    Your message has been successfully submitted and would be delivered to recipients shortly.