Text looks horrible

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
brianp22
Posts: 9
Joined: 2011-12-14T11:39:37-07:00
Authentication code: 8675308

Text looks horrible

Post by brianp22 »

I am using standard Ubuntu fonts:
Ghostscript helvetica
/usr/share/fonts/type1/gsfonts/n019003l.pfb
TrueType courier
/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf
/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf

All come out way too thick. If I use the exact same font in GD, it looks fine. When after I create the image:

Code: Select all

        _image->font("/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf");
        _image->fontPointsize(10);
and then when I want to draw the string (I do draw other stuff before the string)

Code: Select all

         _image->transformRotation(geo::radiansToDegrees(angle));
        // Rotate the points to match the rotation angle
        f.rotate(angle);
        t.rotate(angle);
        // Draw the text
        _image->draw(Magick::DrawableText(f.x(), t.y(), str));
        // Undo the rotation
        _image->transformReset();
The text is totally blurry and un-readable. I know it isn't the rotation code, as I can take that out and it is still unreadable.

If I crank my font size up to 30, I see an outline of the text in the color I wanted (black) and an inner-line in a different color (gray). Totally not what I expected. All I want is that inner-line of the font and at a 10 point size.

Any thoughts? This has me stumped.

- brian

(I would include screen shots if I knew out to upload them here :(
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Text looks horrible

Post by magick »

Type 'identify -list format'. Check the TTF format. It should show that Freetype is associated with this format:
  • TTF* TTF r-- TrueType font (Freetype 2.4.6)
Do you have Freetype associated with your instance of ImageMagick?
brianp22
Posts: 9
Joined: 2011-12-14T11:39:37-07:00
Authentication code: 8675308

Re: Text looks horrible

Post by brianp22 »

I do have TTF support.

Code: Select all

identify -list format | grep -i TTF
    DFONT* TTF       r--   Multi-face font package (Freetype 2.3.11)
      OTF* TTF       r--   Open Type font (Freetype 2.3.11)
      PFA* TTF       r--   Postscript Type 1 font (ASCII) (Freetype 2.3.11)
      PFB* TTF       r--   Postscript Type 1 font (binary) (Freetype 2.3.11)
      TTC* TTF       r--   TrueType font collection (Freetype 2.3.11)
      TTF* TTF       r--   TrueType font (Freetype 2.3.11)
I have the same problem with Postscript fonts

Code: Select all

identify -list format | grep -i pfb
      PFB* TTF       r--   Postscript Type 1 font (binary) (Freetype 2.3.11)
- brian
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Text looks horrible

Post by magick »

What version of ImageMagick are you using? The latest is ImageMagick 6.7.4-1. We only have one patch against Freetype in this version but it might resolve the problem.

Try from the command line:
  • convert -font /usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf pointsize 30 label:Magick x:
Does this return reasonable results (it does for us).
brianp22
Posts: 9
Joined: 2011-12-14T11:39:37-07:00
Authentication code: 8675308

Re: Text looks horrible

Post by brianp22 »

magick wrote:
  • convert -font /usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf pointsize 30 label:Magick x:
Does this return reasonable results (it does for us).
Is something missing from this command? It just hangs for me.

I am using Ubuntu 10.04.3 LTS.:
libmagick++-dev 7:6.5.7.8-1ubuntu1.1
imagemagick 7:6.5.7.8-1ubuntu1.1

here is a little test program:

Code: Select all

#include <Magick++.h>
int main(int, char**)
{
    Magick::Image image("100x120", "linen");
    image.font("/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf");
    image.strokeColor("black");
    image.fillColor(Magick::Color(0, 0, 0, MaxRGB));
    image.fontPointsize(10);
    image.lineWidth(2);

    image.draw(Magick::DrawableText(10, 20, "W 10TH ST"));
    image.draw(Magick::DrawableText(10, 40, "HIGHLAND PL"));
    image.draw(Magick::DrawableText(10, 60, "AIR HILL ST"));

    image.fontPointsize(40);
    image.draw(Magick::DrawableText(10, 100, "40"));

    image.write("/tmp/test.png");
}
which produces this image:
Image

http://itic.occinc.com/brian/test.png
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Text looks horrible

Post by magick »

Instead of x: use label.pnm. Then use label.png. Do these renderings look ok? We agree something is wrong and we're trying to narrow down where in the code its misbehavin'.

We're offline for a few hours. We will get back to you later.
brianp22
Posts: 9
Joined: 2011-12-14T11:39:37-07:00
Authentication code: 8675308

Re: Text looks horrible

Post by brianp22 »

magick wrote:Instead of x: use label.pnm. Then use label.png. Do these renderings look ok? We agree something is wrong and we're trying to narrow down where in the code its misbehavin'.

We're offline for a few hours. We will get back to you later.
Looks like the convert program is working OK, which implies there is a problem with Magick++.

PNG: Image
PNM: http://itic.occinc.com/brian/label.pnm (you can't view postscript in a browser)

- brian
brianp22
Posts: 9
Joined: 2011-12-14T11:39:37-07:00
Authentication code: 8675308

Re: Text looks horrible

Post by brianp22 »

Interesting. If I make the outline transparent and the fill the color I want, it seems to be working:

Image

Code: Select all

#include <Magick++.h>

int main(int, char**)
{
    Magick::Image image("100x120", "linen");
    image.font("/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf");
//    image.strokeColor("black");
//    image.fillColor(Magick::Color(0, 0, 0, MaxRGB));
    image.strokeColor(Magick::Color(0, 0, 0, MaxRGB));
    image.fillColor("black");
    image.fontPointsize(10);
    image.lineWidth(2);

    image.draw(Magick::DrawableText(10, 20, "W 10TH ST"));
    image.draw(Magick::DrawableText(10, 40, "HIGHLAND PL"));
    image.draw(Magick::DrawableText(10, 60, "AIR HILL ST"));

    image.fontPointsize(40);
    image.draw(Magick::DrawableText(10, 100, "40"));

    image.write("/tmp/test.png");
}
goofy, but I guess it makes sense in my mind. Although this is different than how the convert program seems to be working.....

- brian
Post Reply