Help with font images

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
sequoia

Help with font images

Post by sequoia »

I'm trying to create images of individual font characters. The images must have a fixed height, and a variable width to match the character. Using label: appears to be the right way to do this, but some font characters get clipped on the right side while other fonts do not.

Code: Select all

convert -background lightblue -fill blue -font Times-New-Roman -size x100 label:A A1.jpg

convert -background lightblue -fill blue -font Comic-Sans-ML -size x100 label:A A2.jpg
ImageImage

I am new to ImageMagick and appreciate any help or advice.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The problem you posted is a bug. It is fixed in ImageMagick 6.3.1-7 Beta. It will be released within a week or two.
sequoia

Post by sequoia »

Wonderful! I will keep a watch for that new version.

Thanks.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

the new label update is demonstrated in IM examples...
Label Image Bounds
http://www.cit.gu.edu.au/~anthony/graph ... xt/#bounds

Aside. Thanks to cristy for the fast bug fix for bounding boxes that was introduced with this, and to also expand BOTH right and LEFT bounds of the lable if nessary.

The 'H' letter of LokiCola font is particaulrly bad as you can see in the later section...
Bounding Box Overflows..
http://www.cit.gu.edu.au/~anthony/graph ... /#overflow
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sequoia

Post by sequoia »

Quite impressive! I tried it on some of my "tough" fonts and it worked great. Thanks for the speedy and informative reply.
sequoia

Post by sequoia »

Using ImageMagick 6.3.1 01/11/07 Q16, some characters show a little extra like the one below using Helsinki

Code: Select all

convert.exe -background lightblue -fill blue size x100 -border 20x0 -font Helsinki -label:J J.jpg
Image
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Haven't seen this effect before.

It may be that you are seeing strange effects due to not difining your image BEFORE making further operations. Try...

Code: Select all

convert.exe -background lightblue -fill blue -font Helsinki -size x100 label:J  -border 20x0  J.jpg
All the options before label: are settings for the label. The -border is a seperate operator that needs an image to work with, so should be after the label:

Also try -border 20x5 how did that differ?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

I downloaded the font and tring it our on the latest 3.2.0-0 beta and had no problems.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sequoia

Post by sequoia »

Agreed, the problem is not there with the latest 6.3.2 beta. Thanks!

Another question please, is there a way to generate an image for a single space character (0x20 or 0xA0)? I can't figure out how to get just a space other than simply creating a blank image. The problem with that is the width is then up to me and not based on the font definition. Thanks for any help.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

I see what you mean you get a very thin space!

that seems to be due to the way label is now adjusting its size. Didn't use to be like that.

The problem is that is the bounding box size for space! Most word processes use a base space size that is specified by the font itself, and then adjusts that size according to justification settings. IM doesn't have that luxury.

Basically a space is infinately thin unless the situation specifies otherwise.

however I beleve the typical space size is the bounding box size for 'n'.
whcih is also use for a interword 'dash'.

As such try..

Code: Select all

  convert.exe -background lightblue -fill lightblue -font Helsinki -size x100 label:-  -border 20x0  space.jpg
note I set the fill color to the background color!!!

You can also try -annotating the space but then you need to specify the point size rather than bounding box height! Note pointsize is the line separate distance of a font. You can still have a small or large font at the same pointsize, however pointsize is the more normal way of specifything a font.

Code: Select all

convert -size 120x120 xc:white -gravity center -box lightblue -fill blue -font helsinki.ttf -pointsize 80 -annotate 0 ' ' x:
Note -bix specifies a a color for the texts bounding box, which is what word processes use to fit characetrs together. The drawn characters themselves do not nessarilly fit inside that bounding box... though often does, and seems to be the case for the Helsinki font.

That font by the way is incomplete -- no tilde ('~'), or '@', only uppercase, etc... Any specific reason you are using it? What are you planing to do with it?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sequoia

Post by sequoia »

Thanks for that info. I'll try your suggestions shortly. This particular font is jsut one of several that I'm looking at using. It was referenced because it showed the "extra stuff" with 6.3.1 01/11/07.

The application is to print rotated characters in HTML. The characters to be printed are not known until the page is generated, and there is no scripting available to create an image for character strings, so each character must be an individual image. I'm automating the creation of the individual character files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Yuck. that is really a bad situation.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply