Does ImageMagick accepts tab "\n"?

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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Does ImageMagick accepts tab "\n"?

Post by anthony »

You can include the tab in the string. But that will NOT help you!

Tabs are simply passed by IM to the normal text rendering delegate library. This library just trys to look up a 'glyph' associated with that character code, but find none as it is not a 'glyph' but a text formatting control.

Handling TABs is something that requires text re-positioning based on the location of text on the page, to move the cursor to the next 'tab point' column. Neither IM nor the text processing library knows just how much space a tab needs to be
to do this alignment with other strings in the image being 'drawn'.

Basically TAB characters is a text formatting aspect that requires more serious word processing layout know how. That puts it beyond the scope of simple text labling and overlays onto images.

It is recommended you either
  • DIY tab positioning yourself (easy as you know the tab is at the start of the string and where you are placing the text.
  • OR use a full text formatting program, such as TeX/LaTex. Page Layout language such as Postscript. or text layout software such as Pango.
See Form Filling
http://www.imagemagick.org/Usage/text/#form_filling
and Text Processing Alternatives
http://www.imagemagick.org/Usage/text/#tex

For a simple solution see "pango-view" whcih convert text files to images. with formating
For example

Code: Select all

  pango-view -t "{tab}abc" -q -o text.png
Other solutions also include the many text to postscript conversion programs, such as "a2ps" which I demonstrate in generating a example postscript file in. IM examples, Postscript
http://www.imagemagick.org/Usage/text/#postscript


Technically even return/newline characters should not be handled by IM, But a simple solution for this is obvious and that is what is done.

A similar 'fallback' handling for tabs could be provided. For example jump cursor to the next multiple of N pixels along the line, or newline. But this would require much more complex text handling. IM is a open source package and you are welcome to program TAB handling.

Then again if you are doing that then 'justified text alignment processing' should also be included. Then what about bolding and italic formatting? Where do you stop? Completely re-implementing of word process layout language, such as provided by TeX, and GUI web browsers?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Does ImageMagick accepts tab "\n"?

Post by magick »

For proper text handling within ImageMagick, use SVG. We intend to support the Pango markup language but we do not currently have an ETA on this enhancement.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Does ImageMagick accepts tab "\n"?

Post by anthony »

In summery...

Imagemagick has only limited (low level) text processing capabilities for basic tasks.

There are lots of tools out there to convert text into images, and most can be combined with image magick to post-process the text image and merge it into your image. This lets imagemagick get on with what it does best, image processing.

For example see..
Coloring a Gray-scale Text Image
http://www.imagemagick.org/Usage/text/#coloring_text
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply