Page 1 of 1

Setting fontWeight/fontStyle/lineSpacing doesn't work

Posted: 2017-04-28T19:59:45-07:00
by Airon65
Here is my code:

Code: Select all

	Magick::Image image( Magick::Geometry( 700, 700 ), Magick::Color( "white" ) );
	
	image.font( "verdana" );
	image.fontPointsize( 70 );
	
	image.fontWeight( 900 );
	image.fontStyle( Magick::ItalicStyle );
	image.textInterlineSpacing( 0.1f );
	
	image.textGravity( MagickCore::CenterGravity );
	image.draw( Magick::DrawableText( 0, 0, "Hello\nworld!" ) );
	
	image.write( "images/testImage.png" );
And that's my output:
Image
As you can see there are no any weight, style affect. And there's no also any interlineSpacing effect. Why does it work like this?

Version: ImageMagick 7.0.5-4 Q16 x86_64 2017-03-25 http://www.imagemagick.org
macOS 10.12.3

Re: Setting fontWeight/fontStyle/lineSpacing doesn't work

Posted: 2017-04-28T20:46:23-07:00
by snibgo
For drawing text, as opposed to other methods, I suppose you should use methods on http://www.imagemagick.org/Magick++/Drawable.html such as DrawableFont.

Re: Setting fontWeight/fontStyle/lineSpacing doesn't work

Posted: 2017-04-28T21:10:14-07:00
by Airon65
snibgo wrote: 2017-04-28T20:46:23-07:00 For drawing text, as opposed to other methods, I suppose you should use methods on http://www.imagemagick.org/Magick++/Drawable.html such as DrawableFont.
Well maybe. But for what purposes developers created those methods such as fontStyle(), fontWeight(), textInterlineSpacing()? :)

Re: Setting fontWeight/fontStyle/lineSpacing doesn't work

Posted: 2017-04-28T21:22:45-07:00
by Airon65

Code: Select all

Magick::Image image( Magick::Geometry( 300, 300 ), Magick::Color( "white" ) );
	
std::vector < Magick::Drawable > textArr;
	
textArr.push_back( Magick::DrawablePointSize( 70 ) );
textArr.push_back( Magick::DrawableTextInterlineSpacing( 0.1f ) );
textArr.push_back( Magick::DrawableGravity( MagickCore::CenterGravity ) );
textArr.push_back( Magick::DrawableFont( "verdana", Magick::ItalicStyle, 900, Magick::NormalStretch ) );
textArr.push_back( Magick::DrawableText( 0, 0, "Hello\nworld!" ) );
	
image.draw( textArr );
	
image.write( "images/testImage.png" );
The same output as listed above...

Re: Setting fontWeight/fontStyle/lineSpacing doesn't work

Posted: 2017-04-28T21:33:47-07:00
by Airon65

Code: Select all

$ convert -size 230x130 xc:lightblue -font verdana -pointsize 25 -style italic -draw "gravity NorthWest fill black text 0,0 'The quick red fox jumped over the lazy brown dog'" font1.png
Image

Re: Setting fontWeight/fontStyle/lineSpacing doesn't work

Posted: 2017-04-28T21:38:33-07:00
by Airon65
Well I can use another ttf file for setting italic style of setting new font weight but what to do with the TextInterlineSpacing? It doesn't work in both cases...

Re: Setting fontWeight/fontStyle/lineSpacing doesn't work

Posted: 2017-04-28T22:06:13-07:00
by fmw42
There is no -style. But in command line, you can use -interline-spacing. See http://www.imagemagick.org/Usage/text/# ... ne-spacing. That should autowrap with caption, but with label:, -annotate, and -draw, you likely need to put in newline character (\n) where you want it to wrap.;

Re: Setting fontWeight/fontStyle/lineSpacing doesn't work

Posted: 2017-04-29T08:55:25-07:00
by snibgo
Interline spacing of zero means "no change". A value of 0.1 will increase it by 0.1 pixels, which I can't see. Try:

Code: Select all

image.textInterlineSpacing( 50.0f );

Re: Setting fontWeight/fontStyle/lineSpacing doesn't work

Posted: 2017-07-25T14:17:20-07:00
by jeroenooms
I ran into this as well. In my case it was because imagemagick on osx homebrew is built without fontconfig. Therefore it is unable to find the italic/boldface fonts.

The problem was fixed after: brew reinstall imagemagick --with-fontconfig