FontMetrics to FxFontMetrics

To convert from AWT to AFC, instances of java.awt.FontMetrics should be transformed into instances of com.ms.fx.FxFontMetrics.

Purpose and Usage

FxFontMetrics extends from FontMetrics, so everything you could do before can still be done. However, FxFontMetrics provides new functionality and some advantages. First, you can instantiate FxFontMetrics by looking at the Graphics object using the font, by instantiating it as

new FxFontMetrics(Font, Graphics)

instead of just

new FxFontMetrics(Font)

In addition, FxFontMetrics provides additional functions, like canDrawOutline(), which returns whether the font can be drawn in outline mode, and getAveCharWidth(), which returns the average character width for the current font. The documentation provides more features.

Porting

FxFontMetrics extends FontMetrics, so no changes need to be made to create AFC applications. It is recommended, though, that you change FontMetrics instances to FxFontMetrics instances, and note that if you wish to get the metrics of the font based on a graphics object, you will have to use the new constructor described above.