Lisp HUG Maillist Archive

gp:draw-string with right-ward alignment?

gp:draw-string is always left aligned.

I am drawing y-axis of a chart and I want all the numbers to be right- 
aligned to the y-axis. Is there a parameter in gp:-draw-string that  
will allow me to induce right-ward alignment?

Or must this only be done manually? For example, calculating the  
pixel width of the string and shift x accordingly. If so, is there a  
method for calculating the pixel width automatically?

Thank you,

Dr. Atip Asvanund


Re: gp:draw-string with right-ward alignment?

Dr. Atip Asvanund wrote:

> I am drawing y-axis of a chart and I want all the numbers to
> be right-aligned to the y-axis. Is there a parameter in
> gp:-draw-string that  will allow me to induce right-ward
> alignment?

I don't think so.

> Or must this only be done manually? For example, calculating the
> pixel width of the string and shift x accordingly.

Yes, that's how I did it when I needed this.

> If so, is there a  method for calculating the pixel width automatically?

GP:GET-STRING-EXTENT.

I attach some code that I wrote as part of my own chart-drawing library.
Please feel free to use this code.

 --
Arthur


Updated at: 2020-12-10 08:50 UTC