[gs-commits] ghostpdl branch, master, updated. ghostpdl-9.02-1026-g8031fd5
Chris Liddell
chrisl at ghostscript.com
Wed Mar 21 14:28:38 UTC 2012
The ghostpdl branch, master has been updated
via 8031fd574e3949cf1e17eed0372034e522580dca (commit)
from 0c0f193bc6673fd4c6c257fd8c6fe740882c6023 (commit)
----------------------------------------------------------------------
commit 8031fd574e3949cf1e17eed0372034e522580dca
Author: Chris Liddell <chris.liddell at artifex.com>
Date: Wed Mar 21 14:22:35 2012 +0000
Bug 692850: FAPI: clamp fixed-point overflows instead of error.
This job ends up with an insanely big scale factor when trying rendering glyphs
from a font. Obviously that ends up too big to render to a bitmap in the
font renderer, so we build a path instead.
Previously, during FAPI path extraction, if the coordinates overflowed what we
can represent in our fixed point representation, give a rangecheck error. But
the AFS code seems to clamp the coordinate to something we can represent, and
carry on.
Do the same in FAPI.
No cluster differences.
diff --git a/gs/psi/zfapi.c b/gs/psi/zfapi.c
index d875529..8dab500 100644
--- a/gs/psi/zfapi.c
+++ b/gs/psi/zfapi.c
@@ -101,17 +101,27 @@ static int add_move(FAPI_path *I, int64_t x, int64_t y)
x = import_shift(x, I->shift) + olh->x0;
y = -import_shift(y, I->shift) + olh->y0;
- if (x > (int64_t)max_fixed || y > (int64_t)max_fixed || x < -(int64_t)max_fixed || y < -(int64_t)max_fixed) {
- I->gs_error = e_rangecheck;
+
+ if (x > (int64_t)max_fixed) {
+ x = (int64_t)max_fixed;
+ }
+ else if (x < (int64_t)min_fixed) {
+ x = (int64_t)min_fixed;
}
- else {
- if (olh->need_close && olh->close_path)
- if ((I->gs_error = add_closepath(I)) < 0)
- return I->gs_error;
- olh->need_close = false;
- I->gs_error = gx_path_add_point(olh->path, (fixed)x, (fixed)y);
+ if (y > (int64_t)max_fixed) {
+ y = (int64_t)max_fixed;
+ }
+ else if (y < (int64_t)min_fixed) {
+ y = (int64_t)min_fixed;
}
+
+ if (olh->need_close && olh->close_path)
+ if ((I->gs_error = add_closepath(I)) < 0)
+ return I->gs_error;
+ olh->need_close = false;
+ I->gs_error = gx_path_add_point(olh->path, (fixed)x, (fixed)y);
+
return I->gs_error;
}
@@ -120,14 +130,22 @@ static int add_line(FAPI_path *I, int64_t x, int64_t y)
x = import_shift(x, I->shift) + olh->x0;
y = -import_shift(y, I->shift) + olh->y0;
- if (x > (int64_t)max_fixed || y > (int64_t)max_fixed || x < -(int64_t)max_fixed || y < -(int64_t)max_fixed) {
- I->gs_error = e_rangecheck;
+ if (x > (int64_t)max_fixed) {
+ x = (int64_t)max_fixed;
+ }
+ else if (x < (int64_t)min_fixed) {
+ x = (int64_t)min_fixed;
}
- else {
- olh->need_close = true;
- I->gs_error = gx_path_add_line_notes(olh->path, (fixed)x, (fixed)y, 0);
+ if (y > (int64_t)max_fixed) {
+ y = (int64_t)max_fixed;
+ }
+ else if (y < (int64_t)min_fixed) {
+ y = (int64_t)min_fixed;
}
+
+ olh->need_close = true;
+ I->gs_error = gx_path_add_line_notes(olh->path, (fixed)x, (fixed)y, 0);
return I->gs_error;
}
@@ -141,16 +159,48 @@ static int add_curve(FAPI_path *I, int64_t x0, int64_t y0, int64_t x1, int64_t y
x2 = import_shift(x2, I->shift) + olh->x0;
y2 = -import_shift(y2, I->shift) + olh->y0;
- if (x0 > (int64_t)max_fixed || y0 > (int64_t)max_fixed || x0 < -(int64_t)max_fixed || y0 < -(int64_t)max_fixed ||
- x1 > (int64_t)max_fixed || y1 > (int64_t)max_fixed || x1 < -(int64_t)max_fixed || y1 < -(int64_t)max_fixed ||
- x2 > (int64_t)max_fixed || y2 > (int64_t)max_fixed || x2 < -(int64_t)max_fixed || y2 < -(int64_t)max_fixed) {
- I->gs_error = e_rangecheck;
+ if (x0 > (int64_t)max_fixed) {
+ x0 = (int64_t)max_fixed;
+ }
+ else if (x0 < (int64_t)min_fixed) {
+ x0 = (int64_t)min_fixed;
}
- else {
- olh->need_close = true;
- I->gs_error = gx_path_add_curve_notes(olh->path, (fixed)x0, (fixed)y0, (fixed)x1, (fixed)y1, (fixed)x2, (fixed)y2, 0);
+ if (y0 > (int64_t)max_fixed) {
+ y0 = (int64_t)max_fixed;
+ }
+ else if (y0 < (int64_t)min_fixed) {
+ y0 = (int64_t)min_fixed;
+ }
+ if (x1 > (int64_t)max_fixed) {
+ x1 = (int64_t)max_fixed;
+ }
+ else if (x1 < (int64_t)min_fixed) {
+ x1 = (int64_t)min_fixed;
+ }
+
+ if (y1 > (int64_t)max_fixed) {
+ y1 = (int64_t)max_fixed;
+ }
+ else if (y1 < (int64_t)min_fixed) {
+ y1 = (int64_t)min_fixed;
}
+ if (x2 > (int64_t)max_fixed) {
+ x2 = (int64_t)max_fixed;
+ }
+ else if (x2 < (int64_t)min_fixed) {
+ x2 = (int64_t)min_fixed;
+ }
+
+ if (y2 > (int64_t)max_fixed) {
+ y2 = (int64_t)max_fixed;
+ }
+ else if (y2 < (int64_t)min_fixed) {
+ y2 = (int64_t)min_fixed;
+ }
+
+ olh->need_close = true;
+ I->gs_error = gx_path_add_curve_notes(olh->path, (fixed)x0, (fixed)y0, (fixed)x1, (fixed)y1, (fixed)x2, (fixed)y2, 0);
return I->gs_error;
}
Summary of changes:
gs/psi/zfapi.c | 90 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 70 insertions(+), 20 deletions(-)
More information about the gs-commits
mailing list