imagefontwidth 


gd apg

RETURNS the pixel width of a character in font.





Letter fonts used in this tutorial:

   * GDF fonts  !    Vera ttf fonts  !


* To be used in this exercise.

* Don't forget to save the fonts in folders visible to the proposed exercises.
   Like example, this tutorial uses gdf and ttf, respectively.


* If you have other fonts, you can use them as long as they are usable.

* Solve, therefore, the exercises proposed.





$font can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding.

The higher numbers corresponding to larger fonts or any of your own font identifiers registered with imageloadfont.



<?php

int imagefontwidth 
GdFont|int $font )


where,

$font The font number

?>
 

  $font   


The font number.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$arrfw = [ "font 1" => 1"font 2" => 2
                
"font 3" => 3"font 4" => 4"font 5" => ];

foreach(
$arrfw as $f => $fw)
{
echo 
$f ' => ' imagefontwidth($fw) . '<br>';
}

?> 

  2 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

// $lang = 'pt';
$lang 'en';

$var getcwd();

$gdf_font_name $var "/gdf/";

$arqs glob($gdf_font_name .'*{.gdf,.GDF}'GLOB_BRACE);

foreach(
$arqs as $v)
{
// echo basename($v) . '<br>';

   
$gdf_fnt imageloadfont($v);

   
$gdf_fnt_width imagefontwidth ($gdf_fnt);
   
   
$pt $v "<br>Largura da Fonte: " $gdf_fnt_width "px<br><br>";
   
$en $v "<br>Font Width: " $gdf_fnt_width "px<br><br>";


echo $
$lang;
}

?>