Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!eru!luth!sunic!sics.se!sics.se!jw From: jw@sics.se (Johan Widen) Newsgroups: comp.windows.x Subject: ralpage, fix for cache.c Message-ID: <1990Aug24.093359.24479@sics.se> Date: 24 Aug 90 09:33:59 GMT Sender: news@sics.se Distribution: comp Organization: Swedish Institute of Computer Science, Kista Lines: 58 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