Page 1 of 1

Text images with unicode chars looking blurry.

Posted: 2018-03-04T03:56:11-07:00
by phleagol
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

Re: Text images with unicode chars looking blurry.

Posted: 2018-03-04T04:21:40-07:00
by Bonzo
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?

Re: Text images with unicode chars looking blurry.

Posted: 2018-03-04T06:17:45-07:00
by phleagol
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?

Re: Text images with unicode chars looking blurry.

Posted: 2018-03-04T08:01:08-07:00
by Bonzo
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.

Re: Text images with unicode chars looking blurry.

Posted: 2018-03-04T14:03:58-07:00
by phleagol
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.

Re: Text images with unicode chars looking blurry.

Posted: 2018-03-04T14:12:25-07:00
by Bonzo
I am using Windows 10 and double clicking the file opens it in "Windows font viewer".

Re: Text images with unicode chars looking blurry.

Posted: 2018-03-04T14:18:09-07:00
by phleagol
Bonzo wrote: 2018-03-04T14:12:25-07:00I 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...

Re: Text images with unicode chars looking blurry.

Posted: 2018-03-04T15:45:35-07:00
by snibgo
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?