Skip to content

postscript printer breaking up long strings

4 messages · tommers, (Ted Harding), Cameron Bracken

#
For a long string in an axis title, or main title the postscript device
breaks apart the long strings into smaller strings.  For example,
produces the attached output.
http://www.nabble.com/file/p23322197/linebreaktest.eps linebreaktest.eps 

The most important lines from the eps source are at the end of the file:
********************************************
309.70 36.72 (aReallyLongStr) 0 ta
0.180 (ingT) tb
-1.440 (oSeeHo) tb
-0.180 (wItBreaks) tb gr
30.96 212.50 (aReallyLongStr) 90 ta
0.180 (ingT) tb
-1.440 (oSeeHo) tb
-0.180 (wItBreaks) tb gr
77.04 91.44 743.76 534.96 cl
/Font1 findfont 12 s
0 setgray
1.03 104.76 (aReallyLongStr) 0 ta
0.180 (ingT) tb
-1.440 (oSeeHo) tb
-0.180 (wItBreaks) tb gr
309.70 310.10 (aReallyLongStr) 0 ta
0.180 (ingT) tb
-1.440 (oSeeHo) tb
-0.180 (wItBreaks) tb gr
618.36 515.43 (aReallyLongStr) 0 ta
0.180 (ingT) tb
-1.440 (oSeeHo) tb
-0.180 (wItBreaks) tb gr
*******************************************************
Each string is broken into 4 chunks.  Has anyone else had this problem?

Thanks!
#
On 30-Apr-09 18:50:38, tommers wrote:
postscript('linebreaktest.eps')
  plot(1,xlab='aReallyLongStringToSeeHowItBreaks',
         ylab='aReallyLongStringToSeeHowItBreaks')
  for(i in
c(.6,1,1.4))text(i,i,'aReallyLongStringToSeeHowItBreaks')
  dev.off()
In the graph shown in your URL above, the xlab and the ylab
appear in their entirety, unbroken. So does the one plotted
in the middle of the graph. I get the same when I run your code.

The texts you plotted at the first and third of the positions
(i,i) also are not (I think) unbroken -- they are simply not
entirely visible.

The one at bottom left is missing its start "aReallyLongSt",
and the one at top right is missing its end "eHowItBreaks".

These apparent truncations arise because the beginning of the
first, and the end of the second, are outside the plotting
area, and so when the postcript() driver puts a BoundingBox
at the border of the potting area this has the effect of
"clipping" these strings when they are displayed.

The apparently "broken" strings in the PostScript code you
quote below are perfectly normal in PostScript. When dealing
with text in a variable-width font, a PS driver will typically
split continuous text into chunks, to allow for effects like
kerning (or other adjustments of spacing) between the chunks.
You will note that all five instances of the string are split
in the same places, despite the fact that at least three of
them come out perfectly (according to the graph on your URL).

So nothing is wrong. You will have to adjust the extent of
your plotting area, or adjust the "pos" or "just" of your
(i,i) labels, to be able to see them in their entirety.

Hoping this helps,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 30-Apr-09                                       Time: 21:39:59
------------------------------ XFMail ------------------------------
#
########################
The apparently "broken" strings in the PostScript code you
quote below are perfectly normal in PostScript. When dealing
with text in a variable-width font, a PS driver will typically
split continuous text into chunks, to allow for effects like
kerning (or other adjustments of spacing) between the chunks.
########################

Let give a few more details.

If I were to leave the plot as a postscript file, there wouldn't be a
problem.  I am, however, attempting to convert to a pgf file with the
pgfSweave package (which utilizes eps2pgf).  

 http://www.rforge.net/pgfSweave/

When converted to pgf, the breaking of strings is quite obvious (see
attachment). 

http://www.nabble.com/file/p23324954/pgfSweave-example-boxplot.pdf
pgfSweave-example-boxplot.pdf 

I have been in contact with the developers of pgfSweave, but they
cannot replicate my problem.  Their postscript devices do not break
apart the strings, so the pgf files have correctly spaced axes labels.
 They referred me to the forums for additional support.
#
Ted.Harding-2 wrote:
Hi-

I am one of the developers of pgfSweave. The problem (although it is
considered a feature) is this (from https://svn.r-project.org/R/trunk/NEWS):

NEW FEATURES (in 2.9.0)

    o	pdf() and postscript() gain a 'useKerning' argument to place
	strings using kerning (which had previously been ignored in
	display but not in strwidth), based in part on an idea and
	code from Ei-ji Nakama. The default is TRUE.

	Kerning involving spaces is now ignored (it was previously
	only used in the computation of string widths).

This is normally not a problem but converting to pgf and then to pdf causes
large gaps when the useKerning option is turned on. The following will cause
the long strings to not break.

  postscript('linebreaktest.eps',useKerning=FALSE) 
  plot(1,xlab='aReallyLongStringToSeeHowItBreaks', 
         ylab='aReallyLongStringToSeeHowItBreaks') 
  for(i in c(.6,1,1.4))text(i,i,'aReallyLongStringToSeeHowItBreaks') 
  dev.off()
 
Kerning will be turned off by default in the latest snapshot of pgfSweave.

-Cameron Bracken