for (int i=0; i<6; i++) {
if (i)
s += " ";
- s += pdf_coord(m[i], 0);
+ s += pdf_coord(m[i], 6);
}
return s;
}
swap(y_min, y_max);
}
+BBox BBox::transformed(pdf_matrix &m)
+{
+ BBox b = *this;
+ b.transform(m);
+ return b;
+}
+
void BBox::join(BBox &with)
{
x_min = min(x_min, with.x_min);
y_max = max(y_max, with.y_max);
}
+void BBox::enlarge(double by)
+{
+ x_min -= by;
+ x_max += by;
+ y_min -= by;
+ y_max += by;
+}
+
+BBox BBox::enlarged(double by)
+{
+ BBox b = *this;
+ b.enlarge(by);
+ return b;
+}
+
/*** Unicode strings ***/
// Construct PDF representation of a UTF-8 string
string pdf_coord(double x, uint digits)
{
- char buf[16];
- snprintf(buf, sizeof(buf), "%.*f", digits, x);
- return buf;
+ char buf[16];
+ snprintf(buf, sizeof(buf), "%.*f", digits, x);
+ int n = strlen(buf);
+ while (n > 0 && buf[n-1] == '0')
+ buf[--n] = 0;
+ if (n > 0 && buf[n-1] == '.')
+ buf[--n] = 0;
+ return buf;
}