By battochir on
Does anyone off hand know how to change the font types and font sizes used by the captcha module? The letters are too small for my taste and I'd like a new font. I have loaded a new font and it's path in the configuration a few times. No dice. Any ideas?
thanks,
Wim
Comments
Edit captcha.module
In my test setup I use Vera Sans and Vera Serif for the captchas.
I created the directory d:\wwwroot\drupal\fonts and copied the files vera.ttf and verase.ttf to the new directory.
On the captcha settings screen in Drupal I have 'True Type Fonts Path' set to d:/wwwroot/drupal/fonts
After saving the settings 'Image and font information' shows:
To change the font size, edit the value of the variable $charSize in the _captcha_image() function in captcha.module. You have to modify the image size and the initial value of $y as well. My settings for a 48pt font are:
(Although a width of 320 still results in some clipping every now and then.)
Font path
The path you entered appears to be an ablsolute path (on a windows pc?). I'm on a shared server, so I found out what my absoulute path is on the linux server and tried that, but got an error saying it couldn't be found.
I've also tried the path relative to my drupal install, and relative to my httdoc root. Still no joy. Any ideas?
Same Here...
The message I get is the same...
The current font path is invalid. The default font will be used.
I have also tried the absolute path and this did not work.
It's quite old this post,
It's quite old this post, but just for the record, type fonts in the font path and that works fine.
__________________
http://www.wilba.org
thanks....
Hei Helsinki,
Yes it's old but I still follow them! Thanks.
Kitos,
wim
ei mitään
ei mitään ;-)
__________________
http://www.wilba.org
Solution!
I'm using Drupal 4.7.0 but I guess this also works for captcha for version 4.6.x as well. I had installed my fonts in the directory "D:\websites\home\fonts\". Note that my Drupal directory is "D:\websites\home\" - this info is important.
I had a persistent path not found error. I initially set it to "/fonts". No dice.
Then I set it to "fonts". No dice again.
Set it to "D:\websites\home\fonts\". No dice still.
Searched Drupal site. They said absolute directory reference "D:\websites\home\fonts\" should work. And even also just "fonts".
Retried both. Still didn't work. Then I noticed that the path not found error was looking at "/font" still - notice that I've already changed it to "D:\websites\home\fonts\" or "fonts". So I THEN created a directory "D:\fonts\" temporarily. Retried both "D:\websites\home\fonts\" and just "fonts" and now they work. Now I can remove the "D:\fonts\".
It appears that the captcha module kept looking for "/fonts" at the beginning of its code even though I have changed from it already
Faultless, huh?
Fix the Captcha module
Change the top of the captcha_settings function (line 45) in modules/captcha/captcha.module to have this instead of the existing code:
This repairs the rather odd settings method that causes Drupal to remember the OLD settings (basically it will read the OLD variable before the new one is set, resulting in a broken setting that can never be changed). This code directly resets the captcha path variable in order to "forget" the bad setting. No other changes in the module are needed.