Text images with unicode chars looking blurry.

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
phleagol
Posts: 9
Joined: 2017-12-16T02:20:37-07:00
Authentication code: 1152

Text images with unicode chars looking blurry.

Post by phleagol » 2018-03-04T03:56:11-07:00

I want imagemagick to create an image of unicode chars that is sharp and accurate. And my attempts with ttf fonts worked okay, but didn't look exactly right. So I tried again with the fixed bitmap font, which I read has good unicode support, but the unicode chars failed to render at all. Disappointing.

So in short, I ask if there is a better way please. The images below are enlarged so you can better see aliasing, blurring etc.

1] Firstly, I have echoed some unicode chars in urxvt terminal with dejavu 18pt ttf font. Nice and sharp, as desired.

Code: Select all

echo -ne "aaa \u259A bbb \u256c ccc \u2591 ddd"
Image

2] Next, I created an image of a unicode message using dejavu 14pt ttf font. Some blurring though.

Code: Select all

msg=$(echo -ne "aaa \u259A bbb \u256c ccc \u2591 ddd")
convert -font DejaVu-Sans-Mono-Bold -pointsize 14 label:"$msg" out.png
Image

3] Now, I created the same unicode text, but with anti-aliasing disabled. Sharp, but still looking odd.

Code: Select all

msg=$(echo -ne "aaa \u259A bbb \u256c ccc \u2591 ddd")
convert -font DejaVu-Sans-Mono-Bold -pointsize 14 +antialias label:"$msg" out.png
Image

4] Lastly, I create text image with IM using the fixed bitmap font. But the unicode chars failed to render at all.

Code: Select all

msg=$(echo -ne "aaa \u259A bbb \u256c ccc \u2591 ddd")
bitmapfont='-misc-fixed-bold-r-normal--15-140-75-75-c-90-iso8859-1'
convert -font $bitmapfont label:"$msg" out.png
Image

In short, none of the methods I've used above have given me nice sharp unicode cahrs in an image. So I ask, is there a better way.

Code: Select all

$ identify -version                                                       
Version: ImageMagick 6.9.9-34 Q16 x86_64 20180122 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP 
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Text images with unicode chars looking blurry.

Post by Bonzo » 2018-03-04T04:21:40-07:00

I am not great with fonts but there are standard font sizes. For instance in my arial font there is a 12pt and 18pt so any size in between those two has to be scaled. What happens if you use pointsize 12 or 18?

phleagol
Posts: 9
Joined: 2017-12-16T02:20:37-07:00
Authentication code: 1152

Re: Text images with unicode chars looking blurry.

Post by phleagol » 2018-03-04T06:17:45-07:00

Not sure what the standard font sizes are for ttf DejaVu-Sans-Mono-Bold. But having just tested for all sizes between 6pt and 22pt, I havent really found a sweet spot where unicode chars look accurate. So still having mixed results with ttf dejavu.

And I'm still not sure why IM didn't render unicode chars with the bitmap fixed font. Did I not do it right?

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Text images with unicode chars looking blurry.

Post by Bonzo » 2018-03-04T08:01:08-07:00

If you click on a .ttf file it should open as an image showing the standard sizes.
Your code looks OK; perhaps the design of that font does not scale very well.

phleagol
Posts: 9
Joined: 2017-12-16T02:20:37-07:00
Authentication code: 1152

Re: Text images with unicode chars looking blurry.

Post by phleagol » 2018-03-04T14:03:58-07:00

Bonzo wrote:
2018-03-04T08:01:08-07:00
If you click on a .ttf file it should open as an image showing the standard sizes.
Having trouble "opening" the ttf file. Which application is your file manager using to open ttf files plz? Thanx.

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Text images with unicode chars looking blurry.

Post by Bonzo » 2018-03-04T14:12:25-07:00

I am using Windows 10 and double clicking the file opens it in "Windows font viewer".

phleagol
Posts: 9
Joined: 2017-12-16T02:20:37-07:00
Authentication code: 1152

Re: Text images with unicode chars looking blurry.

Post by phleagol » 2018-03-04T14:18:09-07:00

Bonzo wrote:
2018-03-04T14:12:25-07:00
I am using Windows 10 and double clicking the file opens it in "Windows font viewer".
I am using Debian 9, and my file manager is ranger. Slightly awkward, but I will find a way...

snibgo
Posts: 10926
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Text images with unicode chars looking blurry.

Post by snibgo » 2018-03-04T15:45:35-07:00

phleagol wrote:The images below are enlarged so you can better see aliasing, blurring etc.
Fonts are designed to look good at whatever size they are rendered at. They are not designed to look good when rendered at a small size and then enlarged. An enlargement of any raster image will be either pixellated or blurry.

If you want it to look good at a large size, then use eg "-pointsize 300".

Or am I missing something? What are you trying to achieve?
snibgo's IM pages: im.snibgo.com

Post Reply