Page 1 of 1
How can I get sharp text?
Posted: 2007-06-17T21:58:50-07:00
by maozhua.net
convert -background transparent -fill blue -pointsize 12 label:Hello,ImageMagick test.png
Text generated by this command is blurry, How can I get sharp text? Thanks.
Re: How can I get sharp text?
Posted: 2007-06-18T02:09:39-07:00
by maozhua.net
I found it, use +antialias to turn off antialias, but the image generated still looks ugly, what's the problem?
Re: How can I get sharp text?
Posted: 2007-06-18T02:24:14-07:00
by maozhua.net
It just can not produce normal look text?
Re: How can I get sharp text?
Posted: 2007-06-18T18:28:31-07:00
by anthony
Prehaps if you link in a copy of the example 'unsharp' text that you put somewhere on the web (try one of the photo sites if you don't have anywhere) then we can see what you mean by it being 'fuzzy'.
Note text is generally aliased. meaning the edge pixels are combined with the background to attempt to produce a smoother looking image. Without this you get a very pixelated 'staircase' type of edge to the text.
See IM examples, text
http://www.imagemagick.org/Usage/text/
for lots of examples of normal IM text output.
Re: How can I get sharp text?
Posted: 2007-06-18T19:01:55-07:00
by maozhua.net
The first image was generated by command:
convert -background white -fill blue -font arial +antialias -pointsize 12 label:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmlopqrstuvwxyz test.png
and the second one is what they actually look like,
you can notice the difference: B Q W X m r
Re: How can I get sharp text?
Posted: 2007-06-18T19:25:09-07:00
by maozhua.net
and my platform is windows2000, ImageMagick-6.2.9-Q8, thanks
Re: How can I get sharp text?
Posted: 2007-06-18T19:44:30-07:00
by anthony
Can you give a thrid example of the default aliases text you claim is too 'fuzzy'.
It will neet to be more than a two color image!
We may be able to convert that to a bitmap in a more consistant way.
However you are right the anti-aliased form could probably be a lot better.
You best solution is probably to use a 'bitmap font' designed for the specific pointsize and density, rather than the more typical truetype, or vector font.
However I have not seen much use of bitmap fonts in IM for some time.
Can someone in the know enlighten us?
Re: How can I get sharp text?
Posted: 2007-06-18T21:03:12-07:00
by maozhua.net
convert -size 380x29 xc:transparent -draw "fill tomato rectangle 0,0 190,28 fill limegreen rectangle 191,0 379,28 fill blue text 5,15 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmlopqrstuvwxyz'" test.png
It's not quite suitable for my application, I prefer the not-anti-aliased text as we usually see,
maybe 'bitmap font' is the best solution.
Re: How can I get sharp text?
Posted: 2007-06-18T22:19:51-07:00
by anthony
I tried a few thresholding techniques on that image, and did not get a good bitmap font result. The 'X' is especially bad in this regard.
Looks like we need a bitmap font at the right scale.
For example this is a 'snapshot' of the X windows bitmap font I am using on my Xterminal...
However it is a X windows font. (in this case 8x15 )
Hmm online my IM was able to get that font directly using...
Code: Select all
convert -font '-misc-fixed-medium-r-normal--15-145-75-75-c-80-iso10646-1' \
label:'Some Text String abcXYZ' bitmap_font.png
But that only works when my X windows server is running, so it is no good for windows or batch processing.
WARNING: IM Bug found! While the above returned the bitmaps font, IM did not set the 'baseline' of the font right, so all the letters sat on the bottom-most line of the image. Any decender was clipped. there was however pleanty of space for the font to be positioned correctly within a label.
We need to access bitmaps fonts like this batch wise.
Are you using windows, unix or a mac environment?
Re: How can I get sharp text?
Posted: 2007-06-18T22:42:30-07:00
by maozhua.net
Windows for development, and linux for production.
Actually, I come from China, and as I know, there are NO bitmap fonts for Chinese, so I think it will be a problem if IM can not produce identical not-anti-aliased text as we usually see for typical true type fonts or vector fonts.
Re: How can I get sharp text?
Posted: 2007-06-18T23:01:54-07:00
by anthony
That would be a problem, though I believe there are bitmaps chinese fonts too.
There are japanese and koren fonts..
development may have discontinued however, but I am sure they exist somewhere.
try searching the old X windows sources.
Re: How can I get sharp text?
Posted: 2007-06-18T23:04:59-07:00
by maozhua.net
Sorry, it's my mistake, Chinese do have some bitmap fonts.
Thanks a lot
Re: How can I get sharp text?
Posted: 2007-06-20T20:27:22-07:00
by maozhua.net
more questions
Actually, the simsun.ttf font(delivered with windows) contains 3 bitmap fonts - 12px, 14px and 16px, so how can I specify IM to use these fonts instead of the vector font within it?
Re: How can I get sharp text?
Posted: 2007-06-20T20:29:30-07:00
by anthony
That is the question I would like cristy to answer.
however if you knwo the files you can try specifying the specific font file you want IM to use with -font
let us know how it goes.
Re: How can I get sharp text?
Posted: 2007-06-20T20:45:46-07:00
by maozhua.net
Yes, I am calling IM using '-font /path/to/simsum.ttf', but I have no idea how to specify IM to use a particular bitmap font within this file
And I have tried to extract the bitmap fonts from the file using fontforge, but failed