Hi all,

First of all I'd like to thank all who answered.

I'd like to share code, results, toughts and ask some more support .

Let's start from the code (many thanks to Matthias):


Here the result:


The Font:getWordWidth is very inaccurate for a long string, becuase for each
character the size is floored to integer [point], means that in worst case
you miss 1 point per char.

I've generated a big document to mesure the real width of the string, and I
got results near the FontMetrics:getWidth ... 3 to 5 points miss, thise are
probably due to my imperfection doing the mesurement manually.

My toughts:
I agree with Glenn when he says

Glenn Adams-2 wrote
> However, calling getCharWidth() on a given character will not necessarily
> produce the same results as FOP regarding line fitting due to the affects
> of:
> 
>    - kerning
>    - letter/word spacing
>    - complex script features (GSUB/GPOS) which apply to all scripts
> 
> In general, I would expect summing getCharWidth() over some substring of
> text to be line fitted will produce a larger width than FOP may end up
> using. So such estimates could be used for upper bounds of required
> measure, but not lower bounds.

The best way to get those points into account is to do the calculation with
the exact code that fop uses in placing the characters into a block. 
For my objective is not needed because:
 - the font I'm using does not uses kernering
 - I'm placing the text left aligned into the block (no justified)
 - (I don't know anything about "complex script features", first time I hear
about this)  

I indeed use a custom letter-spacing, but I assume I can add to my result
"mySpacing * (text.lenght()-1)" .. (right?)
About the word-spacing, are there specific cases where the length of a
"normal white space" diffears ftom the one defined into the font?


And now I need an additional support; As I mentioned in my first post I'm
using a custom font, loaded through the custom fop.xconf.

But the  loads only the predefined fonts metrics (F1 to F14).

How do I load the metrics of my custom font?

Best regards,
Curzio



--
View this message in context: 
http://apache-fop.1065347.n5.nabble.com/Extract-font-width-using-FOP-tp37360p37383.html
Sent from the FOP - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to