Here's my problem: during XSLT processing to generate FO instances I need to be able to make a reasonable guess as to the rendered length of a given string so that I can do some simple automatic copy fitting, such as setting the list label width to fit the longest item in a definition list. I know this can't be exact because of variables like kerning and justification, but in the normal case of unjustified, relatively short strings I should be able to get within an Em width of the correct length.

I think I should be able to do this using the font metric support in the current development version of FOP but I'm having a hard time figuring out exactly what bits are involved. I think where I'm stuck is on what code actually takes a font and generates a metrics file from it. I've traced down to where the XML font metrics files are loaded but it appears that the font metrics files just exist.

Also, I need to be able to process OpenType fonts and it's not clear from the code and the archives whether that's currently implemented, although I did see a couple messages discussing it.

What I want to implement is an XSLT extension function something like this:

public static int renderedStringLength(String str,
                                       String fontFamilyName,
                                       int fontSize) {
        Font font = magicFopFontHelper.getFont(fontFamilyName,
                                               fontSize);
        return font.getWordWidth(str);
}

Obviously, it's the "magicFopFontHelper" class that I'm not sure how to go about constructing.

Can someone point me in the right direction?

Thanks,

Eliot
--
W. Eliot Kimber
Professional Services
Innodata Isogen
9030 Research Blvd, #410
Austin, TX 78758
(512) 372-8122

[EMAIL PROTECTED]
www.innodata-isogen.com




Reply via email to