Page 1 of 1

Font size not correct while annotating - magick++

Posted: 2013-05-28T04:43:51-07:00
by writetonsharma
I am using imagemagick 6.7.3 on windows XP compiled with Visual Studio 6.0.
I have the below code to annotate some text and I see that the font size is not set correctly. I doubt that a default font size is picked.

Code: Select all

Image image( Geometry(713,8), Color("#ffffff"));
image.fillColor("#000000");
image.density( Geometry(96, 96));
image.font("@.\Arial.ttf");
image.fontPointsize(5);
image.annotate("A long text here", WestGravity);
image.rotate(270);
image.write("test.png");
Other surprising thing I see is, if I change some sequence of the code, the font size changes to something else. Like if I set the font point size in the end.

Code: Select all

Image image( Geometry(713,8), Color("#ffffff"));
image.fillColor("#000000");
image.density( Geometry(96, 96));
image.font("@.\Arial.ttf");
image.annotate("A long text here", WestGravity);
image.rotate(270);
image.fontPointsize(5);
image.write("test.png");

I am not an expert but I think something is wrong. Depending on where I put set the font size, the font either become too large or too small.


Thanks,
Naveen.

Re: Font size not correct while annotating - magick++

Posted: 2013-05-28T05:31:52-07:00
by magick
Set the density to 72 then adjust your font pointsize.

Re: Font size not correct while annotating - magick++

Posted: 2013-05-28T07:16:47-07:00
by writetonsharma
Thanks for looking at it.

I tried that -

Code: Select all

image.density( Geometry(72, 72));
But its still not working.

see the image. The top font is the correct one. Rest two below are either smaller or bigger.

https://docs.google.com/file/d/0B_-EiOs ... sp=sharing

Thanks.

Re: Font size not correct while annotating - magick++

Posted: 2013-05-28T07:34:55-07:00
by magick
You also need to set your font pointsize before you call image.annotate().

Re: Font size not correct while annotating - magick++

Posted: 2013-05-28T07:57:14-07:00
by writetonsharma
yes, I did that only. So, its like the below code

Code: Select all

Image image( Geometry(713,8), Color("#ffffff"));
image.fillColor("#000000");
image.density( Geometry(72, 72));
image.font("@.\Arial.ttf");
image.fontPointsize(5);
image.annotate("A long text here", WestGravity);
image.rotate(270);
image.write("test.png");
Did I do correctly ?

Re: Font size not correct while annotating - magick++

Posted: 2013-05-28T09:09:35-07:00
by magick
Change "@.\Arial.ttf" to "@Arial.ttf". We're using ImageMagick 6.8.5-8, the latest release and it appears to render the font correctly.

Re: Font size not correct while annotating - magick++

Posted: 2013-05-28T10:07:21-07:00
by writetonsharma
I tried this but the output is still the same. The font is bigger than 5point.

I can try the latest release but I was avoiding it. We use various non-windows platforms and it will take some time to compile the library on all these platforms with our new release due soon.

Do you think I can do something else in 6.7.3 to make it work ?