Tuesday, May 19, 2020

Dynamically Changing Font and Font Attributes


In the XDOUserGuide there is a section of Supported XSL-FO Elements (D1).  The section does not have any examples of how to use them.

I have created an example on how you may go about dynamically change the size of a font.

First I created a parameter called "fsize" to simulate varying the font size:

<?param@begin:fsize;string('20pt')?>


Below is the code that I will use.  It is mandatory that everything you see below is to go into a form field.


<fo:inline font-family="Arial" font-size="{$fsize}" font-weight="bold" font-style="italic"   hyphenate="yes "text-align="center">Now is the time for all good men to come to the aide of their comrades.</fo:inline>

The tricky part was to introduce the variable (fsize) into the markup. You have to encapsulate the variable with "{var}". Note that param's are referenced with a prefix of "$".