home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Magazine / UsingPDF / GhostScript / source / gs5.10 / zchar1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-12  |  18.4 KB  |  647 lines

  1. /* Copyright (C) 1993, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* zchar1.c */
  20. /* Type 1 character display operator */
  21. #include "ghost.h"
  22. #include "errors.h"
  23. #include "oper.h"
  24. #include "gsstruct.h"
  25. #include "gxfixed.h"
  26. #include "gxmatrix.h"
  27. #include "gxchar.h"        /* for gs_type1_init in gstype1.h */
  28.                 /* (should only be gschar.h) */
  29. #include "gxdevice.h"        /* for gxfont.h */
  30. #include "gxfont.h"
  31. #include "gxfont1.h"
  32. #include "gxtype1.h"
  33. #include "gzstate.h"        /* for path for gs_type1_init */
  34.                 /* (should only be gsstate.h) */
  35. #include "gspaint.h"        /* for gs_fill, gs_stroke */
  36. #include "gspath.h"
  37. #include "estack.h"
  38. #include "ialloc.h"
  39. #include "ichar.h"
  40. #include "icharout.h"
  41. #include "idict.h"
  42. #include "ifont.h"
  43. #include "igstate.h"
  44. #include "store.h"
  45.  
  46. /* Test whether a font is Type 1 compatible. */
  47. #define font_is_type1_compatible(pfont)\
  48.   ((pfont)->FontType == ft_encrypted || (pfont)->FontType == ft_disk_based)
  49.  
  50. /* ---------------- .type1execchar ---------------- */
  51.  
  52. /*
  53.  * This is the workhorse for %Type1BuildChar, %Type1BuildGlyph,
  54.  * CCRun, and CID fonts.  Eventually this will appear in the C API;
  55.  * even now, its normal control path doesn't use any continuations.
  56.  */
  57.  
  58. /*
  59.  * Define the state record for this operator, which must save the metrics
  60.  * separately as well as the Type 1 interpreter state.
  61.  */
  62. typedef struct gs_type1exec_state_s {
  63.   gs_type1_state cis;        /* must be first */
  64.   double sbw[4];
  65.   int /*metrics_present*/ present;
  66.   gs_rect char_bbox;
  67. } gs_type1exec_state;
  68. gs_private_st_suffix_add0(st_gs_type1exec_state, gs_type1exec_state,
  69.   "gs_type1exec_state", gs_type1exec_state_enum_ptrs,
  70.   gs_type1exec_state_reloc_ptrs, st_gs_type1_state);
  71.  
  72. /* Forward references */
  73. private int bbox_continue(P1(os_ptr));
  74. private int nobbox_continue(P1(os_ptr));
  75. private int type1_call_OtherSubr(P3(const gs_type1exec_state *,
  76.                     int (*)(P1(os_ptr)), const ref *));
  77. private int type1_continue_dispatch(P3(gs_type1_state *, const ref *, ref *));
  78. private int type1_callout_dispatch(P2(os_ptr, int (*)(P1(os_ptr))));
  79. private int op_type1_cleanup(P1(os_ptr));
  80. private void op_type1_free(P1(os_ptr));
  81. private void
  82.   type1_cis_get_metrics(P2(const gs_type1_state *pcis, double psbw[4]));
  83. private int bbox_getsbw_continue(P1(os_ptr));
  84. private int type1exec_bbox(P3(os_ptr, gs_type1exec_state *, gs_font *));
  85. private int bbox_fill(P1(os_ptr));
  86. private int bbox_stroke(P1(os_ptr));
  87. private int nobbox_finish(P2(os_ptr, gs_type1exec_state *));
  88. private int nobbox_fill(P1(os_ptr));
  89. private int nobbox_stroke(P1(os_ptr));
  90. private int
  91.  
  92. /* <font> <code|name> <name> <charstring> .type1execchar - */
  93. ztype1execchar(register os_ptr op)
  94. {    gs_font *pfont;
  95. #define pbfont ((gs_font_base *)pfont)
  96. #define pfont1 ((gs_font_type1 *)pfont)
  97.     const gs_type1_data *pdata;
  98.     int code = font_param(op - 3, &pfont);
  99.     gs_show_enum *penum = op_show_find();
  100.     gs_type1exec_state cxs;
  101. #define pcis (&cxs.cis)
  102.  
  103.     if ( code < 0 )
  104.       return code;
  105.     if ( penum == 0 || !font_is_type1_compatible(pfont) )
  106.       return_error(e_undefined);
  107.     pdata = &pfont1->data;
  108.     /*
  109.      * Any reasonable implementation would execute something like
  110.      *    1 setmiterlimit 0 setlinejoin 0 setlinecap
  111.      * here, but apparently the Adobe implementations aren't reasonable.
  112.      *
  113.      * If this is a stroked font, set the stroke width.
  114.      */
  115.     if ( pfont->PaintType )
  116.       gs_setlinewidth(igs, pfont->StrokeWidth);
  117.     check_estack(3);    /* for continuations */
  118.     /*
  119.      * Execute the definition of the character.
  120.      */
  121.     if ( r_is_proc(op) )
  122.       return zchar_exec_char_proc(op);
  123.     /*
  124.      * The definition must be a Type 1 CharString.
  125.      * Note that we do not require read access: this is deliberate.
  126.      */
  127.     check_type(*op, t_string);
  128.     if ( r_size(op) <= max(pdata->lenIV, 0) )
  129.       return_error(e_invalidfont);
  130.     /*
  131.      * In order to make character oversampling work, we must
  132.      * set up the cache before calling .type1addpath.
  133.      * To do this, we must get the bounding box from the FontBBox,
  134.      * and the width from the CharString or the Metrics.
  135.      * If the FontBBox isn't valid, we can't do any of this.
  136.      */
  137.     code = zchar_get_metrics(pbfont, op - 1, cxs.sbw);
  138.     if ( code < 0 )
  139.       return code;
  140.     cxs.present = code;
  141.     /* Establish a current point. */
  142.     code = gs_moveto(igs, 0.0, 0.0);
  143.     if ( code < 0 )
  144.       return code;
  145.     code = gs_type1_init(pcis, penum, NULL,
  146.                  gs_show_in_charpath(penum) != cpm_show,
  147.                  pfont1->PaintType, pfont1);
  148.     if ( code < 0 )
  149.       return code;
  150.     if ( pfont1->FontBBox.q.x > pfont1->FontBBox.p.x &&
  151.          pfont1->FontBBox.q.y > pfont1->FontBBox.p.y
  152.        )
  153.       {    /* The FontBBox is valid. */
  154.         cxs.char_bbox = pfont1->FontBBox;
  155.         return type1exec_bbox(op, &cxs, pfont);
  156.       }
  157.     else
  158.       {    /*
  159.          * The FontBBox is not valid.  In this case,
  160.          * we create the path first, then do the setcachedevice.
  161.          * If we are oversampling (in this case, only for anti-
  162.          * aliasing, not just to improve quality), we have to
  163.          * create the path twice, since we can't know the
  164.          * oversampling factor until after setcachedevice.
  165.          */
  166.         const ref *opstr = op;
  167.         ref other_subr;
  168.  
  169.         if ( cxs.present == metricsSideBearingAndWidth )
  170.         {    gs_point sbpt;
  171.             sbpt.x = cxs.sbw[0], sbpt.y = cxs.sbw[1];
  172.             gs_type1_set_lsb(pcis, &sbpt);
  173.         }
  174.         /* Continue interpreting. */
  175. icont:        code = type1_continue_dispatch(pcis, opstr, &other_subr);
  176.         switch ( code )
  177.           {
  178.           case 0:            /* all done */
  179.             return nobbox_finish(op, &cxs);
  180.           default:            /* code < 0, error */
  181.             return code;
  182.           case type1_result_callothersubr:    /* unknown OtherSubr */
  183.             return type1_call_OtherSubr(&cxs, nobbox_continue,
  184.                         &other_subr);
  185.           case type1_result_sbw:    /* [h]sbw, just continue */
  186.             if ( cxs.present != metricsSideBearingAndWidth )
  187.               type1_cis_get_metrics(pcis, cxs.sbw);
  188.             opstr = 0;
  189.             goto icont;
  190.           }
  191.       }
  192. #undef pcis
  193. #undef pfont1
  194. #undef pbfont
  195. }
  196. /* Do all the work for the case where we have a bounding box. */
  197. private int
  198. type1exec_bbox(os_ptr op, gs_type1exec_state *pcxs, gs_font *pfont)
  199. {
  200. #define pcis (&pcxs->cis)
  201. #define pbfont ((gs_font_base *)pfont)
  202.     /*
  203.      * We have a valid bounding box.  If we don't have Metrics
  204.      * for this character, start interpreting the CharString;
  205.      * do the setcachedevice as soon as we know the
  206.      * (side bearing and) width.
  207.      */
  208.     if ( pcxs->present == metricsNone )
  209.     {    /* Get the width from the CharString, */
  210.         /* then set the cache device. */
  211.         ref cnref;
  212.         ref other_subr;
  213.         int code;
  214.  
  215.         /* Since an OtherSubr callout might change osp, */
  216.         /* save the character name now. */
  217.         ref_assign(&cnref, op - 1);
  218.         code = type1_continue_dispatch(pcis, op, &other_subr);
  219.         switch ( code )
  220.           {
  221.           default:        /* code < 0 or done, error */
  222.             return((code < 0 ? code :
  223.                 gs_note_error(e_invalidfont)));
  224.           case type1_result_callothersubr:    /* unknown OtherSubr */
  225.             return type1_call_OtherSubr(pcxs,
  226.                         bbox_getsbw_continue,
  227.                         &other_subr);
  228.           case type1_result_sbw:    /* [h]sbw, done */
  229.             break;
  230.           }
  231.         type1_cis_get_metrics(pcis, pcxs->sbw);
  232.         return zchar_set_cache(osp, pbfont, &cnref,
  233.                        NULL, pcxs->sbw + 2,
  234.                        &pcxs->char_bbox,
  235.                        bbox_fill, bbox_stroke);
  236.     }
  237.     else
  238.     {    /* We have the width and bounding box: */
  239.         /* set up the cache device now. */
  240.         return zchar_set_cache(op, pbfont, op - 1,
  241.                        (pcxs->present ==
  242.                     metricsSideBearingAndWidth ?
  243.                     pcxs->sbw : NULL),
  244.                        pcxs->sbw + 2,
  245.                        &pcxs->char_bbox,
  246.                        bbox_fill, bbox_stroke);
  247.     }
  248. #undef pcis
  249. #undef pbfont
  250. }
  251.  
  252.  
  253. /* Handle the results of gs_type1_interpret. */
  254. /* pcref points to a t_string ref. */
  255. private int
  256. type1_continue_dispatch(gs_type1_state *pcis, const ref *pcref, ref *pos)
  257. {    int value;
  258.     int code;
  259.     gs_const_string charstring;
  260.     gs_const_string *pchars;
  261.  
  262.     if ( pcref == 0 )
  263.       {    pchars = 0;
  264.       }
  265.     else
  266.       {    charstring.data = pcref->value.const_bytes;
  267.         charstring.size = r_size(pcref);
  268.         pchars = &charstring;
  269.       }
  270.     code = gs_type1_interpret(pcis, pchars, &value);
  271.     switch ( code )
  272.     {
  273.     case type1_result_callothersubr:
  274.     {    /* The Type 1 interpreter handles all known OtherSubrs, */
  275.         /* so this must be an unknown one. */
  276.         const font_data *pfdata = pfont_data(gs_currentfont(igs));
  277.  
  278.         code = array_get(&pfdata->u.type1.OtherSubrs,
  279.                  (long)value, pos);
  280.         return (code < 0 ? code : type1_result_callothersubr);
  281.     }
  282.     }
  283.     return code;
  284. }
  285.  
  286. /* Do a callout to an OtherSubr implemented in PostScript. */
  287. /* The caller must have done a check_estack(4). */
  288. private int
  289. type1_call_OtherSubr(const gs_type1exec_state *pcxs, int (*cont)(P1(os_ptr)),
  290.   const ref *pos)
  291. {    /* Move the Type 1 interpreter state to the heap. */
  292.     gs_type1exec_state *hpcxs = ialloc_struct(gs_type1exec_state,
  293.                           &st_gs_type1exec_state,
  294.                           "type1_call_OtherSubr");
  295.  
  296.     if ( hpcxs == 0 )
  297.       return_error(e_VMerror);
  298.     *hpcxs = *pcxs;
  299.     push_mark_estack(es_show, op_type1_cleanup);
  300.     ++esp;
  301.     make_istruct(esp, 0, hpcxs);
  302.     push_op_estack(cont);
  303.     ++esp;
  304.     *esp = *pos;
  305.     return o_push_estack;
  306. }
  307.  
  308. /* Continue from an OtherSubr callout while getting metrics. */
  309. private int
  310. bbox_getsbw_continue(os_ptr op)
  311. {    ref other_subr;
  312.     gs_type1exec_state *pcxs = r_ptr(esp, gs_type1exec_state);
  313. #define pcis (&pcxs->cis)
  314.     int code;
  315.  
  316.     code = type1_continue_dispatch(pcis, NULL, &other_subr);
  317.     op = osp;        /* in case z1_push/pop_proc was called */
  318.     switch ( code )
  319.     {
  320.     default:        /* code < 0 or done, error */
  321.         op_type1_free(op);
  322.         return((code < 0 ? code : gs_note_error(e_invalidfont)));
  323.     case type1_result_callothersubr:    /* unknown OtherSubr */
  324.         push_op_estack(bbox_getsbw_continue);
  325.         ++esp;
  326.         *esp = other_subr;
  327.         return o_push_estack;
  328.     case type1_result_sbw:            /* [h]sbw, done */
  329.       {    double sbw[4];
  330.         const gs_font_base *pbfont =
  331.           (const gs_font_base *)pcis->pfont;
  332.         gs_rect bbox;
  333.  
  334.         /* Get the metrics before freeing the state. */
  335.         type1_cis_get_metrics(pcis, sbw);
  336.         bbox = pcxs->char_bbox;
  337.         op_type1_free(op);
  338.         return zchar_set_cache(op, pbfont, op, sbw, sbw + 2, &bbox,
  339.                        bbox_fill, bbox_stroke);
  340.       }
  341.     }
  342. #undef pcis
  343. }
  344.  
  345. /* <font> <code|name> <name> <charstring> <sbx> <sby> %bbox_{fill|stroke} - */
  346. /* <font> <code|name> <name> <charstring> %bbox_{fill|stroke} - */
  347. private int bbox_finish(P2(os_ptr, int (*)(P1(os_ptr))));
  348. private int
  349. bbox_fill(os_ptr op)
  350. {    return bbox_finish(op, nobbox_fill);
  351. }
  352. private int
  353. bbox_stroke(os_ptr op)
  354. {    return bbox_finish(op, nobbox_stroke);
  355. }
  356. private int
  357. bbox_finish(os_ptr op, int (*cont)(P1(os_ptr)))
  358. {    gs_font *pfont;
  359. #define pfont1 ((gs_font_type1 *)pfont)
  360.     int code;
  361.     gs_show_enum *penum = op_show_find();
  362.     gs_type1exec_state cxs;        /* stack allocate to avoid sandbars */
  363. #define pcis (&cxs.cis)
  364.     double sbxy[2];
  365.     gs_point sbpt;
  366.     gs_point *psbpt = 0;
  367.     os_ptr opc = op;
  368.     const ref *opstr;
  369.     ref other_subr;
  370.  
  371.     if ( !r_has_type(opc, t_string) )
  372.       {    check_op(3);
  373.         code = num_params(op, 2, sbxy);
  374.         if ( code < 0 )
  375.           return code;
  376.         sbpt.x = sbxy[0];
  377.         sbpt.y = sbxy[1];
  378.         psbpt = &sbpt;
  379.         opc -= 2;
  380.         check_type(*opc, t_string);
  381.       }
  382.     code = font_param(opc - 3, &pfont);
  383.     if ( code < 0 )
  384.       return code;
  385.     if ( penum == 0 || !font_is_type1_compatible(pfont) )
  386.       return_error(e_undefined);
  387.     { int lenIV = pfont1->data.lenIV;
  388.  
  389.       if ( lenIV > 0 && r_size(opc) <= lenIV )
  390.         return_error(e_invalidfont);
  391.     }
  392.     check_estack(5);    /* in case we need to do a callout */
  393.     code = gs_type1_init(pcis, penum, psbpt,
  394.                  gs_show_in_charpath(penum) != cpm_show,
  395.                  pfont1->PaintType, pfont1);
  396.     if ( code < 0 )
  397.       return code;
  398.     opstr = opc;
  399. icont:    code = type1_continue_dispatch(pcis, opstr, &other_subr);
  400.     switch ( code )
  401.     {
  402.     case 0:            /* all done */
  403.         /* Call the continuation now. */
  404.         if ( psbpt )
  405.           pop(2);
  406.         return (*cont)(osp);
  407.     case type1_result_callothersubr:    /* unknown OtherSubr */
  408.         push_op_estack(cont);        /* call later */
  409.         return type1_call_OtherSubr(&cxs, bbox_continue,
  410.                         &other_subr);
  411.     case type1_result_sbw:            /* [h]sbw, just continue */
  412.         opstr = 0;
  413.         goto icont;
  414.     default:        /* code < 0, error */
  415.         return code;
  416.     }
  417. #undef pfont1
  418. #undef pcis
  419. }
  420.  
  421. /* Continue from an OtherSubr callout while building the path. */
  422. private int
  423. type1_callout_dispatch(os_ptr op, int (*cont)(P1(os_ptr)))
  424. {    ref other_subr;
  425.     gs_type1exec_state *pcxs = r_ptr(esp, gs_type1exec_state);
  426. #define pcis (&pcxs->cis)
  427.     int code;
  428.  
  429. icont:    code = type1_continue_dispatch(pcis, NULL, &other_subr);
  430.     op = osp;        /* in case z1_push/pop_proc was called */
  431.     switch ( code )
  432.     {
  433.     case 0:            /* callout done, cont is on e-stack */
  434.         return 0;
  435.     default:        /* code < 0 or done, error */
  436.         op_type1_free(op);
  437.         return((code < 0 ? code : gs_note_error(e_invalidfont)));
  438.     case type1_result_callothersubr:    /* unknown OtherSubr */
  439.         push_op_estack(cont);
  440.         ++esp;
  441.         *esp = other_subr;
  442.         return o_push_estack;
  443.     case type1_result_sbw:            /* [h]sbw, just continue */
  444.         goto icont;
  445.     }
  446. #undef pcis
  447. }
  448. private int
  449. bbox_continue(os_ptr op)
  450. {    int code = type1_callout_dispatch(op, bbox_continue);
  451.  
  452.     if ( code == 0 )
  453.       {    /* Assume the OtherSubr(s) didn't mess with the o-stack.... */
  454.         int npop = (r_has_type(op, t_string) ? 4 : 6);
  455.  
  456.         pop(npop);  op -= npop;
  457.         op_type1_free(op);
  458.       }
  459.     return code;
  460. }
  461. private int
  462. nobbox_continue(os_ptr op)
  463. {    int code = type1_callout_dispatch(op, nobbox_continue);
  464.  
  465.     if ( code )
  466.       return code;
  467.     { gs_type1exec_state cxs;
  468.       gs_type1exec_state *pcxs = r_ptr(esp, gs_type1exec_state);
  469.  
  470.       cxs = *pcxs;
  471.       op_type1_free(op);
  472.       return nobbox_finish(op, &cxs);
  473.     }
  474. }
  475.  
  476. /* Clean up after a Type 1 callout. */
  477. private int
  478. op_type1_cleanup(os_ptr op)
  479. {    ifree_object(r_ptr(esp + 2, void), "op_type1_cleanup");
  480.     return 0;
  481. }
  482. private void
  483. op_type1_free(os_ptr op)
  484. {    ifree_object(r_ptr(esp, void), "op_type1_free");
  485.     /*
  486.      * In order to avoid popping from the e-stack and then pushing onto
  487.      * it, which would violate an interpreter invariant, we simply
  488.      * overwrite the two e-stack items being discarded (hpcxs and the
  489.      * cleanup operator) with empty procedures.
  490.      */
  491.     make_empty_const_array(esp - 1, a_readonly + a_executable);
  492.     make_empty_const_array(esp, a_readonly + a_executable);
  493. }
  494.  
  495. /* Finish the no-FontBBox case after constructing the path. */
  496. /* If we are oversampling for anti-aliasing, we have to go around again. */
  497. /* <font> <code|name> <name> <charstring> %nobbox_continue - */
  498. private int
  499. nobbox_finish(os_ptr op, gs_type1exec_state *pcxs)
  500. {    int code;
  501.     gs_show_enum *penum = op_show_find();
  502.     gs_font *pfont;
  503. #define pbfont ((gs_font_base *)pfont)
  504. #define pfont1 ((gs_font_type1 *)pfont)
  505.  
  506.     if ( (code = gs_pathbbox(igs, &pcxs->char_bbox)) < 0 ||
  507.          (code = font_param(op - 3, &pfont)) < 0
  508.        )
  509.       return code;
  510.     if ( penum == 0 || !font_is_type1_compatible(pfont) )
  511.       return_error(e_undefined);
  512.     if ( pcxs->present == metricsNone )
  513.     {    gs_point endpt;
  514.         if ( (code = gs_currentpoint(igs, &endpt)) < 0 )
  515.           return code;
  516.         pcxs->sbw[2] = endpt.x, pcxs->sbw[3] = endpt.y;
  517.         pcxs->present = metricsSideBearingAndWidth;
  518.     }
  519.     /*
  520.      * We only need to rebuild the path from scratch if we might
  521.      * oversample for anti-aliasing.
  522.      */
  523.     if ( (*dev_proc(igs->device, get_alpha_bits))
  524.            (igs->device, go_text) > 1
  525.        )
  526.       { gs_newpath(igs);
  527.         gs_moveto(igs, 0.0, 0.0);
  528.         code = gs_type1_init(&pcxs->cis, penum, NULL,
  529.                  gs_show_in_charpath(penum) != cpm_show,
  530.                  pfont1->PaintType, pfont1);
  531.         if ( code < 0 )
  532.           return code;
  533.         return type1exec_bbox(op, pcxs, pfont);
  534.       }
  535.     return zchar_set_cache(op, pbfont, op, NULL, pcxs->sbw + 2,
  536.                    &pcxs->char_bbox,
  537.                    nobbox_fill, nobbox_stroke);
  538. #undef pbfont
  539. }
  540. /* Finish by popping the operands and filling or stroking. */
  541. private int
  542. nobbox_fill(os_ptr op)
  543. {    pop(4);
  544.     /*
  545.      * Properly designed fonts, which have no self-intersecting outlines
  546.      * and in which outer and inner outlines are drawn in opposite
  547.      * directions, aren't affected by choice of filling rule; but some
  548.      * badly designed fonts in the Genoa test suite seem to require
  549.      * using the even-odd rule to match Adobe interpreters.
  550.      */
  551.     return gs_eofill(igs);
  552. }
  553. private int
  554. nobbox_stroke(os_ptr op)
  555. {    pop(4);
  556.     return gs_stroke(igs);
  557. }
  558.  
  559. /* ------ Internal procedures ------ */
  560.  
  561. /* Get the metrics (l.s.b. and width) from the Type 1 interpreter. */
  562. private void
  563. type1_cis_get_metrics(const gs_type1_state *pcis, double psbw[4])
  564. {    psbw[0] = fixed2float(pcis->lsb.x);
  565.     psbw[1] = fixed2float(pcis->lsb.y);
  566.     psbw[2] = fixed2float(pcis->width.x);
  567.     psbw[3] = fixed2float(pcis->width.y);
  568. }
  569.  
  570. /* ------ Initialization procedure ------ */
  571.  
  572. BEGIN_OP_DEFS(zchar1_op_defs) {
  573.     {"4.type1execchar", ztype1execchar},
  574.         /* Internal operators */
  575.     {"4%nobbox_continue", nobbox_continue},
  576.     {"4%nobbox_fill", nobbox_fill},
  577.     {"4%nobbox_stroke", nobbox_stroke},
  578.     {"4%bbox_getsbw_continue", bbox_getsbw_continue},
  579.     {"4%bbox_continue", bbox_continue},
  580.     {"4%bbox_fill", bbox_fill},
  581.     {"4%bbox_stroke", bbox_stroke},
  582. END_OP_DEFS(0) }
  583.  
  584. /* ------ Auxiliary procedures for type 1 fonts ------ */
  585.  
  586. /* These are exported for zfont1.c. */
  587.  
  588. int
  589. z1_subr_proc(gs_font_type1 *pfont, int index, bool global,
  590.   gs_const_string *pstr)
  591. {    const font_data *pfdata = pfont_data(pfont);
  592.     ref subr;
  593.     int code;
  594.  
  595.     code = array_get((global ? &pfdata->u.type1.GlobalSubrs :
  596.               &pfdata->u.type1.Subrs),
  597.              index, &subr);
  598.     if ( code < 0 )
  599.       return code;
  600.     check_type_only(subr, t_string);
  601.     pstr->data = subr.value.const_bytes;
  602.     pstr->size = r_size(&subr);
  603.     return 0;
  604. }
  605.  
  606. int
  607. z1_seac_proc(gs_font_type1 *pfont, int index, gs_const_string *pstr)
  608. {    const font_data *pfdata = pfont_data(pfont);
  609.     ref *pcstr;
  610.     ref enc_entry;
  611.     int code = array_get(&StandardEncoding, (long)index, &enc_entry);
  612.  
  613.     if ( code < 0 )
  614.       return code;
  615.     if ( dict_find(&pfdata->CharStrings, &enc_entry, &pcstr) <= 0 )
  616.       return_error(e_undefined);
  617.     check_type_only(*pcstr, t_string);
  618.     pstr->data = pcstr->value.const_bytes;
  619.     pstr->size = r_size(pcstr);
  620.     return 0;
  621. }
  622.  
  623. int
  624. z1_push_proc(gs_font_type1 *ignore, const fixed *pf, int count)
  625. {    const fixed *p = pf + count - 1;
  626.     int i;
  627.  
  628.     check_ostack(count);
  629.     for ( i = 0; i < count; i++, p-- )
  630.       {    osp++;
  631.         make_real(osp, fixed2float(*p));
  632.       }
  633.     return 0;
  634. }
  635.  
  636. int
  637. z1_pop_proc(gs_font_type1 *ignore, fixed *pf)
  638. {    double val;
  639.     int code = real_param(osp, &val);
  640.  
  641.     if ( code < 0 )
  642.       return code;
  643.     *pf = float2fixed(val);
  644.     osp--;
  645.     return 0;
  646. }
  647.