setfont,but setfontweight no work

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jackliangs

setfont,but setfontweight no work

Post by jackliangs »

Code: Select all

<?php
$Imagick = new Imagick();
$bg = new ImagickPixel();
$bg->setColor( 'white' );
$ImagickDraw = new ImagickDraw();
$ImagickDraw->setfont("/var/www/simkai.ttf");
$ImagickDraw->setFontSize( 20 );
$ImagickDraw->setfontweight(100);
$string = 'Az';
$Imagick->newImage( 600, 300, $bg ); 
$Imagick->annotateImage( $ImagickDraw, 4, 20, 0, $string );
$Imagick->drawImage( $ImagickDraw );
$Imagick->setImageFormat( 'png' );
header( "Content-Type: image/{$Imagick->getImageFormat()}" );
echo $Imagick->getImageBlob( );
?>
Set a font, while the effect of setting a bold, but bold is not in force, if not properly set the font bold. May I set the font does not contain a bold, but the algorithm should be bold freetype.

Code: Select all

<edit name="embolden" mode="assign"> 
             <bool>true</bool> 
         </edit> 
Please give me some help, thanks.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: setfont,but setfontweight no work

Post by anthony »

Font weights are not used with regard to TTF fonts. They are for other different font schemes.

For TTF fonts you generally use a different font from the same family for different attributes like bold, italic, etc.

However if you do not have access to a 'bold' font you can sometimes fake a bold version by say increasing the inter-character spacing and using a stroke to make the font slightly thicker. For Italic you can use angle warps such as provided by the annotate operator.

Many other things can also be done such as shown in 'Compound Font Examples' in IM Examples.
http://www.imagemagick.org/Usage/fonts/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply