xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tomas Rimšelis <tori3...@gmail.com>
Subject Re: Text of given font width
Date Wed, 06 Jan 2010 12:55:06 GMT
I have came up with the solution - I've
used FontMetrics's getWidth(codePoint, fontSize) for the character width and
sum all the characters in a word. It is not as clear as a solution with Java
AWT, but still it works.

2010/1/4 Tomas Rimšelis <tori3852@gmail.com>

> Hello,
> I need to programatically get a width of some text (word, specifically) in
> a given font, size and style, which will be generated in Apache FOP (version
> 0.95) PDF document.
>
> The problem is that I need to know, if given word will fit to a column with
> a known width, and if it won't - resize to a fitable size. So far I have
> used java.awt.FontMetrics.stringWidth() method for this, but it seems that
> Java AWT's and FOP's PDF renderer generate text of different sizes.
>

Mime
View raw message