spring.turbo.module.misc.captcha.google.renderer.BestFitTextRenderer Maven / Gradle / Ivy
package spring.turbo.module.misc.captcha.google.renderer;
/**
* @since 1.0.0
*/
public class BestFitTextRenderer extends AbstractTextRenderer {
@Override
protected void arrangeCharacters(int width, int height, TextString ts) {
double widthRemaining = (width - ts.getWidth() - leftMargin - rightMargin) / ts.getCharacters().size();
double x = leftMargin + widthRemaining / 2;
height -= topMargin + bottomMargin;
for (TextCharacter tc : ts.getCharacters()) {
double y = topMargin + (height + tc.getAscent() * 0.7) / 2;
tc.setX(x);
tc.setY(y);
x += tc.getWidth() + widthRemaining;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy