+static inline int twipsnap(double f)
+{
+ /* if(f < -0x40000000/20.0) {
+ fprintf(stderr, "Warning: Coordinate underflow (%f)\n", f);
+ f = -0x40000000/20.0;
+ } else if(f>0x3fffffff/20.0) {
+ fprintf(stderr, "Warning: Coordinate overflow (%f)\n", f);
+ f = 0x3fffffff/20.0;
+ }*/
+
+ /* clamp coordinates to a rectangle with the property that we
+ can represent a line from the upper left corner to the upper
+ right corner using no more than 64 strokes */
+ const double min = -(1<<(18+4))/20.0;
+ const double max = ((1<<(18+4))-1)/20.0;
+ if(f < min) {
+ fprintf(stderr, "Warning: Coordinate underflow (%f)\n", f);
+ f = min;
+ } else if(f>max) {
+ fprintf(stderr, "Warning: Coordinate overflow (%f)\n", f);
+ f = max;
+ }
+
+ return (int)(f*20);
+}
+