⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t1gload.c

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 C
📖 第 1 页 / 共 4 页
字号:
 *********************************************************************/  EXPORT_FUNC  T1_Error   T1_Parse_CharStrings( T1_Decoder*  decoder,                                   T1_Byte*     charstring_base,                                   T1_Int       charstring_len,                                   T1_Int       num_subrs,                                   T1_Byte**    subrs_base,                                   T1_Int*      subrs_len )  {    T1_Error            error;    T1_Decoder_Zone*    zone;    T1_Byte*            ip;    T1_Byte*            limit;    T1_Builder*         builder = &decoder->builder;    T1_Builder_Funcs*   builds  = &builder->funcs;    T1_Hinter_Funcs*    hints   = &decoder->hinter;    static const T1_Int  args_count[ op_max ] =     {      0, /* none */      0, /* endchar */      2, /* hsbw */      5, /* seac */      4, /* sbw */      0, /* closepath */      1, /* hlineto */      1, /* hmoveto */      4, /* hvcurveto */      2, /* rlineto */      2, /* rmoveto */      6, /* rrcurveto */      4, /* vhcurveto */      1, /* vlineto */      1, /* vmoveto */      0, /* dotsection */      2, /* hstem */      6, /* hstem3 */      2, /* vstem */      6, /* vstem3 */      2, /* div */     -1, /* callothersubr */      1, /* callsubr */      0, /* pop */      0, /* return */      2  /* setcurrentpoint */    };    /* First of all, initialise the decoder */    decoder->top  = decoder->stack;    decoder->zone = decoder->zones;    zone          = decoder->zones;    builder->path_begun  = 0;    zone->base           = charstring_base;    limit = zone->limit  = charstring_base + charstring_len;    ip    = zone->cursor = zone->base;    error = T1_Err_Ok;    /* now, execute loop */    while ( ip < limit )    {      T1_Int*      top      = decoder->top;      T1_Operator  op       = op_none;      T1_Long      value    = 0;      /* First of all, decompress operator or value */      switch (*ip++)      {        case 1:  op = op_hstem;     break;        case 3:  op = op_vstem;     break;        case 4:  op = op_vmoveto;   break;        case 5:  op = op_rlineto;   break;        case 6:  op = op_hlineto;   break;        case 7:  op = op_vlineto;   break;        case 8:  op = op_rrcurveto; break;        case 9:  op = op_closepath; break;        case 10: op = op_callsubr;  break;        case 11: op = op_return;    break;        case 13: op = op_hsbw;      break;        case 14: op = op_endchar;   break;        case 21: op = op_rmoveto;   break;        case 22: op = op_hmoveto;   break;        case 30: op = op_vhcurveto; break;        case 31: op = op_hvcurveto; break;        case 12:          {            if (ip > limit)            {              FT_ERROR(( "T1.Parse_CharStrings : invalid escape (12+EOF)\n" ));              goto Syntax_Error;            }            switch (*ip++)            {              case 0:  op = op_dotsection;      break;              case 1:  op = op_vstem3;          break;              case 2:  op = op_hstem3;          break;              case 6:  op = op_seac;            break;              case 7:  op = op_sbw;             break;              case 12: op = op_div;             break;              case 16: op = op_callothersubr;   break;              case 17: op = op_pop;             break;              case 33: op = op_setcurrentpoint; break;              default:                FT_ERROR(( "T1.Parse_CharStrings : invalid escape (12+%d)\n",                         ip[-1] ));                goto Syntax_Error;            }          }          break;        case 255:    /* four bytes integer */          {            if (ip+4 > limit)            {              FT_ERROR(( "T1.Parse_CharStrings : unexpected EOF in integer\n" ));              goto Syntax_Error;            }            value = ((long)ip[0] << 24) |                    ((long)ip[1] << 16) |                    ((long)ip[2] << 8)  |                           ip[3];            ip += 4;          }          break;        default:          if (ip[-1] >= 32)          {            if (ip[-1] < 247)              value = (long)ip[-1] - 139;            else            {              if (++ip > limit)              {                FT_ERROR(( "T1.Parse_CharStrings : unexpected EOF in integer\n" ));                goto Syntax_Error;              }              if (ip[-2] < 251)                value =  ((long)(ip[-2]-247) << 8) + ip[-1] + 108;              else                value = -((((long)ip[-2]-251) << 8) + ip[-1] + 108 );            }          }          else          {            FT_ERROR(( "T1.Parse_CharStrings : invalid byte (%d)\n",                     ip[-1] ));            goto Syntax_Error;          }      }      /* push value if needed */      if ( op == op_none )      {        if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS )        {          FT_ERROR(( "T1.Parse_CharStrings : Stack overflow !!\n" ));          goto Syntax_Error;        }        *top++       = value;        decoder->top = top;      }      else if ( op == op_callothersubr ) /* check arguments differently */      {        if ( top - decoder->stack < 2)          goto Stack_Underflow;        top -= 2;        switch (top[1])        {          case 1:   /* start flex feature ----------------------------- */            {              if (top[0] != 0) goto Unexpected_OtherSubr;              decoder->flex_state        = 1;              decoder->num_flex_vectors  = 0;              decoder->flex_vectors[0].x = 0;              decoder->flex_vectors[0].y = 0;            }            break;          case 2:   /* add flex vector ------------------------------- */            {              T1_Int      index;              T1_Vector*  flex;              if (top[0] != 0) goto Unexpected_OtherSubr;              top -= 2;              if (top < decoder->stack) goto Stack_Underflow;              index = decoder->num_flex_vectors++;              if (index >= 7)              {                FT_ERROR(( "T1.Parse_CharStrings: too many flex vectors !\n" ));                goto Syntax_Error;              }              flex = decoder->flex_vectors + index;              flex->x += top[0];              flex->y += top[1];            }            break;          case 0:   /* end flex feature ------------------------------ */            {              if ( decoder->flex_state       == 0 ||                   decoder->num_flex_vectors != 7 )              {                FT_ERROR(( "T1.Parse_CharStrings: unexpected flex end\n" ));                goto Syntax_Error;              }              if (top[0] != 3) goto Unexpected_OtherSubr;              top -= 3;              if (top < decoder->stack) goto Stack_Underflow;              /* now consume the remaining "pop pop setcurrentpoint" */              if ( ip+6 > limit ||                   ip[0] != 12  || ip[1] != 17 ||   /* pop */                   ip[2] != 12  || ip[3] != 17 ||   /* pop */                   ip[4] != 12  || ip[5] != 33 )    /* setcurrentpoint */              {                FT_ERROR(( "T1.Parse_CharStrings: invalid flex charstring\n" ));                goto Syntax_Error;              }              decoder->flex_state = 0;              decoder->top        = top;              error = t1operator_flex( decoder, top[0], top[1], top[2] );            }            break;          case 3:  /* change hints ------------------------------------ */            {              if (top[0] != 1) goto Unexpected_OtherSubr;              /* eat the following "pop" */              if (ip+2 > limit)              {                FT_ERROR(( "T1.Parse_CharStrings: invalid escape (12+%d)\n",                         ip[-1] ));                goto Syntax_Error;              }              if (ip[0] != 12 || ip[1] != 17)              {                FT_ERROR(( "T1.Parse_CharStrings: 'pop' expected, found (%d %d)\n",                         ip[0], ip[1] ));                goto Syntax_Error;              }              ip    += 2;              error  = hints->change_hints(builder);            }            break;          default:            /* invalid OtherSubrs call */          Unexpected_OtherSubr:            FT_ERROR(( "T1.Parse_CharStrings: unexpected OtherSubrs [%d %d]\n",                     top[0], top[1] ));            goto Syntax_Error;        }        decoder->top = top;      }      else      {        T1_Int  num_args = args_count[op];        if ( top - decoder->stack < num_args )          goto Stack_Underflow;        top -= num_args;        switch (op)        {          case op_endchar:            error = builds->end_char( builder );            break;          case op_hsbw:            error = builds->set_bearing_point( builder, top[0], 0,                                                         top[1], 0 );            break;          case op_seac:            /* return immediately after the processing */            return t1operator_seac( decoder, top[0], top[1],                                             top[2], top[3], top[4] );          case op_sbw:            error = builds->set_bearing_point( builder, top[0], top[1],                                                        top[2], top[3] );            break;          case op_closepath:            error = builds->close_path( builder );            break;          case op_hlineto:            error = builds->rline_to( builder, top[0], 0 );            break;          case op_hmoveto:            error = builds->rmove_to( builder, top[0], 0 );            break;          case op_hvcurveto:            error = builds->rcurve_to( builder, top[0], 0,                                                top[1], top[2],                                                0,      top[3] );            break;          case op_rlineto:            error = builds->rline_to( builder, top[0], top[1] );            break;          case op_rmoveto:            /* ignore operator when in flex mode */            if (decoder->flex_state == 0)              error = builds->rmove_to( builder, top[0], top[1] );            else              top += 2;            break;          case op_rrcurveto:            {              error = builds->rcurve_to( builder, top[0], top[1],                                                  top[2], top[3],                                                  top[4], top[5] );            }            break;          case op_vhcurveto:            error = builds->rcurve_to( builder,      0, top[0],                                                top[1], top[2],                                                top[3],      0 );            break;          case op_vlineto:            error = builds->rline_to( builder, 0, top[0] );            break;          case op_vmoveto:            error = builds->rmove_to( builder, 0, top[0] );            break;          case op_dotsection:            error = hints->dot_section( builder );            break;          case op_hstem:            error = hints->stem( builder, top[0], top[1], 0 );            break;          case op_hstem3:            error = hints->stem3( builder, top[0], top[1], top[2],                                           top[3], top[4], top[5], 0 );            break;          case op_vstem:            error = hints->stem( builder, top[0], top[1], 1 );            break;          case op_vstem3:            error = hints->stem3( builder, top[0], top[1], top[2],                                           top[3], top[4], top[5], 1 );            break;          case op_div:            if (top[1])              *top++ = top[0] / top[1];            else            {              FT_ERROR(( "T1.Parse_CHarStrings : division by 0\n" ));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -