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
> 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 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?
> 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:[email protected]]
Gesendet: Mittwoch, 17. Dezember 2008 17:32
An: [email protected]
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: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]