website logo
Auteur
avatar
Visiteur

Forum » » Le coin des codeurs » » [Résolu] - Bug du captcha en chinois


Posté : 21 juil. 2026 à 16:53 icone du post

DejaVuSans.ttf https://www.fontsquirrel.com/fonts/dejavu-sans
DejaVuSans.ttf (direct) https://github.com/senotrusov/dejavu-fonts-ttf/blob/master/ttf/DejaVuSans.ttf

https://raw.githubusercontent.com/deepin-community/fonts-wqy-zenhei/master/wqy-zenhei.ttc



case 'captcha':
$mot = decrypt($att_id); // gardez en UTF-8

// Choix de la police selon la langue
if (isset($language) && $language === 'chinese') {
$fontFile = 'fonts/wqy-zenhei.ttc';
} else {
$fontFile = 'fonts/DejaVuSans.ttf';
}

// Utilisation directe de imagettftext
$fontSize = 16;
$angle = 0;
$bbox = imagettfbbox($fontSize, $angle, $fontFile, $mot);
$width = $bbox[2] - $bbox[0] + 4;
$height = $bbox[1] - $bbox[5] + 4;
$img = imagecreate($width, $height);
$blanc = imagecolorallocate($img, 255, 255, 255);
$noir = imagecolorallocate($img, 0, 0, 0);
imagecolortransparent($img, $blanc);
$x = -$bbox[0] + 2;
$y = -$bbox[5] + 2;
imagettftext($img, $fontSize, $angle, $x, $y, $noir, $fontFile, $mot);
imagepng($img);
imagedestroy($img);
break;

 Message édité par : nicolas2 / 21/07/2026 23:30

Cet article provient de NPDS
https://www.npds.org/viewtopic.php?topic=27112&forum=5