Page 1 of 1

can i draw a bold text with regular font?

Posted: 2007-12-04T21:10:49-07:00
by jueljust
as far as i know, imagemagick use font to present differnet text style.
however, now more and more font just provider regular font, with no bold or italic font.
can i present these font's bold style with imagemagick?

Re: can i draw a bold text with regular font?

Posted: 2007-12-05T01:11:13-07:00
by Bonzo
I think you can only do it in draw.

Code: Select all

<?php 
exec("convert -size 230x130 xc:lightblue -font verdana.ttf -pointsize 25 -style italic -draw \"gravity NorthWest fill black text 0,0 'The quick red fox
jumped over the
lazy brown dog'\" font1.png");
?> 

Re: can i draw a bold text with regular font?

Posted: 2007-12-07T13:55:07-07:00
by fmw42
you can generally get a bold version of the specific font and specify that

Re: can i draw a bold text with regular font?

Posted: 2007-12-10T22:21:11-07:00
by jueljust
Bonzo's solution depends on font register file, if i don't reg italic or bold font in it, then it doesn't works, or works but still invoke the regular font.

fmw42's solution, i've tried. and i found i can just generate a bold version of the specific font in a specific size(as it was convert to bmp format), but i don't know which size of the font will i use, so i can use this solution.

and i found i can use skewX to simulate italic font, but i haven't found i way to simulate bold font, that's my mainly problem now

http://www.imagemagick.org/Usage/fonts/#slanted

regards

Re: can i draw a bold text with regular font?

Posted: 2007-12-11T18:19:24-07:00
by anthony
A simple way to bold is to just set -strokecolor to the same color as -fill and set a -strokewidth to 1(default) or 2.
See..
http://imagemagick.org/Usage/fonts/#stroke
but with both colors the same.

The Best method is of course to use a bold version of that font, if that font is part of a specific font family. Bold fonts are often slightly longer with extra spacing between characters.

Re: can i draw a bold text with regular font?

Posted: 2012-09-26T00:07:59-07:00
by cccnikul
hi,

how to make font bold or italic?
i tried,
<?php
$draw = new ImagickDraw();
$draw->setFontStyle(2);
and
$draw->setFontStyle(Imagick:: STYLE_ITALIC);
?>
but not working...
please help me on this
thanks a lot

nikul

Re: can i draw a bold text with regular font?

Posted: 2012-09-26T04:46:14-07:00
by Bonzo
There is an example and comments on this page: http://valokuva.org/?p=10 search it for setFontStyle

Re: can i draw a bold text with regular font?

Posted: 2012-09-27T00:49:49-07:00
by whugemann
Bonzo wrote:I think you can only do it in draw.

Code: Select all

<?php 
exec("convert -size 230x130 xc:lightblue -font verdana.ttf -pointsize 25 -style italic -draw \"gravity NorthWest fill black text 0,0 'The quick red fox
jumped over the
lazy brown dog'\" font1.png");
?> 
I just tried this under Windows. You have to provide the full path name to the font file, i.e. "C:\Windows\fonts\verdana.ttf". But the neither "-style italic" nor "-weight bold" have any effect on the font type; you have to choose the right font file, i.e. something like "timesbd.ttf".

AFAIK Windows has default mechanisms to turn any font into italic or bold, but IM does not seem to activate these mechanisms.