endroid / qr-code

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

Font path problem #211

Closed acosonic closed 5 years ago

acosonic commented 5 years ago

I've tried basic demo from your homepage

just composer install

added autoload at the top of

<?php
require __DIR__ . '/vendor/autoload.php';
use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\LabelAlignment;
use Endroid\QrCode\QrCode;
use Endroid\Q

rest is like on homepage

And got this error

Fatal error: Uncaught Endroid\QrCode\Exception\InvalidPathException: Invalid label font path: in /home/aleksandar/websites/qr/vendor/endroid/qr-code/src/QrCode.php:392 Stack trace: #0 /home/aleksandar/websites/qr/vendor/endroid/qr-code/src/QrCode.php(338): Endroid\QrCode\QrCode->setLabelFontPath(false) #1 /home/aleksandar/websites/qr/p.php(19): Endroid\QrCode\QrCode->setLabel('Scan the code', 16, '/home/aleksanda...', 'center') #2 {main} thrown in /home/aleksandar/websites/qr/vendor/endroid/qr-code/src/QrCode.php on line 392

nimasdj commented 5 years ago

This means font and image file not found. You need to edit the paths below that it can find the file.

$qrCode->setLabel('Scan the code', 16, __DIR__.'/../assets/fonts/noto_sans.otf', LabelAlignment::CENTER);
$qrCode->setLogoPath(__DIR__.'/../assets/images/symfony.png');

Those two files are inside qr-code packages installed by composer.

acosonic commented 5 years ago

Where do I find those fonts fike? Are they in github repo?

nimasdj commented 5 years ago

Yes. In asset folder. You have them already on your server as you installed this repo via composer. Look inside assets folder of this pack and add relative path to those files that your script can find them.