{site_name}

{site_name}

🌜 搜索

Gmagick::queryfontmetrics() is a functio

php 𝄐 0
php gmp,php gmp扩展,php gmp 向左移动,php gmp的最大位数,php gmbh,php gmail客户端
Gmagick::queryfontmetrics() is a function in the Gmagick extension of PHP which is used to retrieve font metrics for a specified text string.

This function calculates various metrics of a text string, such as its bounding box, width, height, and baseline position, based on the specified font and font size. These metrics can be useful for positioning or layout purposes when working with text or images.

Here is an example of how you can use Gmagick::queryfontmetrics() in PHP:

php
// Load an image
$gmagick = new Gmagick();
$gmagick->readImage('path/to/image.jpg');

// Set font properties
$font = 'Arial';
$fontSize = 16;

// Set text string
$text = 'Hello, World!';

// Query font metrics
$metrics = $gmagick->queryFontMetrics($draw, $text);

// Print font metrics
echo 'Text width: ' . $metrics['textWidth'] . '<br>';
echo 'Text height: ' . $metrics['textHeight'] . '<br>';
echo 'Bounding box: [' . $metrics['boundingBox']['x1'] . ', ' . $metrics['boundingBox']['y1'] . ', ' . $metrics['boundingBox']['x2'] . ', ' . $metrics['boundingBox']['y2'] . ']<br>';
echo 'Baseline: ' . $metrics['baseline'] . '<br>';


In this example, we first create a new Gmagick object and load an image. Then, we set the font and font size, and define the text to be measured. Finally, we call Gmagick::queryfontmetrics() method with the Gmagick object and the text string as parameters, and retrieve the metrics in an array.

The example then prints out different font metrics, such as the text width, text height, bounding box coordinates, and the baseline position.

Please note that in order to use Gmagick and the queryFontMetrics() function, you need to have both the Gmagick extension and the GraphicsMagick library installed and enabled on your server.