akiraly / cage

Cage is a CAptcha image GEnerator java library. It is fast, small and simple. Its goal is to generate images that are easy to read for a human but impossible or at least very hard for a computer.
http://akiraly.github.com/cage/
66 stars 34 forks source link

Spacing of Fonts #6

Closed vishnoor closed 3 years ago

vishnoor commented 3 years ago

Hi, is there anyway I can get the fonts to have a bit of spacing between them? They all get clumped up together with no spacing between fonts. Example code

![clumped_up_captcha](https://user-images.githubusercontent.com/7250331/98228460-a173e700-1f7e-11eb-8149-e340038704a0.png) import java.awt.Color; import java.awt.Font; import java.awt.image.BufferedImage; import java.util.Random;

import com.github.cage.Cage;
import com.github.cage.image.EffectConfig;
import com.github.cage.image.Painter;

public class ACage extends Cage {

    private Painter painter;

public ACage() {
    super();

    EffectConfig effectConfig = new EffectConfig(false, false, false, false, null);
    this.painter = new Painter(100, 50, Color.WHITE, 
                                    Painter.Quality.MAX, effectConfig, new Random());
}

@Override
public BufferedImage drawImage(String text) {

    Font font =new Font("Purisa", Font.PLAIN, 12);

    return painter.draw( font, Color.BLACK, text);
}

} `

vishnoor commented 3 years ago

Any body else facing this issue, create a copy of Painter.java and comment out the line which calls function transform in function void draw(Graphics2D g, String text)

    protected void draw(Graphics2D g, String text) {
        final GlyphVector vector = g.getFont().createGlyphVector(
                g.getFontRenderContext(), text);

        //transform(g, text, vector);