endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.41k stars 725 forks source link

imagettfbbox(): Could not find/open font #423

Closed LeQuangKhai99 closed 11 months ago

LeQuangKhai99 commented 11 months ago

I have error image image It error when i add label. It seems like it can't read the default font file

endroid commented 11 months ago

Hi @LeQuangKhai99 what version are you using? The current version checks if the path to the font exists (this happens in Label::create) while the imagettfbbox method is called later, when writing the image. So it appears that the font does exist but it can't be opened. Please put a debug statement in the LoadImageData class just before the imagettfbbox method and tell me what $label->getFont()->getPath() resolves to and what file_exists($label->getFont()->getPath()) resolves to.

LeQuangKhai99 commented 11 months ago

Hi @endroid, file_exists($label->getFont()->getPath()) return true.

LeQuangKhai99 commented 11 months ago

image

noto_sans.oft is exist

endroid commented 11 months ago

Thank you. And the output of the path please. And could you try using realpath() around the path, like $labelBox = imagettfbbox(realpath($label->getFont()->getSize()), 0, $label->getFont()->getPath(), $label->getText());

And if that does not work, what does file_get_contents give? Can it read the file?

LeQuangKhai99 commented 11 months ago

@endroid I'm sorry, i was installed this package to another project and it work well. I think i will uninstall and try again. Thanks!

endroid commented 11 months ago

Np, glad to hear your problem is solved!