ImageMagick Right-to-Left text rendering - imagemagick

ImageMagick does not render Right-to-Left text correctly (it does not join it and its reversed). I need a solution for this...

ImageMagick uses freetype as it's text-rendering engine, which does not support complex text layout languages. If you need text to image generation for those language, you would need alternative solution.
On Linux/UNIX, Pango has a command line tool called "pango-view", which would output text as PNG. You can then manipulate the PNG with ImageMagick.
On Windows, you can get "pango-view" in cygwin (I believe the dev package for pango in cygwin). If cygwin is unacceptable, you would need to write a program using WCF or GDI+.

Recent versions of ImageMagick supports command line argument -direction which determines rendering direction of the text from Right to Left (-direction right-to-left) or Left to Right (-direction left-to-right) manner.
See also this SO answer for an example.

Related

Writing Latex math expression in Maxima

How I can write Latex/TEX expressions in legend and labels of plot2d?
Thanks.
Maxima relies on Gnuplot for displaying plots, so to extent Maxima can handle TeX/LaTeX in labels and legends depends on what Gnuplot can handle.
Gnuplot has a LaTeX output format, but that is a file output format, not for display on the screen, so I won't consider it further here. But maybe there is some way to output a LaTeX file and then launch a viewer for it? I haven't investigated that possibility.
From looking at some discussions in the Gnuplot project, it appears that Gnuplot cannot handle TeX/LaTeX in output formats which are displayed directly to the screen. However, Gnuplot recognizes some escape sequences, and also allows Unicode characters in strings when the terminal option enhanced is specified. This allows some subset of LaTeX-like functionality.
About escape sequences, see "Enhanced text mode", pp 32--33 in the current version of the manual: http://gnuplot.info/docs_5.4/Gnuplot_5_4.pdf
About Unicode characters, see "Escape sequences", p 34. See also the examples: http://www.gnuplot.info/demo/enhanced_utf8.html and http://www.gnuplot.info/demo_5.4/unicode.html .
On looking at how Maxima interacts with Gnuplot, it appears that Maxima disabled the enhanced flag, so stuff like underscore and caret have no effect, and escape sequences are not recognized. EDIT: You can enable Gnuplot enhanced strings in Maxima via: set_plot_option([gnuplot_strings, true]);
When Unicode characters are in a string supplied by Maxima to Gnuplot, they are displayed correctly.
Most Lisp implementations handle Unicode characters; GCL is the exception.
I know this is not straightforward; this is a summary of what I could figure out, and I hope it helps.

when creating pdf with delphi how to give line break?

I am creating my own pdf with delphi. I am using Tj,BT and ET commands but I can't give line break. Which command I have to use for this line break problem or how to give line break? any link,reference or help?
I'm not sure how this relates to Delphi (which PDF component are you using?), but from what I know about postscript as used by PDF, the font data describes the width of each character, which is used for horizontal progression, but vertical progression is done with the TL and the ' command. See the PDF reference section 5.3.2

gnuplot epslatex functionality in matplotlib

I am used to plot data with gnuplot, so I can easily put the figures in a LaTeX document, using the epslatex terminal. For example:
file = "data.dat"
set terminal epslatex
set output "figure1.tex"
plot file
This way, two files are generated: one .eps file, which contains the graphics, and one .tex file, which contains the text. The great advantage of this is that text is rendered by LaTeX, so the tics, labels, etc. have the same font as the rest of the document.
Now I am starting with matplotlib, which has a much nicer API, is more scriptable and, well, is Python. But, even though I can make matplotlib render the text with LaTeX, it gets embedded into the image and I cannot achieve the same advantages I had with gnuplot.
Is there any way I can emulate the epslatex terminal in matplotlib?
Update: matplotlib 1.2 introduced a new PGF/TikZ backend, and I have successfully used it for the exact purpose stated in this question: make LaTeX / XeTeX render the text of the plot. In the documentation there are some nice examples of plotting using the PGF backend, including custom preambles, custom fonts and full unicode math support.

change to letter size on teXnicCenter & MikTex

How come TeXicCenter and MiKTeX always generate an A4 size pdf paper?
I reinstalled both MiKTeX and TeXicCenter and I made sure that I selected "Letter" to be my default paper size. Nothing changes.
Here is what worked for me, regardless of the documentclass or other packages used.
Right after \begin{document} I put these two lines:
\setlength{\pdfpagewidth}{8.5in}
\setlength{\pdfpageheight}{11in}
The default paper size for MikTeX is contained in some configuration file somewhere in the MikTeX directory. You can change it by starting up MikTeX's "Settings (Admin)" program, but you probably already tried that. TeXnicCenter has nothing to do with it.
You can always specify to use letter size paper, overriding the default, by adding the letterpaper option to your \documentclass command:
\documentclass[letterpaper]{article}
The paper size you specify is only used if your LaTeX document doesn't specify one. Even if you didn't do this in your documents, the class or one of the packages you are using may do this.
To explicitly choose your papersize either use
\documentclass[letterpaper]{scrreprt}
or
\usepackage[letterpaper]{geometry}
Other possible paper sizes are a0paper, a1paper, ..., a6paper, b0paper,b1paper, ...,b6paper,letterpaper,legalpaper,executivepaper`.
If you are using LaTeX=>PS=>PDF, then the following will work for you:
Goto Build->Define Output Profiles->LaTeX=>PS=>PDF.
Goto the Postprocessor tab.
Select Ghostscript (ps2pdf).
Edit the "Arguments".
Change the -sPAPERSIZE=a4 to -sPAPERSIZE=letter.
Notice that the size of the PDF is now 8.5 x 11.

How do you save a plot in Octave 3.0.5 if it has latex in it?

My school has Matlab but I can't use it at home so I am trying to learn Octave. I am having trouble saving plots as png files so I can put them in a report.
I read you can use print("filename.png") to save the plots, but I am getting some kind of error I am assuming is due to using latex in my labels
I am using
xlabel('\omega')
Error message: gdImageStringFT: Could not find/open font while printing string w with font Symbol
The plot still saves, but any label with latex in it just doesn't print at all. I know I could just avoid formatting the text, but it just looks so much nicer with latex.
Anyone know what I can do? (ps I am not very advanced with linux just fyi)
So what happens here is that for the png format Octave needs to have the Symbols font at its disposal if you want to include, e.g., greek letters. This is because png is a bitmap format and the letters are rasterized and printed into the picture.
The correct way, or at least the way most people circumvent Octave's / Mathematica's / etc. poor labeling, is to output encapsulated postscript (.eps) with dummy labels. These labels are kept separate in the eps format and one can then use the psfrag package in LaTeX to replace the dummy labels for correct labels. This allows for much better control over the label and gives you access to all of LaTeX's formatting and formulas.
Here or here is a hands on tutorial how to do this with Octave and gnuplot.

Resources