Russ Cox committed c947ca2

libdraw: add scalesize


  • Participants
  • Parent commits 10a127e

Comments (0)

Files changed (3)

File include/draw.h

 extern int	nameimage(Image*, char*, int);
 extern Image* allocimagemix(Display*, u32int, u32int);
 extern int	drawsetlabel(char*);
+extern int	scalesize(Display*, int);
  * Colors

File man/man3/graphics.3

 	   Image **ip, Screen **sp, int ref)
+int	scalesize(Display *d, int n)
 void	cursorswitch(Cursor *curs)
 .B Screen
 variables for the new window.
+Historically, Plan 9 graphics programs have used fixed-size graphics features that assume a narrow range of display densities, around 100 dpi: pixels (or dots) per inch.
+The new field
+.B display->dpi
+contains the display's actual density if known, or else
+.B DefaultDPI
+.I Scalesize
+scales the fixed pixel count
+.I n
+.BR display->dpi / DefaultDPI ,
+rounding appropriately.
 The mouse cursor is always displayed.
 The initial cursor is an arrow.
 .I Cursorswitch

File src/libdraw/init.c

 	return p;
+scalesize(Display *d, int n)
+	if(d == nil || d->dpi <= DefaultDPI)
+		return n;
+	return (n*d->dpi+DefaultDPI/2)/DefaultDPI;