[comp.windows.x] ralpage, fix for cache.c

jw@sics.se (Johan Widen) (08/24/90)

Here is a fix for the PostScript previewer ralpage. X Window would complain
when I tried to print very small characters.

XCreatePixmap could be called with a width or height of 0.
I changed SetCacheDevice to check the width and height.
I also introduced rounding when converting height, width and offsets from
float to int.

*** /tmp/,RCSt1a08673	Fri Aug 24 11:17:15 1990
--- cache.c	Fri Aug 24 11:16:55 1990
***************
*** 215,221 ****
   	float left, right, top, bottom, width, height;
   	struct device *new_char;
   	struct cache *ccache = gstate->show->ccache;
!  	int swidth, sheight;
   	HardPoint origin;
   	
   	SetCharWidth (char_width);
--- 215,221 ----
   	float left, right, top, bottom, width, height;
   	struct device *new_char;
   	struct cache *ccache = gstate->show->ccache;
!  	int swidth, sheight, iwidth, iheight;
   	HardPoint origin;
   	
   	SetCharWidth (char_width);
***************
*** 226,236 ****
   	width = right - left; height = top - bottom;
   	
  	origin = ExtToInt (NewPoint (0.0, 0.0));
! 	swidth = origin.hx - left; sheight = origin.hy - bottom;
!  	if (CharTooBig (width, height))
   		return TRUE;
   	
!  	new_char = NewCacheDevice (ccache->mat, (int) (right - left), (int) (top - bottom), swidth, sheight);
   	CharStore (name, char_width, LinkDevice (new_char), swidth, sheight);
   	SetDevice (new_char);
   	
--- 226,237 ----
   	width = right - left; height = top - bottom;
   	
  	origin = ExtToInt (NewPoint (0.0, 0.0));
! 	swidth = origin.hx - left + 0.5; sheight = origin.hy - bottom + 0.5;
! 	iwidth = right - left + 0.5; iheight = top - bottom + 0.5;
!  	if (CharTooBig (width, height) || iwidth == 0 || iheight == 0)
   		return TRUE;
   	
!  	new_char = NewCacheDevice (ccache->mat, iwidth, iheight, swidth, sheight);
   	CharStore (name, char_width, LinkDevice (new_char), swidth, sheight);
   	SetDevice (new_char);
   	

--
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN	Internet: jw@sics.se
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30

fgreco@govt.shearson.COM (Frank Greco) (08/24/90)

Excuse me Johan,  but are you the gentleman responsible for ralpage?

I'd like to get a copy for my SPARCstation, but don't know where to get it.


Thanks,

Frank Greco
fgreco@shearson.com

jw@sics.se (Johan Widen) (08/25/90)

>>>>> In article <9008241437.AA07991@islanders.>, fgreco@govt.shearson.COM (Frank Greco) writes:

fgreco> Excuse me Johan,  but are you the gentleman responsible for ralpage?

fgreco> I'd like to get a copy for my SPARCstation, but don't know where to get it.

Well, no one seems to be really responsible for ralpage at this stage.

On the other hand: I am willing to accept bug fixes and improvements,
integrate them in the current version and put it up immediately for
anonymous ftp.

I can send you the stuff by email if you are unable to reach us by ftp
(this presumes that I am not deluged by requests)... well I guess there
is such a thing as a mail archive server.

For now, the current up to date version can be retrieved by anonymous
ftp from
	sics.se (192.16.123.90)
path
	archive/ralpage.tar.Z

--
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN	Internet: jw@sics.se
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30