Skip to content

Commit

Permalink
Don't bundle 16MB of fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
CatoTH committed Nov 30, 2024
1 parent e9419be commit 4d7aac6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions components/SecondFactorAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use app\controllers\UserController;
use app\models\layoutHooks\Layout;
use app\models\db\User;
use Endroid\QrCode\Label\Font\FontInterface;
use app\models\http\{RedirectResponse, ResponseInterface};
use app\models\settings\AntragsgruenApp;
use Endroid\QrCode\Builder\Builder;
Expand Down Expand Up @@ -275,6 +276,18 @@ public function attemptForcedRegisteringSecondFactor(string $secondFactor): User
return $user;
}

private static function getQrCodeLabelFont(): FontInterface
{
return new class() implements FontInterface {
public function getPath(): string {
return __DIR__ . '/../assets/PT-Sans/PTS55F.ttf';
}
public function getSize(): int {
return 16;
}
};
}

public static function createQrCode(TOTP $totp): ResultInterface
{
$logo = Layout::squareLogoPath();
Expand All @@ -296,6 +309,8 @@ public static function createQrCode(TOTP $totp): ResultInterface
->logoResizeToWidth(50)
->logoResizeToHeight(50)
->logoPunchoutBackground(true)
->labelFont(self::getQrCodeLabelFont())
->labelText('')
->validateResult(false)
->build();
}
Expand Down
1 change: 1 addition & 0 deletions docs/create-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ rm ./vendor/s1syphos/php-simple-captcha/fonts/LinLibertine_Rah.ttf
rm ./vendor/s1syphos/php-simple-captcha/fonts/Hack-Regular.ttf
rm ./vendor/s1syphos/php-simple-captcha/fonts/Bitter-Bold.ttf
rm ./vendor/s1syphos/php-simple-captcha/fonts/Vollkorn-Regular.ttf
rm -R vendor/endroid/qr-code/assets/ # Replaced by bundled TTF
find vendor -type l -exec rm {} \;
rm -R vendor/cebe/markdown/tests
rm -R tests/
Expand Down

0 comments on commit 4d7aac6

Please sign in to comment.