+ x = FROUND(box.ox * xf) + dvi->pos.hh;
+ y = FROUND(box.oy * vf) + dvi->pos.vv - h + 1;
+
+ if (!file || !dvi->device.draw_ps) {
+ dvi->device.draw_rule (dvi, x, y, w, h, 0);
+ return;
+ }
+
+ if (file[0] == '/') { /* Absolute path */
+ if (stat (file, &buf) == 0)
+ dvi->device.draw_ps (dvi, file, x, y, w, h);
+ else
+ dvi->device.draw_rule (dvi, x, y, w, h, 0);
+ return;
+ }
+
+ tmp = mdvi_strrstr (dvi->filename, "/");
+ if (tmp) { /* Document directory */
+ int path_len = strlen (dvi->filename) - strlen (tmp + 1);
+ int file_len = strlen (file);
+
+ psfile = mdvi_malloc (path_len + file_len + 1);
+ psfile[0] = '\0';
+ strncat (psfile, dvi->filename, path_len);
+ strncat (psfile, file, file_len);
+
+ if (stat (psfile, &buf) == 0) {
+ dvi->device.draw_ps (dvi, psfile, x, y, w, h);
+ mdvi_free (psfile);
+
+ return;
+ }
+
+ mdvi_free (psfile);
+ }
+
+ psfile = mdvi_build_path_from_cwd (file);
+ if (stat (psfile, &buf) == 0) { /* Current working dir */
+ dvi->device.draw_ps (dvi, psfile, x, y, w, h);
+ mdvi_free (psfile);
+
+ return;
+ }
+
+ mdvi_free (psfile);
+
+ psfile = kpse_find_pict (file);
+ if (psfile) { /* kpse */
+ dvi->device.draw_ps (dvi, psfile, x, y, w, h);
+ } else {
+ dvi->device.draw_rule(dvi, x, y, w, h, 0);
+ }
+
+ free (psfile);