Skip to content

Instantly share code, notes, and snippets.

@ameenross
Last active March 4, 2019 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ameenross/e8192222a5414b7de4e99c4bb500a253 to your computer and use it in GitHub Desktop.
Save ameenross/e8192222a5414b7de4e99c4bb500a253 to your computer and use it in GitHub Desktop.
Just output a table with fonts and their appearance in PHP Imagick. Inspired by Stefano: http://php.net/manual/en/imagick.queryfonts.php#121010
<?php
foreach (Imagick::queryFonts() as $fontName) {
$image = new Imagick;
$draw = new ImagickDraw;
$draw->setGravity(Imagick::GRAVITY_CENTER);
$draw->setFont($fontName);
$draw->setFontSize(12);
$draw->setFillColor('black');
$image->newImage(300, 20, 'lightblue');
$image->annotateImage($draw, 0, 0, 0, $fontName);
$image->setImageFormat('png');
$base64 = base64_encode($image);
echo "<img src='data:image/png;base64,{$base64}'> {$fontName} <br>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment