[Gs-code-review] FAPI project : Fixing a bug in stringwidth
Igor V. Melichev
igor at artifex.com
Mon Feb 25 02:11:27 PST 2002
FAPI project : (1) Fixing a bug in stringwidth;
(2) replacing CheckRET macro with return_if_error.
[Log message end]
This is post-commit submission.
It only changes UFST-dependent files.
Changes:
File fapiufst.c :
*** f:\casper\head\gs\src\fapiufst.c Fri Feb 22 02:07:04 2002
--- files\gs\src\fapiufst.c Mon Feb 25 12:53:08 2002
***************
*** 38,42 ****
#include "gxfapi.h"
! #define CheckRET(a) { int x = a; if(x != 0) return x; }
GLOBAL const SW16 trace_sw = 0; /* UFST 4.3 wants it. */
--- 38,42 ----
#include "gxfapi.h"
! #define return_if_error(a) { int x = a; if(x != 0) return x; }
GLOBAL const SW16 trace_sw = 0; /* UFST 4.3 wants it. */
***************
*** 124,133 ****
private FAPI_retcode open_UFST(fapi_ufst_server *r)
{ IFCONFIG config_block;
! CheckRET(CGIFinit(&r->IFS));
r->IFS.mem_avail[BUFFER_POOL] = 6000000L; /* For Asian TT fonts with
vertical writing mode. */
config_block.num_files = 10;
config_block.bit_map_width = 1;
! CheckRET(CGIFconfig(&r->IFS, &config_block));
! CheckRET(CGIFenter(&r->IFS));
return 0;
}
--- 124,133 ----
private FAPI_retcode open_UFST(fapi_ufst_server *r)
{ IFCONFIG config_block;
! return_if_error(CGIFinit(&r->IFS));
r->IFS.mem_avail[BUFFER_POOL] = 6000000L; /* For Asian TT fonts with
vertical writing mode. */
config_block.num_files = 10;
config_block.bit_map_width = 1;
! return_if_error(CGIFconfig(&r->IFS, &config_block));
! return_if_error(CGIFenter(&r->IFS));
return 0;
}
***************
*** 473,477 ****
if (e == 0) {
SW16 fcHandle;
! CheckRET(CGIFfco_Open(&r->IFS, (UB8 *)font_file_path, &fcHandle));
e = (fco_list_elem *)r->client_mem.alloc(&r->client_mem,
sizeof(*e), "fco_list_elem");
if (e == 0) {
--- 473,477 ----
if (e == 0) {
SW16 fcHandle;
! return_if_error(CGIFfco_Open(&r->IFS, (UB8 *)font_file_path,
&fcHandle));
e = (fco_list_elem *)r->client_mem.alloc(&r->client_mem,
sizeof(*e), "fco_list_elem");
if (e == 0) {
***************
*** 538,542 ****
if (d->font_type == FC_FCO_TYPE) {
fco_list_elem *e;
! CheckRET(fco_open(r, font_file_path, &e));
enumerate_fco(r, font_file_path); /* development perpose only
*/
d->font_id = (e->fcHandle << 16) | subfont;
--- 538,542 ----
if (d->font_type == FC_FCO_TYPE) {
fco_list_elem *e;
! return_if_error(fco_open(r, font_file_path, &e));
enumerate_fco(r, font_file_path); /* development perpose only
*/
d->font_id = (e->fcHandle << 16) | subfont;
***************
*** 640,644 ****
ff->need_decrypt = 1;
if (d == 0) {
! CheckRET(make_font_data(r, ff->font_file_path, subfont, ff, &d));
ff->server_font_data = d;
prepare_typeface(r, d);
--- 640,644 ----
ff->need_decrypt = 1;
if (d == 0) {
! return_if_error(make_font_data(r, ff->font_file_path, subfont, ff,
&d));
ff->server_font_data = d;
prepare_typeface(r, d);
***************
*** 694,698 ****
gx_set_UFST_Callbacks(gs_PCLEO_charptr, gs_PCLchId2ptr,
gs_PCLglyphID2Ptr);
code = CGIFfont(&r->IFS, fc);
! CheckRET(r->callback_error);
return code;
}
--- 694,698 ----
gx_set_UFST_Callbacks(gs_PCLEO_charptr, gs_PCLchId2ptr,
gs_PCLglyphID2Ptr);
code = CGIFfont(&r->IFS, fc);
! return_if_error(r->callback_error);
return code;
}
***************
*** 708,712 ****
{ fapi_ufst_server *r = If_to_I(server);
SW16 VLCPower = 0;
! CheckRET(CGIFbound_box(&r->IFS, BBox, &VLCPower));
/* UFST expands bbox for internal needs, and retrives the expanded
bbox.
We believe it's bug in UFST.
--- 708,712 ----
{ fapi_ufst_server *r = If_to_I(server);
SW16 VLCPower = 0;
! return_if_error(CGIFbound_box(&r->IFS, BBox, &VLCPower));
/* UFST expands bbox for internal needs, and retrives the expanded
bbox.
We believe it's bug in UFST.
***************
*** 775,779 ****
}
! private FAPI_retcode get_char_width(FAPI_server *server, FAPI_font *ff,
FAPI_char_ref *c, int *escapement)
{ fapi_ufst_server *r = If_to_I(server);
UW16 buffer[2];
--- 775,779 ----
}
! private FAPI_retcode get_char_width(FAPI_server *server, FAPI_font *ff,
FAPI_char_ref *c, FAPI_metrics *metrics)
{ fapi_ufst_server *r = If_to_I(server);
UW16 buffer[2];
***************
*** 783,790 ****
r->ff = ff;
CGIFchIdptr(&r->IFS, &cc, PSchar_name);
! CheckRET(CGIFwidth(&r->IFS, cc, 1, 4, buffer));
r->ff = 0;
release_glyphs(r, (ufst_common_font_data *)ff->server_font_data);
! *escapement = buffer[0]; /* fixme : not tested after the change. */
return 0;
}
--- 783,791 ----
r->ff = ff;
CGIFchIdptr(&r->IFS, &cc, PSchar_name);
! return_if_error(CGIFwidth(&r->IFS, cc, 1, 4, buffer));
r->ff = 0;
release_glyphs(r, (ufst_common_font_data *)ff->server_font_data);
! metrics->escapement = buffer[0];
! metrics->em_x = metrics->em_y = buffer[1];
return 0;
}
***************
*** 807,814 ****
for(j=0; j<num_segmts; j++) {
if(*segment == 0x00) {
! CheckRET(p->moveto(p, points->x, points->y));
points++;
} else if (*segment == 0x01) {
! CheckRET(p->lineto(p, points->x, points->y));
points++;
} else if (*segment == 0x02) {
--- 808,815 ----
for(j=0; j<num_segmts; j++) {
if(*segment == 0x00) {
! return_if_error(p->moveto(p, points->x, points->y));
points++;
} else if (*segment == 0x01) {
! return_if_error(p->lineto(p, points->x, points->y));
points++;
} else if (*segment == 0x02) {
***************
*** 816,820 ****
return e_invalidfont; /* This must not happen */
} else if (*segment == 0x03) {
! CheckRET(p->curveto(p, points[0].x, points[0].y, points[1].x,
points[1].y, points[2].x, points[2].y));
points+=3;
} else
--- 817,821 ----
return e_invalidfont; /* This must not happen */
} else if (*segment == 0x03) {
! return_if_error(p->curveto(p, points[0].x, points[0].y, points[1].x,
points[1].y, points[2].x, points[2].y));
points+=3;
} else
***************
*** 860,864 ****
/* hack : Changing UFST internal data - see above. */
r->IFS.fcCur.ssnum = RAW_GLYPH;
! CheckRET(r->callback_error);
CGIFchIdptr(&r->IFS, &c1, (char *)".notdef");
code = CGIFchar_with_design_bbox(&r->IFS, c1, &result, (SW16)0,
design_bbox, &design_escapement);
--- 861,865 ----
/* hack : Changing UFST internal data - see above. */
r->IFS.fcCur.ssnum = RAW_GLYPH;
! return_if_error(r->callback_error);
CGIFchIdptr(&r->IFS, &c1, (char *)".notdef");
code = CGIFchar_with_design_bbox(&r->IFS, c1, &result, (SW16)0,
design_bbox, &design_escapement);
***************
*** 867,871 ****
r->ff = 0;
release_glyphs(r, (ufst_common_font_data *)ff->server_font_data);
! CheckRET(r->callback_error);
if (code != ERR_fixed_space && code != 0)
return code;
--- 868,872 ----
r->ff = 0;
release_glyphs(r, (ufst_common_font_data *)ff->server_font_data);
! return_if_error(r->callback_error);
if (code != ERR_fixed_space && code != 0)
return code;
File ifapi.h :
*** f:\casper\head\gs\src\ifapi.h Fri Feb 22 02:07:58 2002
--- files\gs\src\ifapi.h Mon Feb 25 10:08:49 2002
***************
*** 129,133 ****
FAPI_retcode (*can_retrieve_char_by_name)(FAPI_server *server,
FAPI_font *ff, FAPI_char_ref *c, int *result);
//FAPI_retcode (*outline_char)(FAPI_server *server, FAPI_font *ff,
FAPI_char_ref *c, FAPI_path *p, FAPI_metrics *metrics);
! FAPI_retcode (*get_char_width)(FAPI_server *server, FAPI_font *ff,
FAPI_char_ref *c, int *escapement);
FAPI_retcode (*get_char_raster_metrics)(FAPI_server *server, FAPI_font
*ff, FAPI_char_ref *c, FAPI_metrics *metrics);
FAPI_retcode (*get_char_raster)(FAPI_server *server, FAPI_raster *r);
--- 129,133 ----
FAPI_retcode (*can_retrieve_char_by_name)(FAPI_server *server,
FAPI_font *ff, FAPI_char_ref *c, int *result);
//FAPI_retcode (*outline_char)(FAPI_server *server, FAPI_font *ff,
FAPI_char_ref *c, FAPI_path *p, FAPI_metrics *metrics);
! FAPI_retcode (*get_char_width)(FAPI_server *server, FAPI_font *ff,
FAPI_char_ref *c, FAPI_metrics *metrics);
FAPI_retcode (*get_char_raster_metrics)(FAPI_server *server, FAPI_font
*ff, FAPI_char_ref *c, FAPI_metrics *metrics);
FAPI_retcode (*get_char_raster)(FAPI_server *server, FAPI_raster *r);
File int.mak :
*** f:\casper\head\gs\src\int.mak Fri Feb 22 02:08:00 2002
--- files\gs\src\int.mak Mon Feb 25 12:57:29 2002
***************
*** 1787,1791 ****
$(PSOBJ)fapiufst.$(OBJ) : $(PSSRC)fapiufst.c $(OP) \
! $(memory__h) $(stdio__h) $(math__h) $(errors_h) $(iplugin_h) $(ifapi_h)
$(gxfapi_h) \
$(UFST_ROOT)$(D)rts$(D)inc$(D)cgconfig.h\
$(UFST_ROOT)$(D)rts$(D)inc$(D)shareinc.h\
--- 1787,1791 ----
$(PSOBJ)fapiufst.$(OBJ) : $(PSSRC)fapiufst.c $(OP) \
! $(memory__h) $(stdio__h) $(math__h) $(errors_h) $(iplugin_h) $(ifapi_h)
$(gserror_h) $(gxfapi_h) \
$(UFST_ROOT)$(D)rts$(D)inc$(D)cgconfig.h\
$(UFST_ROOT)$(D)rts$(D)inc$(D)shareinc.h\
File zfapi.c :
*** f:\casper\head\gs\src\zfapi.c Fri Feb 22 02:22:22 2002
--- files\gs\src\zfapi.c Mon Feb 25 10:11:17 2002
***************
*** 54,59 ****
#include "gxfcid.h"
- #define CheckRET(a) { int x = a; if(x < 0) return x; }
-
/* -------------------------------------------------------- */
--- 54,57 ----
***************
*** 77,81 ****
{ FAPI_outline_handler *olh = (FAPI_outline_handler *)I->olh;
if (olh->need_close && olh->close_path)
! CheckRET(add_closepath(I));
olh->need_close = false;
return gx_path_add_point(olh->path, import_shift(x, I->shift) +
olh->x0, -import_shift(y, I->shift) + olh->y0);
--- 75,79 ----
{ FAPI_outline_handler *olh = (FAPI_outline_handler *)I->olh;
if (olh->need_close && olh->close_path)
! return_if_error(add_closepath(I));
olh->need_close = false;
return gx_path_add_point(olh->path, import_shift(x, I->shift) +
olh->x0, -import_shift(y, I->shift) + olh->y0);
***************
*** 600,604 ****
private int FAPI_get_xlatmap(i_ctx_t *i_ctx_p, char **xlatmap)
{ ref *pref;
! CheckRET(dict_find_string(systemdict, ".xlatmap", &pref));
if (r_type(pref) != t_string)
return_error(e_typecheck);
--- 598,602 ----
private int FAPI_get_xlatmap(i_ctx_t *i_ctx_p, char **xlatmap)
{ ref *pref;
! return_if_error(dict_find_string(systemdict, ".xlatmap", &pref));
if (r_type(pref) != t_string)
return_error(e_typecheck);
***************
*** 650,654 ****
if (!strcmp(h->I->d->subtype, subtype)) {
FAPI_server *I = *pI = (FAPI_server *)h->I;
! CheckRET(renderer_retcode(i_ctx_p, I, I->ensure_open(I)));
return 0;
}
--- 648,652 ----
if (!strcmp(h->I->d->subtype, subtype)) {
FAPI_server *I = *pI = (FAPI_server *)h->I;
! return_if_error(renderer_retcode(i_ctx_p, I, I->ensure_open(I)));
return 0;
}
***************
*** 667,671 ****
FAPI_font ff = ff_stub;
if (font_file_path != NULL && pbfont->FAPI_font_data == NULL)
! CheckRET(FAPI_get_xlatmap(i_ctx_p, &xlatmap));
scale = 1 << I->frac_shift;
size1 = size = 1 / hypot(pbfont->FontMatrix.xx,
pbfont->FontMatrix.xy);
--- 665,669 ----
FAPI_font ff = ff_stub;
if (font_file_path != NULL && pbfont->FAPI_font_data == NULL)
! return_if_error(FAPI_get_xlatmap(i_ctx_p, &xlatmap));
scale = 1 << I->frac_shift;
size1 = size = 1 / hypot(pbfont->FontMatrix.xx,
pbfont->FontMatrix.xy);
***************
*** 685,692 ****
ff.server_font_data = pbfont->FAPI_font_data; /* Possibly pass it from
zFAPIpassfont. */
ff.is_cid = IsCIDFont(pbfont);
! CheckRET(renderer_retcode(i_ctx_p, I, I->get_scaled_font(I, &ff,
subfont, matrix, HWResolution, xlatmap, false)));
pbfont->FAPI_font_data = ff.server_font_data; /* Save it back to GS
font. */
! CheckRET(renderer_retcode(i_ctx_p, I, I->get_font_bbox(I, &ff,
BBox)));
! CheckRET(renderer_retcode(i_ctx_p, I, I->get_decodingID(I, &ff,
&decodingID)));
/* Refine FontBBox : */
--- 683,690 ----
ff.server_font_data = pbfont->FAPI_font_data; /* Possibly pass it from
zFAPIpassfont. */
ff.is_cid = IsCIDFont(pbfont);
! return_if_error(renderer_retcode(i_ctx_p, I, I->get_scaled_font(I,
&ff, subfont, matrix, HWResolution, xlatmap, false)));
pbfont->FAPI_font_data = ff.server_font_data; /* Save it back to GS
font. */
! return_if_error(renderer_retcode(i_ctx_p, I, I->get_font_bbox(I, &ff,
BBox)));
! return_if_error(renderer_retcode(i_ctx_p, I, I->get_decodingID(I, &ff,
&decodingID)));
/* Refine FontBBox : */
***************
*** 720,732 ****
ordering_length = min(r_size(Ordering), sizeof(buf) - 2 -
decodingID_length);
memcpy(buf, Ordering->value.const_bytes, ordering_length);
! CheckRET(name_ref(buf, ordering_length, &SubstNWP, 0));
! CheckRET(dict_put_string(pdr, "SubstNWP", &SubstNWP, NULL));
buf[ordering_length] = '.';
memcpy(buf + ordering_length + 1, decodingID,
decodingID_length);
buf[decodingID_length + 1 + ordering_length] = 0; /* Debug
purpose only */
! CheckRET(name_ref(buf, decodingID_length + 1 +
ordering_length, &Decoding, 0));
} else
! CheckRET(name_ref((const byte *)decodingID,
strlen(decodingID), &Decoding, 0));
! CheckRET(dict_put_string(pdr, "Decoding", &Decoding, NULL));
}
--- 718,730 ----
ordering_length = min(r_size(Ordering), sizeof(buf) - 2 -
decodingID_length);
memcpy(buf, Ordering->value.const_bytes, ordering_length);
! return_if_error(name_ref(buf, ordering_length, &SubstNWP, 0));
! return_if_error(dict_put_string(pdr, "SubstNWP", &SubstNWP,
NULL));
buf[ordering_length] = '.';
memcpy(buf + ordering_length + 1, decodingID,
decodingID_length);
buf[decodingID_length + 1 + ordering_length] = 0; /* Debug
purpose only */
! return_if_error(name_ref(buf, decodingID_length + 1 +
ordering_length, &Decoding, 0));
} else
! return_if_error(name_ref((const byte *)decodingID,
strlen(decodingID), &Decoding, 0));
! return_if_error(dict_put_string(pdr, "Decoding", &Decoding,
NULL));
}
***************
*** 751,755 ****
ff.server_font_data = pbfont1->FAPI_font_data;
ff.is_cid = true;
! CheckRET(renderer_retcode(i_ctx_p, I, I->get_scaled_font(I,
&ff, 0, matrix, HWResolution, NULL, false)));
pbfont1->FAPI_font_data = ff.server_font_data; /* Save it back
to GS font. */
}
--- 749,753 ----
ff.server_font_data = pbfont1->FAPI_font_data;
ff.is_cid = true;
! return_if_error(renderer_retcode(i_ctx_p, I,
I->get_scaled_font(I, &ff, 0, matrix, HWResolution, NULL, false)));
pbfont1->FAPI_font_data = ff.server_font_data; /* Save it back
to GS font. */
}
***************
*** 790,794 ****
uint len;
font_data *pdata;
! CheckRET(code);
check_type(*op, t_boolean);
if (pbfont->FAPI != 0) {
--- 788,792 ----
uint len;
font_data *pdata;
! return_if_error(code);
check_type(*op, t_boolean);
if (pbfont->FAPI != 0) {
***************
*** 804,808 ****
strncpy(FAPI_ID, (const char *)pchars, len);
FAPI_ID[len] = 0;
! CheckRET(FAPI_find_plugin(i_ctx_p, FAPI_ID, &pbfont->FAPI));
}
pdata = (font_data *)pfont->client_data;
--- 802,806 ----
strncpy(FAPI_ID, (const char *)pchars, len);
FAPI_ID[len] = 0;
! return_if_error(FAPI_find_plugin(i_ctx_p, FAPI_ID,
&pbfont->FAPI));
}
pdata = (font_data *)pfont->client_data;
***************
*** 810,816 ****
v = NULL;
if (pfont->FontType == ft_CID_encrypted && v == NULL) {
! CheckRET(build_proc_name_refs(&build, ".FAPIBuildGlyph9",
".FAPIBuildGlyph9"));
} else
! CheckRET(build_proc_name_refs(&build, ".FAPIBuildChar",
".FAPIBuildGlyph"));
if (name_index(&pdata->BuildChar) == name_index(&build.BuildChar)) {
/* Already rebuilt - maybe a substituted font. */
--- 808,814 ----
v = NULL;
if (pfont->FontType == ft_CID_encrypted && v == NULL) {
! return_if_error(build_proc_name_refs(&build, ".FAPIBuildGlyph9",
".FAPIBuildGlyph9"));
} else
! return_if_error(build_proc_name_refs(&build, ".FAPIBuildChar",
".FAPIBuildGlyph"));
if (name_index(&pdata->BuildChar) == name_index(&build.BuildChar)) {
/* Already rebuilt - maybe a substituted font. */
***************
*** 865,871 ****
path_interface.olh = &olh;
path_interface.shift = import_shift_v;
! CheckRET(renderer_retcode(i_ctx_p, I, I->get_char_outline(I,
&path_interface)));
if (olh.need_close && olh.close_path)
! CheckRET(add_closepath(&path_interface));
return 0;
}
--- 863,869 ----
path_interface.olh = &olh;
path_interface.shift = import_shift_v;
! return_if_error(renderer_retcode(i_ctx_p, I, I->get_char_outline(I,
&path_interface)));
if (olh.need_close && olh.close_path)
! return_if_error(add_closepath(&path_interface));
return 0;
}
***************
*** 898,902 ****
/* do nothing */
} else if (igs->in_charpath) {
! CheckRET(outline_char(i_ctx_p, I, import_shift_v, penum_s,
pgs->show_gstate->path, !pbfont->PaintType));
} else {
int code = I->get_char_raster(I, &rast);
--- 896,900 ----
/* do nothing */
} else if (igs->in_charpath) {
! return_if_error(outline_char(i_ctx_p, I, import_shift_v, penum_s,
pgs->show_gstate->path, !pbfont->PaintType));
} else {
int code = I->get_char_raster(I, &rast);
***************
*** 905,918 ****
gs_imager_state *pis = (gs_imager_state *)pgs->show_gstate;
gs_point pt;
! CheckRET(gs_currentpoint(pgs->show_gstate, &pt));
! CheckRET(outline_char(i_ctx_p, I, import_shift_v, penum_s,
pgs->show_gstate->path, !pbfont->PaintType));
! CheckRET(gs_imager_setflat(pis, gs_char_flatness(pis, 1.0)));
if (pbfont->PaintType) {
! CheckRET(gs_stroke(pgs->show_gstate));
} else
! CheckRET(gs_fill(pgs->show_gstate));
! CheckRET(gs_moveto(pgs->show_gstate, pt.x, pt.y));
} else {
! CheckRET(renderer_retcode(i_ctx_p, I, code));
if (pgs->in_cachedevice == CACHE_DEVICE_CACHING) { /* Using GS
cache */
/* GS and renderer may transform coordinates few
differently.
--- 903,916 ----
gs_imager_state *pis = (gs_imager_state *)pgs->show_gstate;
gs_point pt;
! return_if_error(gs_currentpoint(pgs->show_gstate, &pt));
! return_if_error(outline_char(i_ctx_p, I, import_shift_v,
penum_s, pgs->show_gstate->path, !pbfont->PaintType));
! return_if_error(gs_imager_setflat(pis, gs_char_flatness(pis,
1.0)));
if (pbfont->PaintType) {
! return_if_error(gs_stroke(pgs->show_gstate));
} else
! return_if_error(gs_fill(pgs->show_gstate));
! return_if_error(gs_moveto(pgs->show_gstate, pt.x, pt.y));
} else {
! return_if_error(renderer_retcode(i_ctx_p, I, code));
if (pgs->in_cachedevice == CACHE_DEVICE_CACHING) { /* Using GS
cache */
/* GS and renderer may transform coordinates few
differently.
***************
*** 926,934 ****
int dx = arith_rshift_slow((pgs->ctm.tx_fixed >> shift_rd)
+ rast.orig_x + rounding, frac_pixel_shift);
int dy = arith_rshift_slow((pgs->ctm.ty_fixed >>
shift_rd) - rast.orig_y + rounding, frac_pixel_shift);
! CheckRET(dev_proc(dev1, copy_mono)(dev1, rast.p, 0,
rast.line_step, 0, dx, dy, rast.width, rast.height, 0, 1));
} else { /* Not using GS cache */
const gx_clip_path * pcpath = i_ctx_p->pgs->clip_path;
const gx_drawing_color * pdcolor = penum->pdcolor;
! CheckRET(dev_proc(dev, fill_mask)(dev, rast.p, 0, rast.line_step,
0,
(int)(penum_s->pgs->ctm.tx + (double)rast.orig_x / (1 <<
frac_pixel_shift) + 0.5),
(int)(penum_s->pgs->ctm.ty - (double)rast.orig_y / (1 <<
frac_pixel_shift) + 0.5),
--- 924,932 ----
int dx = arith_rshift_slow((pgs->ctm.tx_fixed >> shift_rd)
+ rast.orig_x + rounding, frac_pixel_shift);
int dy = arith_rshift_slow((pgs->ctm.ty_fixed >>
shift_rd) - rast.orig_y + rounding, frac_pixel_shift);
! return_if_error(dev_proc(dev1, copy_mono)(dev1, rast.p, 0,
rast.line_step, 0, dx, dy, rast.width, rast.height, 0, 1));
} else { /* Not using GS cache */
const gx_clip_path * pcpath = i_ctx_p->pgs->clip_path;
const gx_drawing_color * pdcolor = penum->pdcolor;
! return_if_error(dev_proc(dev, fill_mask)(dev, rast.p, 0,
rast.line_step, 0,
(int)(penum_s->pgs->ctm.tx + (double)rast.orig_x / (1 <<
frac_pixel_shift) + 0.5),
(int)(penum_s->pgs->ctm.ty - (double)rast.orig_y / (1 <<
frac_pixel_shift) + 0.5),
***************
*** 1040,1044 ****
ff.client_font_data2 = op - 1;
ff.server_font_data = pbfont->FAPI_font_data;
! CheckRET(renderer_retcode(i_ctx_p, I, I->get_scaled_font(I, &ff,
subfont, matrix, HWResolution, NULL, bVertical)));
/* fixme : it would be nice to call get_scaled_font at once for entire
'show' string. */
--- 1038,1042 ----
ff.client_font_data2 = op - 1;
ff.server_font_data = pbfont->FAPI_font_data;
! return_if_error(renderer_retcode(i_ctx_p, I, I->get_scaled_font(I,
&ff, subfont, matrix, HWResolution, NULL, bVertical)));
/* fixme : it would be nice to call get_scaled_font at once for entire
'show' string. */
***************
*** 1054,1058 ****
(r_has_type(Encoding, t_array) || r_has_type(Encoding,
t_shortarray))) {
if (array_get(Encoding, client_char_code, &char_name) < 0)
! CheckRET(name_ref((const byte *)".notdef", 7, &char_name, -1));
} else
return_error(e_invalidfont);
--- 1052,1056 ----
(r_has_type(Encoding, t_array) || r_has_type(Encoding,
t_shortarray))) {
if (array_get(Encoding, client_char_code, &char_name) < 0)
! return_if_error(name_ref((const byte *)".notdef", 7,
&char_name, -1));
} else
return_error(e_invalidfont);
***************
*** 1078,1084 ****
ref rb, re, rs;
int nb, ne, ns;
! CheckRET(array_get(SubstNWP, i + 1, &rb));
! CheckRET(array_get(SubstNWP, i + 2, &re));
! CheckRET(array_get(SubstNWP, i + 3, &rs));
nb = rb.value.intval;
ne = re.value.intval;
--- 1076,1082 ----
ref rb, re, rs;
int nb, ne, ns;
! return_if_error(array_get(SubstNWP, i + 1, &rb));
! return_if_error(array_get(SubstNWP, i + 2, &re));
! return_if_error(array_get(SubstNWP, i + 3, &rs));
nb = rb.value.intval;
ne = re.value.intval;
***************
*** 1101,1105 ****
if (dict_find(CharStrings, &char_name, &glyph_index) < 0) {
cr.char_code = 0; /* .notdef */
! CheckRET(name_ref((const byte *)".notdef", 7,
&char_name, -1));
} else if (r_has_type(glyph_index, t_integer))
cr.char_code = glyph_index->value.intval;
--- 1099,1103 ----
if (dict_find(CharStrings, &char_name, &glyph_index) < 0) {
cr.char_code = 0; /* .notdef */
! return_if_error(name_ref((const byte *)".notdef", 7,
&char_name, -1));
} else if (r_has_type(glyph_index, t_integer))
cr.char_code = glyph_index->value.intval;
***************
*** 1129,1133 ****
bool can_retrieve_char_by_name = false;
obj_string_data(&char_name, &cr.char_name, &cr.char_name_length);
! CheckRET(renderer_retcode(i_ctx_p, I,
I->can_retrieve_char_by_name(I, &ff, &cr, &can_retrieve_char_by_name)));
if (!can_retrieve_char_by_name) {
/* Translate from char name to encoding used with 3d party font
technology : */
--- 1127,1131 ----
bool can_retrieve_char_by_name = false;
obj_string_data(&char_name, &cr.char_name, &cr.char_name_length);
! return_if_error(renderer_retcode(i_ctx_p, I,
I->can_retrieve_char_by_name(I, &ff, &cr, &can_retrieve_char_by_name)));
if (!can_retrieve_char_by_name) {
/* Translate from char name to encoding used with 3d party font
technology : */
***************
*** 1146,1152 ****
ff.client_char_data = &char_name;
if (SHOW_IS(penum, TEXT_DO_NONE)) {
! CheckRET(renderer_retcode(i_ctx_p, I, I->get_char_width(I, &ff, &cr,
&metrics.escapement)));
} else if (igs->in_charpath) {
! CheckRET(renderer_retcode(i_ctx_p, I,
I->get_char_outline_metrics(I, &ff, &cr, &metrics)));
} else {
code = I->get_char_raster_metrics(I, &ff, &cr, &metrics);
--- 1144,1150 ----
ff.client_char_data = &char_name;
if (SHOW_IS(penum, TEXT_DO_NONE)) {
! return_if_error(renderer_retcode(i_ctx_p, I, I->get_char_width(I, &ff,
&cr, &metrics)));
} else if (igs->in_charpath) {
! return_if_error(renderer_retcode(i_ctx_p, I,
I->get_char_outline_metrics(I, &ff, &cr, &metrics)));
} else {
code = I->get_char_raster_metrics(I, &ff, &cr, &metrics);
***************
*** 1157,1168 ****
goto retry_oversampling;
}
! CheckRET(renderer_retcode(i_ctx_p, I,
I->get_char_outline_metrics(I, &ff, &cr, &metrics)));
} else {
! CheckRET(renderer_retcode(i_ctx_p, I, code));
}
}
compute_em_scale(pbfont, &metrics, FontMatrix_div, &em_scale_x,
&em_scale_y);
code = zchar_get_metrics(pbfont, &char_name, sbw);
! CheckRET(code);
if (code == metricsNone) {
if (pbfont->FontType == 2 && font_file_path == NULL) {
--- 1155,1166 ----
goto retry_oversampling;
}
! return_if_error(renderer_retcode(i_ctx_p, I,
I->get_char_outline_metrics(I, &ff, &cr, &metrics)));
} else {
! return_if_error(renderer_retcode(i_ctx_p, I, code));
}
}
compute_em_scale(pbfont, &metrics, FontMatrix_div, &em_scale_x,
&em_scale_y);
code = zchar_get_metrics(pbfont, &char_name, sbw);
! return_if_error(code);
if (code == metricsNone) {
if (pbfont->FontType == 2 && font_file_path == NULL) {
***************
*** 1171,1175 ****
if (dict_find_string(osp - 1, "Private", &Private) <= 0 ||
!r_has_type(Private, t_dictionary))
return_error(e_invalidfont);
! CheckRET(dict_float_param(Private, "nominalWidthX", 0, &v));
sbw[2] = metrics.escapement / em_scale_x + (int)v;
sbw[3] = 0;
--- 1169,1173 ----
if (dict_find_string(osp - 1, "Private", &Private) <= 0 ||
!r_has_type(Private, t_dictionary))
return_error(e_invalidfont);
! return_if_error(dict_float_param(Private, "nominalWidthX", 0,
&v));
sbw[2] = metrics.escapement / em_scale_x + (int)v;
sbw[3] = 0;
***************
*** 1179,1183 ****
}
} else {
! CheckRET(zchar_get_metrics(pbfont, op, sbw));
}
char_bbox.p.x = metrics.bbox_x0 / em_scale_x;
--- 1177,1181 ----
}
} else {
! return_if_error(zchar_get_metrics(pbfont, op, sbw));
}
char_bbox.p.x = metrics.bbox_x0 / em_scale_x;
***************
*** 1229,1233 ****
ref *rFDArray, f;
int font_index;
! CheckRET(ztype9mapcid(i_ctx_p)); /* <font0> <cid> <charstring>
<font_index> */
/* fixme: what happens if the charstring is absent ?
Can FDArray contain 'null' (see %Type9BuildGlyph in gs_cidfn.ps)?
*/
--- 1227,1231 ----
ref *rFDArray, f;
int font_index;
! return_if_error(ztype9mapcid(i_ctx_p)); /* <font0> <cid> <charstring>
<font_index> */
/* fixme: what happens if the charstring is absent ?
Can FDArray contain 'null' (see %Type9BuildGlyph in gs_cidfn.ps)?
*/
***************
*** 1240,1244 ****
op[-2] = op[-1]; /* Keep the charstring on ostack for the garbager. */
op[-1] = f; /* <font0> <charstring> <subfont>
<cid> */
! CheckRET(FAPI_char(i_ctx_p, true, op - 2));
/* <font0> <charstring> */
return 0;
--- 1238,1242 ----
op[-2] = op[-1]; /* Keep the charstring on ostack for the garbager. */
op[-1] = f; /* <font0> <charstring> <subfont>
<cid> */
! return_if_error(FAPI_char(i_ctx_p, true, op - 2));
/* <font0> <charstring> */
return 0;
***************
*** 1299,1303 ****
ref *SubfontId;
FAPI_font ff = ff_stub;
! CheckRET(code);
pbfont = (gs_font_base *)pfont;
if (dict_find_string(pdr, "SubfontId", &SubfontId) > 0 &&
r_has_type(SubfontId, t_integer))
--- 1297,1301 ----
ref *SubfontId;
FAPI_font ff = ff_stub;
! return_if_error(code);
pbfont = (gs_font_base *)pfont;
if (dict_find_string(pdr, "SubfontId", &SubfontId) > 0 &&
r_has_type(SubfontId, t_integer))
***************
*** 1316,1320 ****
continue;
I = (FAPI_server *)h->I;
! CheckRET(renderer_retcode(i_ctx_p, I, I->ensure_open(I)));
HWResolution[0] = HWResolution[1] = 72 << I->frac_shift;
matrix[0] = matrix[3] = 1 << I->frac_shift;
--- 1314,1318 ----
continue;
I = (FAPI_server *)h->I;
! return_if_error(renderer_retcode(i_ctx_p, I, I->ensure_open(I)));
HWResolution[0] = HWResolution[1] = 72 << I->frac_shift;
matrix[0] = matrix[3] = 1 << I->frac_shift;
***************
*** 1336,1341 ****
/* fixme : with CID fonts we need to test something more. */
pbfont->FAPI = I; /* We found a good renderer, so go with it */
! CheckRET(name_ref((const byte *)I->ig.d->subtype,
strlen(I->ig.d->subtype), &FAPI_ID, false));
! CheckRET(dict_put_string(pdr, "FAPI", &FAPI_ID, NULL)); /* Insert FAPI
entry to font dictionary. */
*success = true;
return 0;
--- 1334,1339 ----
/* fixme : with CID fonts we need to test something more. */
pbfont->FAPI = I; /* We found a good renderer, so go with it */
! return_if_error(name_ref((const byte *)I->ig.d->subtype,
strlen(I->ig.d->subtype), &FAPI_ID, false));
! return_if_error(dict_put_string(pdr, "FAPI", &FAPI_ID, NULL)); /* Insert
FAPI entry to font dictionary. */
*success = true;
return 0;
More information about the gs-code-review
mailing list