When you go into the Image Captcha settings, you're presented with a textbox asking you the path of the TrueType font file to use. This isn't really an intuitive solution because most users don't know exact paths, so I turned it into a selection box where you select which font to use. This solution also fixes the problem when there isn't any fonts installed, as it then spits out an error, telling you that some TTF fonts are required.

Please see and review the attached patch.

Comments

soxofaan’s picture

I was also thinking of this.

But maybe we could also (recursively) scan the drupal "files" directory, which is easier for users to upload a font to.

I didn't test the patch yet

soxofaan’s picture

StatusFileSize
new5.61 KB

You can do the font listing much easier with the help of drupal's file_scan_directory() function.
I worked some more on your patch (see attachment):

  • font are searched for in both "image_captcha/fonts" and drupal's "files" directory
  • the change from textfield to select box also means a simpler validation function
  • added more elaborate error messages
  • I streamlined the error handling to catch more error situations like unset/unreadable/renamed font files.
  • when captcha generation for untrusted users failed because of unset/unreadable font, an error is recorded in the logs. Untrusted user won't see any error messages.
robloach’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)