for ($i = 0; $i < strlen($a); $i++) { if ($a[$i] != $b[$i]) { $diff += abs($a[$i] - $b[$i]); } } return $diff; } function containt($c1, $c2) { return false; } $fileData = []; $result = []; $lastX = ''; $lastC = null; $chainBuilder = new \esee\ChainBuilder($points); foreach ($points as $y => $point) { foreach ($point as $x => $v) { if ($v == 1) { $c = $chainBuilder->makeChain2($x, $y); if (is_null($c)) { continue; } if (!is_null($lastC) && containt($lastC, $c)) { continue; } $lastC = $c; $str = join('', $c->path); //echo $str . "\n"; $length = strlen($str); if ($length < 2) {
} } return $points; } function getFirst($points) { foreach ($points as $y => $row) { foreach ($row as $x => $v) { if ($v == 1) { return [$x, $y]; } } } return [0, 0]; } $c = new \esee\ChainBuilder([]); foreach ($fonts as $font) { foreach ($chars as $char) { //6,7,8, $size = [9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24]; foreach ($size as $s) { $im = imagecreatetruecolor(40, 40); $white = imagecolorallocate($im, 0xff, 0xff, 0xff); $black = imagecolorallocate($im, 0x0, 0x0, 0x0); imagefill($im, 0, 0, $white); //echo $fontDir . $font . "\n"; exit(); imagefttext($im, $s, 0, 5, 30, $black, $fontDir . $font, $char); $points = getPoints($im, 40, 40); list($x, $y) = getFirst($points); $c->reset($points); $chain = $c->makeChain2($x, $y);