FontMapper is not being carried over to child Graphics2D

A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).
Post Reply
p_a_harvey
Posts: 1
Joined: Thu Aug 04, 2016 10:17 pm
antibot: No, of course not.

FontMapper is not being carried over to child Graphics2D

Post by p_a_harvey » Thu Aug 04, 2016 10:19 pm

When calling Graphics2D.create(), I would expect the child Graphics2D object to be the same as the original parent Graphics2D object, including the FontMapper. This doesn't seem to be the case.

Code: Select all

public class Test {
	public static void main(String[] args) {
		SVGGraphics2D parent = new SVGGraphics2D(100, 100);
		parent.setFontMapper(new FontMapper() {
			@Override
			public String mapFont(String arg0) {
				return arg0;
			}
		});

		/*
		 * Create a child Graphics2D. Should be the same as the parent,
		 * including the font mapper.
		 */
		SVGGraphics2D child = (SVGGraphics2D) parent.create();

		/* Print out the font mapper. Seems to be different. */
		System.err.println("Parent font mapper = " + parent.getFontMapper());
		System.err.println("Child font mapper = " + child.getFontMapper());
	}
}

david.gilbert
JFreeChart Project Leader
Posts: 11666
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: FontMapper is not being carried over to child Graphics2D

Post by david.gilbert » Tue Aug 16, 2016 10:47 pm

That's a bug in my opinion. I'll fix it.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited

david.gilbert
JFreeChart Project Leader
Posts: 11666
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: FontMapper is not being carried over to child Graphics2D

Post by david.gilbert » Sat Aug 20, 2016 2:42 pm

This should fix it. Will be in the 3.2 release.

https://github.com/jfree/jfreesvg/commi ... 2610334506
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited

Post Reply