On 17.12.2008 18:14:21 Georg Datterl wrote:
> Hi Jeremias,
> 
> > Uhm, why would you want to do such a thing in an XSL-FO environment?
> 
> Because I have a table with a variable number of columns and want to
> implement vertical splitting by calculating the width of all cell
> entries, get max width per column and see how much I can fit on the
> page. The other columns move to a new table below. Since I'm quite greedy with
> space, I need a result as close to the real print result as possible.
> java FontMetrics is not good enough (and 

ah, ok. Java Font Metrics are usually pretty close if you use the right
ones (there are low-resolution (pixel-oriented) and high-resolution
metrics). But they are still not quite good enough for doing
high-quality layout.

> > 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().
> 
> Well, I do have a FopFactory. But PDFRenderer has a default constructor.
> So has FontInfo. But I'm quite sure I'm thinking myself into
> incorrectly initialized territory here. 
> 
> I tried 
> 
> FontInfo info = new FontInfo();
> FontSetup.setup(info);
> FontTriplet unicode = info.createFontKey("arial unicode ms", 
> org.apache.fop.fonts.Font.STYLE_NORMAL, 
> org.apache.fop.fonts.Font.WEIGHT_NORMAL );
> org.apache.fop.fonts.Font funicode = info.getFontInstance(unicode, fontSize);

That won't work. You'll only have default base 14 fonts. The "Arial
Unicode MS" will certainly be replaced with "Helvetica" so you might not
have the right metrics.

> That gives me a nice looking FontTriplet, and the FontInfo object has
> internal Fonts set, but only default fonts, no fonts from fop.xconf.
> Are these fonts somewhere in PDFRenderer? 

Yes, PDFRenderer's FontInfo object gets configured through the
PDFRendererConfigurator. See RendererFactory, too. In the end, you can
get the FontInfo object using pdfRenderer.getFontInfo(). But the
configuration most probably has to occur on the PDFRenderer instance
you have to pass in through the renderer override I mentioned before.

> > 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.
> 
> No problem, I work in pt anyway.
> 
> Mit freundlichen Grüßen
>  
> Georg Datterl
>  
> ------ Kontakt ------
>  
> Georg Datterl
>  
> Geneon media solutions gmbh
> Gutenstetter Straße 8a
> 90449 Nürnberg
>  
> HRB Nürnberg: 17193
> Geschäftsführer: Yong-Harry Steiert 
> 
> Tel.: 0911/36 78 88 - 26
> Fax: 0911/36 78 88 - 20
>  
> www.geneon.de
>  
> Weitere Mitglieder der Willmy MediaGroup:
>  
> IRS Integrated Realization Services GmbH:    www.irs-nbg.de 
> Willmy PrintMedia GmbH:                            www.willmy.de
> Willmy Consult & Content GmbH:                 www.willmycc.de 
> -----Ursprüngliche Nachricht-----
> Von: Jeremias Maerki [mailto:d...@jeremias-maerki.ch] 
> Gesendet: Mittwoch, 17. Dezember 2008 17:32
> An: fop-users@xmlgraphics.apache.org
> Betreff: Re: Usage of Font.getWordWidth()
> 
> 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