| | * a document to transform them into rasterized versions. |
| | */ |
| | -public class SvgReplacedElementFactory |
| | - implements ReplacedElementFactory { |
| | +public class SvgReplacedElementFactory implements ReplacedElementFactory { |
| | + |
| | + /** |
| | + * Prevent instantiation until needed. |
| | + */ |
| | + private static class LazyContainer { |
| | + private static final MathRenderer INSTANCE = new MathRenderer(); |
| | + } |
| | + |
| | + /** |
| | + * Returns the singleton instance for rendering math symbols. |
| | + * |
| | + * @return A non-null instance, loaded, configured, and ready to render math. |
| | + */ |
| | + public static MathRenderer getInstance() { |
| | + return LazyContainer.INSTANCE; |
| | + } |
| | |
| | /** |
 |
| | private static final String HTML_IMAGE = "img"; |
| | private static final String HTML_IMAGE_SRC = "src"; |
| | - |
| | - private static final MathRenderer sMathRenderer = new MathRenderer(); |
| | |
| | /** |
 |
| | final var src = e.getTextContent(); |
| | image = getCachedImage( |
| | - src, __ -> rasterize( sMathRenderer.render( src ) ) |
| | + src, __ -> rasterize( getInstance().render( src ) ) |
| | ); |
| | } |