Search code examples
codenameonedrawsimulatorantialiasing

Is there a way to set whether text is anti-aliased in the codenameone simulator?


My app uses a subclass of Label. I am hoping to capture a screencast (video) of the app in the simulator, to use as part of the app's "in-app tutorial". This would either be an MP4 or an animated GIF.

At this stage, I'd like to capture the animation with text that is not anti-aliased. (I'm hoping I can get the file size down by reducing the number of colors in the GIF. This may be a fool's errand, but I want to do the experiment...)

I've tried the following but the results (in the CN1 simulator) were still anti-aliased.

// This is a subclass of Label
@Override
public void paint(Graphics g) {
    g.setAntiAliased(false);
    g.setAntiAliasedText(false);
    super.paint(g);
}

I also tried variants where I didn't rely on super.paint(g), and instead simply drew a hard-coded "TEST" string. It was still anti-aliased.


Solution

  • There is no easy way to do that and I'm not sure why you would want it. But if you want to just demonstrate/test something in the simulator it's pretty easy to edit the Codename One source code and toggle anti aliasing off either in Graphics itself or in the DefaultLookAndFeel class.

    To use the source code see this http://www.codenameone.com/blog/how-to-use-the-codename-one-sources.html