option for defining fonts for captchas

merge-requests/208/head
fatchan 4 years ago
parent f9ede2a1c7
commit aeec30fa95
  1. 15
      configs/main.js.example
  2. 3
      helpers/captcha/captchagenerate.js

@ -39,7 +39,8 @@ module.exports = {
min: 3,
max: 5
},
paintAmount: 2
paintAmount: 2,
fontPaths: [], //optional list of file paths to fonts for captchas
},
/* dnsbl, will add a small delay for uncached requests. You could also install some
@ -64,6 +65,10 @@ module.exports = {
its not recommended to change this setting after initial setup */
ipHashMode: 1,
/* delete files immediately rather than pruning later. usually disabled to prevent re-thumbnailing and processing commonly
uploaded files, but deleting immediately is better if you are concerned about "deleted" content not being immediately removed */
pruneImmediately: false,
//cache templates in memory. disable only if editing templates and doing dev work
cacheTemplates: true,
@ -126,10 +131,6 @@ module.exports = {
regex=custom regex of what to replace e.g. /[^\w\s-]+/g */
filterFileNames: false,
/* delete files immediately rather than pruning later. usually disabled to prevent re-thumbnailing and processing commonly
uploaded files, but deleting immediately is better if you are concerned about "deleted" content not being immediately removed */
pruneImmediately: false,
//options for code block highlighting in posts
highlightOptions: {
@ -262,6 +263,6 @@ module.exports = {
audio: true,
other: false
}
}
},
}
};

@ -53,6 +53,9 @@ module.exports = async () => {
const captcha = gm(width,height,'#ffffff')
.fill('#000000')
.fontSize(65);
if (captchaOptions.fontPaths && captchaOptions.fontPaths.length > 0) {
captcha.font(captchaOptions.fontPaths[Math.floor(Math.random() * captchaOptions.fontPaths.length)]);
}
const startX = (width-totalWidth(text))/2;
let charX = startX;
for (let i = 0; i < 6; i++) {

Loading…
Cancel
Save