com.octo.captcha.component.image.fontgenerator
Class RandomFontGenerator

java.lang.Object
  extended by com.octo.captcha.component.image.fontgenerator.AbstractFontGenerator
      extended by com.octo.captcha.component.image.fontgenerator.RandomFontGenerator
All Implemented Interfaces:
FontGenerator
Direct Known Subclasses:
DeformedRandomFontGenerator, TwistedRandomFontGenerator

public class RandomFontGenerator
extends AbstractFontGenerator

Description: Random font generator that return one of the available system's (or optionay specified) fonts, using a min and max font size. This list is formerly cleaned of OCR readable font and symbol font


Field Summary
static java.lang.String[] defaultBadFontNamePrefixes
          Prefixes of font names that are avoided by default.
protected  java.util.Random myRandom
           
 
Constructor Summary
RandomFontGenerator(java.lang.Integer minFontSize, java.lang.Integer maxFontSize)
           
RandomFontGenerator(java.lang.Integer minFontSize, java.lang.Integer maxFontSize, java.awt.Font[] fontsList)
           
RandomFontGenerator(java.lang.Integer minFontSize, java.lang.Integer maxFontSize, java.lang.String[] badFontNamePrefixes)
           
 
Method Summary
protected  java.awt.Font applyCustomDeformationOnGeneratedFont(java.awt.Font font)
          Provides a way for children class to customize the generated font array
protected  java.awt.Font applyStyle(java.awt.Font font)
           
protected  java.util.List cleanFontList(java.awt.Font[] uncheckFonts)
          Create an array of fonts that is known to properly represent all the characters in requiredCharacters.
 java.lang.String[] getBadFontNamePrefixes()
           
 java.awt.Font getFont()
          Method from imageFromWord method to apply font to String.
 java.lang.String getRequiredCharacters()
           
 void setBadFontNamePrefixes(java.lang.String[] badFontNamePrefixes)
           
 void setRequiredCharacters(java.lang.String requiredCharacters)
           
 
Methods inherited from class com.octo.captcha.component.image.fontgenerator.AbstractFontGenerator
getMaxFontSize, getMinFontSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultBadFontNamePrefixes

public static java.lang.String[] defaultBadFontNamePrefixes
Prefixes of font names that are avoided by default. The default values list fonts that are totally fine in terms of representing characters, of course, but they're too commonly available in OCR programs.


myRandom

protected java.util.Random myRandom
Constructor Detail

RandomFontGenerator

public RandomFontGenerator(java.lang.Integer minFontSize,
                           java.lang.Integer maxFontSize)

RandomFontGenerator

public RandomFontGenerator(java.lang.Integer minFontSize,
                           java.lang.Integer maxFontSize,
                           java.awt.Font[] fontsList)

RandomFontGenerator

public RandomFontGenerator(java.lang.Integer minFontSize,
                           java.lang.Integer maxFontSize,
                           java.lang.String[] badFontNamePrefixes)
Method Detail

getFont

public java.awt.Font getFont()
Method from imageFromWord method to apply font to String. Implementations must take into account the minFontSize and the MaxFontSize.

Returns:
a Font

applyStyle

protected java.awt.Font applyStyle(java.awt.Font font)

applyCustomDeformationOnGeneratedFont

protected java.awt.Font applyCustomDeformationOnGeneratedFont(java.awt.Font font)
Provides a way for children class to customize the generated font array

Parameters:
font -
Returns:
a customized font

cleanFontList

protected java.util.List cleanFontList(java.awt.Font[] uncheckFonts)
Create an array of fonts that is known to properly represent all the characters in requiredCharacters.

Returns:
array of fonts
See Also:
requiredCharacters

getRequiredCharacters

public java.lang.String getRequiredCharacters()
Returns:
a list of characters that this class must be able to represent

setRequiredCharacters

public void setRequiredCharacters(java.lang.String requiredCharacters)
Parameters:
requiredCharacters - a list of characters that this class must be able to represent

getBadFontNamePrefixes

public java.lang.String[] getBadFontNamePrefixes()
Returns:
an array of font name prefixes that should be not used in generating captchas

setBadFontNamePrefixes

public void setBadFontNamePrefixes(java.lang.String[] badFontNamePrefixes)
Parameters:
badFontNamePrefixes - an array of font name prefixes that should be not used in generating captchas


Copyright 2003-2009 JCaptcha. All Rights Reserved.