[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] XSL:FO dynamic font size based on width
Subject: Re: [xsl] XSL:FO dynamic font size based on width From: Eliot Kimber <ekimber@xxxxxxxxxxxx> Date: Thu, 26 Jun 2008 16:16:57 -0500 |
On 6/26/08 10:49 AM, "Angela Williams" <Angela.Williams@xxxxxxxxxxxxxxxxxx> wrote: > You can simulate the auto-shrink behavior in your stylesheet. > > I would pre-determine how many characters fit per line when my font size > is 12pt, how many fit for 10pt, etc. You could use percentages or other > size units, just be consistent. Then I would create a template that > would determine which font size to use based on the number of characters > in the title. In the past I have done this by creating an Java XSLT extension that uses the Java 2D graphics package to determine the approximate rendered length of a given string in a given font at a given size. It works well enough for relatively short strings, such as single titles, definition list entries, and so forth. For longer strings the difference between the Java-determined length and the length the FO engine will actually use is too variable to be reliable (you can't use it for good line casting, for example). For example, I used it to adjust the font size used for examples so that the longest line of the example content would fit within the available display width. With XSL Formatter you could do the trick where you format stuff in isolation and use the XSL Formatter API to get the rendered details and then feed that into a second pass. I imagine XEP has similar capabilities. We used this technique to determine how many pages tables would take up in order to generate accurate lists of effective pages where the page count had to include the length of the LOEP table itself. I don't have access to any example code any more but it wasn't that hard. You just need to know the font and the size. The actual Java programming required was just a few lines, if memory serves. Cheers, Eliot ---- Eliot Kimber | Senior Solutions Architect | Really Strategies, Inc. email: ekimber@xxxxxxxxxxxx <mailto:ekimber@xxxxxxxxxxxx> office: 610.631.6770 | cell: 512.554.9368 2570 Boulevard of the Generals | Suite 213 | Audubon, PA 19403 www.reallysi.com <http://www.reallysi.com> | http://blog.reallysi.com <http://blog.reallysi.com> | www.rsuitecms.com <http://www.rsuitecms.com>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSL:FO dynamic font size , Angela Williams | Thread | Re: [xsl] XSL:FO dynamic font size , Wasiq Shaikh |
Re: AW: [xsl] XML to PDF (XSL:FO), B Tommie Usdin | Date | [xsl] How to resolve a xpath refere, Kai Hackemesser |
Month |