Re: Does ImageMagick accepts tab "\n"?
Posted: 2011-10-25T23:53:44-07:00
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
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
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?
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.
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
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?