Re: Vertical text alignment in postscript [message #54846] |
Tue, 17 July 2007 09:38 |
Vince Hradil
Messages: 574 Registered: December 1999
|
Senior Member |
|
|
On Jul 17, 4:59 am, Andy Heaps <a.j.he...@reading.ac.uk> wrote:
> I'm trying to align text vertically in postscript but have some extra
> space
> above where the text finishes.Using !D.Y_CH_SIZE/2.0 as the mid-point
> means that the text is now not vertically aligned.
>
> Has anyone an explanation/solution for this problem?
> Attached is a small program to show the problem.
>
> Many thanks
> Andy
>
> PRO ll
>
> SET_PLOT, 'ps'
> DEVICE, FILE='ll.ps', XSIZE=8.27, YSIZE=11.69, $
> XOFFSET=0.5, YOFFSET=0.5, /INCHES, /COLOR
> !P.COLOR=1
> !P.FONT=0
> !P.POSITION=[0.1,0.3,0.9,0.6]
> r = [255,0]
> g = [255,0]
> b = [255,0]
> TVLCT,r,g,b
>
> mysize=6.0 ;Size of our text
> ypix=!D.Y_CH_SIZE*mysize ;Height of text in pixels
> xstart=1000 ;X start of plotting
> xfinish=20000 ;X finish of plotting
> ystart=5000 ;Y start of plotting
>
> XYOUTS, xstart, ystart, CHARSIZE=mysize, 'Testing 123', /DEVICE
> PLOTS, [xstart, xfinish], [ystart, ystart], /DEVICE ;Bottom of text
> PLOTS, [xstart, xfinish], [ystart+ypix, ystart+ypix], /DEVICE ;Top of text
>
> DEVICE, /CLOSE
>
> END
The !d.y_ch_size is not the _exact_ text height:
X_CH_SIZE
Y_CH_SIZE
The width and height of the rectangle that encloses the "average"
character in the current font, in device units (usually pixels).
These values describe the size of the rectangle that contains the
"average" character in the current font. (It is not important what the
"average" character is; it is used only to calculate a scaling factor
that will be applied to all of the characters in the font.) The first
element specifies the width of the rectangle in device units (usually
pixels), and the second element specifies the height.
For vector and TrueType fonts, the height of the "average" character
is determined by the width of the rectangle. The aspect ratio of the
"average" character remains fixed; the character is scaled so that its
width is the value of X_CH_SIZE. The resulting scale factor is then
applied to all of the characters in the font. The amount of spacing
between lines is determined explicitly by the value of Y_CH_SIZE.
For device fonts, the character size is fixed. When the device font
system is in use, the value of X_CH_SIZE is silently ignored, and only
the Y_CH_SIZE value is used.
|
|
|
Re: Vertical text alignment in postscript [message #54852 is a reply to message #54846] |
Tue, 17 July 2007 08:21  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
I'm not sure what you were expecting this program to produce. For me,
it produces the words "Testing 123" with two horizontal lines. There
is some vertical space between the top of the "T" and the top line,
but this is expected for the Helvetica font.
Alignment of text on plots was just discussed in the past few days in
this newsgroup. Maybe the tips presented there could help you.
Good luck,
Craig
Andy Heaps <a.j.heaps@reading.ac.uk> writes:
> I'm trying to align text vertically in postscript but have some extra
> space
> above where the text finishes.Using !D.Y_CH_SIZE/2.0 as the mid-point
> means that the text is now not vertically aligned.
>
> Has anyone an explanation/solution for this problem?
> Attached is a small program to show the problem.
>
> Many thanks
> Andy
>
>
> PRO ll
>
> SET_PLOT, 'ps'
> DEVICE, FILE='ll.ps', XSIZE=8.27, YSIZE=11.69, $
> XOFFSET=0.5, YOFFSET=0.5, /INCHES, /COLOR
> !P.COLOR=1
> !P.FONT=0
> !P.POSITION=[0.1,0.3,0.9,0.6]
> r = [255,0]
> g = [255,0]
> b = [255,0]
> TVLCT,r,g,b
>
> mysize=6.0 ;Size of our text
> ypix=!D.Y_CH_SIZE*mysize ;Height of text in pixels
> xstart=1000 ;X start of plotting
> xfinish=20000 ;X finish of plotting
> ystart=5000 ;Y start of plotting
>
> XYOUTS, xstart, ystart, CHARSIZE=mysize, 'Testing 123', /DEVICE
> PLOTS, [xstart, xfinish], [ystart, ystart], /DEVICE ;Bottom of text
> PLOTS, [xstart, xfinish], [ystart+ypix, ystart+ypix], /DEVICE ;Top of text
>
> DEVICE, /CLOSE
>
> END
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|