PHP 8.3.4 Released!

Imagick::queryFonts

(PECL imagick 2, PECL imagick 3)

Imagick::queryFontsYapılandırımış yazı tiplerini döndürür

Açıklama

public static Imagick::queryFonts(string $şablon = "*"): array

Imagick yapılandırılmış yazı tiplerini döndürür.

Bağımsız Değişkenler

şablon

Sorgu şablonu.

Dönen Değerler

Yapılandırılmış yazı tiplerini içeren bir dizi döndürür.

Hatalar/İstisnalar

Hata durumunda bir ImagickException istisnası oluşur.

Örnekler

Örnek 1 - Imagick::queryFonts() örneği

<?php
$output
= '';
$output .= "'Helvetica*' ile eşleşen yazı tipleri:<br/>";

$fontList = \Imagick::queryFonts("Helvetica*");

foreach (
$fontList as $fontName) {
$output .= '<li>'. $fontName."</li>";
}

return
$output;

?>

add a note

User Contributed Notes 1 note

up
5
Stefano
6 years ago
If you want to create a graphical output of the configured/embedded fonts

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 );
}
To Top