can i draw a bold text with regular font?

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
jueljust

can i draw a bold text with regular font?

Post 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?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post 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");
?> 
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

you can generally get a bold version of the specific font and specify that
jueljust

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

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
cccnikul
Posts: 2
Joined: 2012-07-13T00:50:13-07:00
Authentication code: 13

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

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post by Bonzo »

There is an example and comments on this page: http://valokuva.org/?p=10 search it for setFontStyle
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

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

Post 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.
Wolfgang Hugemann
Post Reply