2 questions about -kerning

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
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

2 questions about -kerning

Post by rmagick »

Regarding the new -kerning option. What units are the value? Pixels? Points? English Metric Units?

Also, is there a corresponding -draw primitive?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: 2 questions about -kerning

Post by magick »

Regarding the new -kerning option. What units are the value? Pixels? Points? English Metric Units?
See the manual page for FT_Get_Kerning(). Units are 64.0 * FT_Get_Kerning() units.
Also, is there a corresponding -draw primitive?
The -kerning option affects -draw text primitives.

For the most robust control of text placement, use SVG. Just use any of the SVG text elements and render like this:
  • convert text.svg text.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: 2 questions about -kerning

Post by anthony »

rmagick wrote:Regarding the new -kerning option. What units are the value? Pixels? Points? English Metric Units?
A question I would like to know. It would be important if you want to use it to make 'justified' text lines of specific length.

Why 64 times, why not just leave them 'as is' or multiplyed by density.

But the SVG is still probbaly the method method, if you can figure out its construction (not easy).

Google search for the man page says units are
font units for scalable formats, and in pixels for fixed-sizes formats
My experiments however show the -kerning size seems to be in pixels, regardless of font, density or otherwise. Basically generate a label of two characters using different fonts, and density's, Then subtract that from the same thing with a -kerning parameter of different sizes. the difference is the added space and that is the parameter in pixels.

As such my tests seem to indicate it is in pixels.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Re: 2 questions about -kerning

Post by rmagick »

anthony wrote: As such my tests seem to indicate it is in pixels.
I agree. Well, almost but not quite pixels. I ran some quick tests using a string of 260 alphabetic characters at 3 different densities and 6 pointsizes. Each unit increase in the kerning value increased the average width/character by 1 pixel plus or minus a couple of hundreths. This holds for positive and negative kerning values. I didn't try fractional values. For my purposes "pixel" is a sufficiently accurate description of the unit.

(Oh, and I only tried 3 fonts.)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: 2 questions about -kerning

Post by anthony »

It does not increases EVERY characters width.

It adds between every character. As such for a string of 260 characters, it will add extra space in 259 spots!

However I think (and this is untested) it will be ignored for the inter-character spaces around a NEWLINE or RETURN character.
It may also be ignored for vertical or horizontal tabs and formfeeds,
but again I can't be certain has I have not tested ir even generally used such characters for some time.

WARNING: if TABs are handles, column spacing on fixed width fonts may have problems. Again this is untested, but something to check if you plan to use it.

Cristy as asked if a -tspan option for inter-word spacing should also be added.

Though he does point out that justification and better text handling is part of the SVG format specification, so if you use the RSVG delegate library that may be the better way to handle text formating.

A simple, hand generated example of SVG text formating would be great to add to IM examples. Suggestions or Examples, or even usage notes, text, comments on this would be a good contribution to me for IM Examples.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Re: 2 questions about -kerning

Post by rmagick »

You're correct. For my purposes, the kerning unit is a pixel.

However, I'm not so much concerned with drawing using SVG as I am with supporting my Ruby RVG library, which generates MVG code. I've already got a rough-but-adequate implemenation of letter-spacing and word-spacing working but a kerning (and tspan) draw primitive would come in handy there.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: 2 questions about -kerning

Post by anthony »

Please keep me, and the rest of us image hackers, informed.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Re: 2 questions about -kerning

Post by rmagick »

I'm sorry. I should've added a link. RVG's been around for some years now. It's fairly static.

http://www.imagemagick.org/RMagick/doc/rvgtut.html.

Follow the "Next" links to see the reference doc.
Post Reply