如果您想创建配置/嵌入字体的图形输出
function outputFont( $fontName = 'Courier' ) {
$image = new Imagick();
$draw = new ImagickDraw();
$draw->setGravity( Imagick::GRAVITY_CENTER );
$draw->setFont( $fontName );
$draw->setFontSize( 12 );
$draw->setFillColor( 'black' );
$image->newImage( 300, 20, new ImagickPixel( 'lightblue' ) );
$image->annotateImage( $draw, 0, 0, 0, $fontName );
$image->setImageFormat( 'png' );
$src = 'data: ' . mime_content_type( $image ) . ';base64,' . base64_encode( $image );
return '<img src="' . $src . '"> ' . $fontName . '<br>';
}
echo '<style>img{vertical-align: middle; margin-bottom: 1px;}</style>';
$fontList = \Imagick::queryFonts( '*' );
foreach ( $fontList as $fontName ) {
echo outputFont( $fontName );
}