Ugly fonts on MacOS

37 views
Skip to first unread message

Bart Jourquin

unread,
Jun 5, 2020, 8:26:34 AM6/5/20
to openmap-users
Hi,

My app offers the possibility to choose a font for the labels (locations) to display. Even if not perfect, the rendering on Windows and Linux is acceptable, but it is really ugly on MacOS, as illustrated by the attached screenshot. Note that the rendering in the font chooser is OK (also in the picture). 

I’ve played with the -Dawt.useSystemAAFontSettings=setting (setting being ‘on', ‘gasp' or ‘lcd') JRE option, but this doesn’t have an impact.

Any idea ?

Bart


Don Dietrick

unread,
Jun 5, 2020, 10:39:34 AM6/5/20
to Bart Jourquin, openmap-users
Hi Bart,

OMText objects let you set the font they display, but they are set with a default.

 public static final transient Font DEFAULT_FONT = new Font("SansSerif", java.awt.Font.PLAIN, 12);

That should be updated to let you set it with a font chooser.

- Don

<Capture d’écran 2020-06-05 à 14.17.59.png>

--
You received this message because you are subscribed to the Google Groups "openmap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openmap-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openmap-users/856807DD-DC2D-4713-958D-72C0C91EC57D%40uclouvain.be.

Bart Jourquin

unread,
Jun 5, 2020, 10:58:42 AM6/5/20
to Don Dietrick, openmap-users
Hi Don,

Yes, my fonts are updated. I can even choose a color and use bold, italic… This works, but the render quality is bad on MacOS. The attached figures illustrate the case with an Arial-Bold-16 font. The output on Windows is acceptable, but not on MacOS.

Bart


Don Dietrick

unread,
Jun 5, 2020, 11:17:33 AM6/5/20
to Bart Jourquin, openmap-users
Hi Bart,

Are you also adjusting the rendering hints for text on the layer?  I’m wondering if different RenderingHints for text might help, if you set those in the RenderPolicy.

- Don

On Jun 5, 2020, at 10:58 AM, Bart Jourquin <bart.j...@uclouvain.be> wrote:

Hi Don,

Yes, my fonts are updated. I can even choose a color and use bold, italic… This works, but the render quality is bad on MacOS. The attached figures illustrate the case with an Arial-Bold-16 font. The output on Windows is acceptable, but not on MacOS.

Bart

<MacOS.png>

<windows.png>

Bart Jourquin

unread,
Jun 5, 2020, 11:52:55 AM6/5/20
to Don Dietrick, openmap-users
Yes, that’s it !!

Many thanks,

Bart

Bart Jourquin

unread,
Jun 8, 2020, 5:25:24 AM6/8/20
to Don Dietrick, openmap-users
Sorry to come back with the same issue…

As I mentioned in my last mail, rendering is now OK, but I tested the solution proposed by Don in a quick and dirty way, i.e., at the MapBean level (for all the layers thus). I used the following code at MapBean creation time:

RenderingHints rhnew RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
RenderingHintsRenderPolicy hints = new RenderingHintsRenderPolicy();
hints.setRenderingHints(rh);
HintsMapBeanRepaintPolicy hmbrp = new HintsMapBeanRepaintPolicy(mapBean);
hmbrp.setHints(hints);
mapBean.setMapBeanRepaintPolicy(hmbrp);

This works, but as rendering is applied to all the layers, this slows down the display of the maps, especially when multiple large layers are present.

Therefore, I’ve tried to associate the rendering to my LocationLayer only, using the following code in the constructor:

public class NodusLocationLayer extends LocationLayer {

// Replacement of the LocationLayer constructor which calls setRenderPolicy(new BufferedImageRenderPolicy(this));
public NodusLocationLayer() {

  RenderingHints rhnew RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  RenderingHintsRenderPolicy rp = new RenderingHintsRenderPolicy(this);
  rp.setRenderingHints(rh);
  setRenderPolicy(rp);

  setMouseModeIDsForEvents(new String[] {"Gestures"});
  }


Unfortunately, this doesn’t work. Did I miss something ?

Bart




Le 5 juin 2020 à 17:52, Bart Jourquin <bart.j...@uclouvain.be> a écrit :

Yes, that’s it !!

Many thanks,

Bart

<Capture d’écran 2020-06-05 à 17.50.42.png>

Don Dietrick

unread,
Jun 8, 2020, 7:55:34 AM6/8/20
to Bart Jourquin, openmap-users
Hi Bart,

I’d try setting a BufferedImageRenderPolicy on your layer and setting the RenderingHints on that (it extends RenderingHintsRenderPolicy).  That should isolate the rendering for the layer into the buffering image.

What you did should have worked, too, though.  I’m not sure why it didn’t.

- Don

Bart Jourquin

unread,
Jun 8, 2020, 8:46:53 AM6/8/20
to Don Dietrick, openmap-users
Hi Don,

Thanks for your answer. Do you mean this ?

RenderingHints rhnew RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
BufferedImageRenderPolicy rp = new BufferedImageRenderPolicy(this);
rp.setRenderingHints(rh);
setRenderPolicy(rp);

I’m afraid it’s not better…

Bart

Don Dietrick

unread,
Jun 8, 2020, 9:02:56 AM6/8/20
to Bart Jourquin, openmap-users
Hi Bart,

If you run in the debugger, can you follow the return from your prepare() method and make sure that RenderPolicy object hasn’t been replaced with something else?  The BufferedImageRenderPolicy should paint into the buffered image right after the layer.prepare() method is called after the projection changes.  You should be able to see the RenderingHints being set in the Graphics object, too.

- Don

Bart Jourquin

unread,
Jun 8, 2020, 9:11:08 AM6/8/20
to Don Dietrick, openmap-users
I’ve already tested this.

But I’ve just noticed that, if I replace the BufferedLayerMapBean my app is built on by a simple MapBean, it works. So, I’m afraid that, if I want to keep the benefits of a BufferedLayerMapBean, I’ll have to set the render policy on the bean, and not on a specific layer. Right ?

Maybe I could write a LayerMapBean…

Bart

Don Dietrick

unread,
Jun 8, 2020, 9:24:51 AM6/8/20
to Bart Jourquin, openmap-users
Now that is pretty interesting.  Is your layer marked as a background layer? What happens if you use a BufferedMapBean?

- Don
Reply all
Reply to author
Forward
0 new messages