Uhm, why would you want to do such a thing in an XSL-FO environment?

Anyway, you need access to the FontInfo object that is attached to the
PDFRenderer (somehow). If you set up the PDFRenderer yourself and set it
using FOUserAgent.setRendererOverride(), that could work. From there,
you can get a FontTriplet using FontInfo.fontLookup(). With a
FontTriplet you can get a Font object using FontInfo.getFontInstance().
The units from the Font object will most likely be millipoints (a 1000th
of a point, our internal unit). You can use UnitConv to convert those.
Sorry, I don't have a recipe ready at hand. I've never had to do
something like that from outside FOP.

On 17.12.2008 17:06:46 Georg Datterl wrote:
> Hi everybody,
> 
> Maybe it's too late in the year for my brain to work properly, but I
> want to call Font.getWordWidth(String) to find out how much space a
> string will take in the finished PDF, but I can't figure out how I can
> get the Font object given the values for font-family and font-size
> (which are the values I later write into the fo-file). 
> 
> The fonts are there and registered correctly in my fop.xconf, are used
> when generating the PDF and generally work fine. I also tried to read
> through the source code, but came from Font to FontMetrics to FontInfo
> to CommonFont to CompleteConfusion. 
> 
> Second question: When I finally get a result, what unit would that be in?
> 
> Regards,
>  
> Georg Datterl
>  



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org

Reply via email to