FontMetrics' getHeight() doesn't behave accurately
FontMetrics' getHeight() doesn't behave accurately
I would like to layout a string in an SVG image. FontMetrics' getHeight() method allows me to compute the height of a character in my string and the stringWidth() method allows me to compute the total width. Using these values, it is straightforward to compute the height of the drawing area needed, if I restrict the width of the drawing area to a fixed constant value. But it appears that the answer I get is not consistent with the actual height needed. It appears that when FontMetrics' methods are accessed "through" JFreeSVG, the height returned is always smaller than the correct height needed to layout the string in a particular font. Is this known behavior? Has anybody found a fix?
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: FontMetrics' getHeight() doesn't behave accurately
The problem here is that JFreeSVG has to use Java API calls to "measure" the text but ultimately the rendering will be done by some other platform (typically a web browser, very often on a different computer from where the SVG was generated). There's no guarantee that the two font rendering systems will give consistent results.
I guess there are ways to deal with this in SVG but so far I haven't had time to investigate it properly.
I guess there are ways to deal with this in SVG but so far I haven't had time to investigate it properly.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
![Idea :idea:](./images/smilies/icon_idea.gif)
![Idea :idea:](./images/smilies/icon_idea.gif)