XF Ultrascale 2011 supports automatic font size adjustment for fo:block-container elements to fit the contents into a specified area. The extension used to perform this is xf:fit-content, which is an attribute specified on the fo:block-container. The possible values for this are true and false.
Usage:
<fo:block-container xf:fit-content="BOOLEAN" width="LENGTH_OR_PERCENT" height="LENGTH_OR_PERCENT" xf:max-iterations="INTEGER" xf:fit-tolerance="FLOAT">
<!-- block container text here -->
</fo:block-container>
Example:
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xf="http://www.ecrion.com/xf/1.0">
<fo:layout-master-set>
<fo:simple-page-master master-name="p1" page-width="7in" page-height="2in">
<fo:region-body region-name="xsl-region-body" margin="0.2in" background="silver"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="p1">
<fo:flow flow-name="xsl-region-body" font-family="Helvetica" font-size="16pt">
<fo:block>
<fo:block-container text-align="justify" color="red" xf:fit-content="true" position="absolute" top="18pt" left="40pt" height="105pt" width="80%" background="yellow">
<fo:block>
<fo:inline>Fit Text 1</fo:inline>
Fit Text 1 Fit Text 1 Fit Text 1 Fit Text 1 Fit Text 1
Fit Text 1 Fit Text 1 Fit Text 1 Fit Text 1 Fit Text 1
Fit Text 1 Fit Text 1 Fit Text 1 Fit Text 1 Fit Text 1
Fit Text 1 Fit Text 1 Fit Text 1 Fit Text 1 Fit Text 1
Fit Text 1 Fit Text 1 Fit Text 1 Fit Text 1 Fit Text 1
</fo:block>
<fo:block>
<fo:inline>Fit Text 2</fo:inline>
Fit Text 2 Fit Text 2 Fit Text 2 Fit Text 2 Fit Text 2
Fit Text 2 Fit Text 2 Fit Text 2 Fit Text 2 Fit Text 2
Fit Text 2 Fit Text 2 Fit Text 2 Fit Text 2 Fit Text 2
Fit Text 2 Fit Text 2 Fit Text 2 Fit Text 2 Fit Text 2
Fit Text 2 Fit Text 2 Fit Text 2 Fit Text 2 Fit Text 2
</fo:block>
</fo:block-container>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
When using this extension, it's possible to set parameters for it using the xf:max-iterations and xf:fit-tolerance attributes on the fo:block-container:
| • | max-iterations specifies the maximum number of tries to fit the contents properly. Default is 10. |
| • | fit-tolerance specifies the error tolerance for the algorithm when trying to fit the exact height of the block container. Default is 0.05. |
The output looks like this:
