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

📄 cffgload.c

📁 source code: Covert TXT to PDF
💻 C
📖 第 1 页 / 共 5 页
字号:
              args  += 4;              phase ^= 1;            }            args = stack;          }          break;        case cff_op_rlinecurve:          {            FT_Int  num_lines = ( num_args - 6 ) / 2;            FT_TRACE4(( " rlinecurve" ));            if ( num_args < 8 || ( num_args - 6 ) & 1 )              goto Stack_Underflow;            if ( start_point( builder, x, y )           ||                 check_points( builder, num_lines + 3 ) )              goto Memory_Error;            args = stack;            /* first, add the line segments */            while ( num_lines > 0 )            {              x += args[0];              y += args[1];              add_point( builder, x, y, 1 );              args += 2;              num_lines--;            }            /* then the curve */            x += args[0];            y += args[1];            add_point( builder, x, y, 0 );            x += args[2];            y += args[3];            add_point( builder, x, y, 0 );            x += args[4];            y += args[5];            add_point( builder, x, y, 1 );            args = stack;          }          break;        case cff_op_rcurveline:          {            FT_Int  num_curves = ( num_args - 2 ) / 6;            FT_TRACE4(( " rcurveline" ));            if ( num_args < 8 || ( num_args - 2 ) % 6 )              goto Stack_Underflow;            if ( start_point ( builder, x, y )             ||                 check_points( builder, num_curves*3 + 2 ) )              goto Memory_Error;            args = stack;            /* first, add the curves */            while ( num_curves > 0 )            {              x += args[0];              y += args[1];              add_point( builder, x, y, 0 );              x += args[2];              y += args[3];              add_point( builder, x, y, 0 );              x += args[4];              y += args[5];              add_point( builder, x, y, 1 );              args += 6;              num_curves--;            }            /* then the final line */            x += args[0];            y += args[1];            add_point( builder, x, y, 1 );            args = stack;          }          break;        case cff_op_hflex1:          {            FT_Pos start_y;            FT_TRACE4(( " hflex1" ));            args = stack;            /* adding five more points; 4 control points, 1 on-curve point */            /* make sure we have enough space for the start point if it    */            /* needs to be added..                                         */            if ( start_point( builder, x, y ) ||                 check_points( builder, 6 )   )              goto Memory_Error;            /* Record the starting point's y postion for later use */            start_y = y;            /* first control point */            x += args[0];            y += args[1];            add_point( builder, x, y, 0 );            /* second control point */            x += args[2];            y += args[3];            add_point( builder, x, y, 0 );            /* join point; on curve, with y-value the same as the last */            /* control point's y-value                                 */            x += args[4];            add_point( builder, x, y, 1 );            /* third control point, with y-value the same as the join */            /* point's y-value                                        */            x += args[5];            add_point( builder, x, y, 0 );            /* fourth control point */            x += args[6];            y += args[7];            add_point( builder, x, y, 0 );            /* ending point, with y-value the same as the start   */            x += args[8];            y  = start_y;            add_point( builder, x, y, 1 );            args = stack;            break;          }        case cff_op_hflex:          {            FT_Pos start_y;            FT_TRACE4(( " hflex" ));            args = stack;            /* adding six more points; 4 control points, 2 on-curve points */            if ( start_point( builder, x, y ) ||                 check_points ( builder, 6 )  )              goto Memory_Error;            /* record the starting point's y-position for later use */            start_y = y;            /* first control point */            x += args[0];            add_point( builder, x, y, 0 );            /* second control point */            x += args[1];            y += args[2];            add_point( builder, x, y, 0 );            /* join point; on curve, with y-value the same as the last */            /* control point's y-value                                 */            x += args[3];            add_point( builder, x, y, 1 );            /* third control point, with y-value the same as the join */            /* point's y-value                                        */            x += args[4];            add_point( builder, x, y, 0 );            /* fourth control point */            x += args[5];            y  = start_y;            add_point( builder, x, y, 0 );            /* ending point, with y-value the same as the start point's */            /* y-value -- we don't add this point, though               */            x += args[6];            add_point( builder, x, y, 1 );            args = stack;            break;          }        case cff_op_flex1:          {            FT_Pos  start_x, start_y; /* record start x, y values for alter */                                      /* use                                */            FT_Int  dx = 0, dy = 0;   /* used in horizontal/vertical        */                                      /* algorithm below                    */            FT_Int  horizontal, count;            FT_TRACE4(( " flex1" ));            /* adding six more points; 4 control points, 2 on-curve points */            if ( start_point( builder, x, y ) ||                 check_points( builder, 6 )   )               goto Memory_Error;            /* record the starting point's x, y postion for later use */            start_x = x;            start_y = y;            /* XXX: figure out whether this is supposed to be a horizontal */            /*      or vertical flex; the Type 2 specification is vague... */            args = stack;            /* grab up to the last argument */            for ( count = 5; count > 0; count-- )            {              dx += args[0];              dy += args[1];              args += 2;            }            /* rewind */            args = stack;            if ( dx < 0 ) dx = -dx;            if ( dy < 0 ) dy = -dy;            /* strange test, but here it is... */            horizontal = ( dx > dy );            for ( count = 5; count > 0; count-- )            {              x += args[0];              y += args[1];              add_point( builder, x, y, (FT_Bool)( count == 3 ) );              args += 2;            }            /* is last operand an x- or y-delta? */            if ( horizontal )            {              x += args[0];              y  = start_y;            }            else            {              x  = start_x;              y += args[0];            }            add_point( builder, x, y, 1 );            args = stack;            break;           }        case cff_op_flex:          {            FT_UInt  count;            FT_TRACE4(( " flex" ));            if ( start_point( builder, x, y ) ||                 check_points( builder, 6 )   )              goto Memory_Error;            args = stack;            for ( count = 6; count > 0; count-- )            {              x += args[0];              y += args[1];              add_point( builder, x, y,                         (FT_Bool)( count == 3 || count == 0 ) );              args += 2;            }            args = stack;          }          break;        case cff_op_endchar:          FT_TRACE4(( " endchar" ));          /* We are going to emulate the seac operator. */          if ( num_args == 4 )          {            error = cff_operator_seac( decoder,                                       args[0] >> 16, args[1] >> 16,                                       args[2] >> 16, args[3] >> 16 );            args += 4;          }          if ( !error )            error = CFF_Err_Ok;          close_contour( builder );          /* close hints recording session */          if ( hinter )          {            if (hinter->close( hinter->hints, builder->current->n_points ) )              goto Syntax_Error;            /* apply hints to the loaded glyph outline now */            hinter->apply( hinter->hints,                           builder->current,                           (PSH_Globals)builder->hints_globals );          }          /* add current outline to the glyph slot */          FT_GlyphLoader_Add( builder->loader );          /* return now! */          FT_TRACE4(( "\n\n" ));          return error;        case cff_op_abs:          FT_TRACE4(( " abs" ));          if ( args[0] < 0 )            args[0] = -args[0];          args++;          break;        case cff_op_add:          FT_TRACE4(( " add" ));          args[0] += args[1];          args++;          break;        case cff_op_sub:          FT_TRACE4(( " sub" ));          args[0] -= args[1];          args++;          break;        case cff_op_div:          FT_TRACE4(( " div" ));          args[0] = FT_DivFix( args[0], args[1] );          args++;          break;        case cff_op_neg:          FT_TRACE4(( " neg" ));          args[0] = -args[0];          args++;          break;        case cff_op_random:          {            FT_Fixed  rand;            FT_TRACE4(( " rand" ));            rand = seed;            if ( rand >= 0x8000 )              rand++;            args[0] = rand;            seed    = FT_MulFix( seed, 0x10000L - seed );            if ( seed == 0 )              seed += 0x2873;            args++;          }          break;        case cff_op_mul:          FT_TRACE4(( " mul" ));          args[0] = FT_MulFix( args[0], args[1] );          args++;          break;        case cff_op_sqrt:          FT_TRACE4(( " sqrt" ));          if ( args[0] > 0 )          {            FT_Int    count = 9;            FT_Fixed  root  = args[0];            FT_Fixed  new_root;            for (;;)            {              new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1;              if ( new_root == root || count <= 0 )                break;              root = new_root;            }            args[0] = new_root;          }          else            args[0] = 0;          args++;          break;        case cff_op_drop:          /* nothing */          FT_TRACE4(( " drop" ));          break;        case cff_op_exch:          {            FT_Fixed  tmp;            FT_TRACE4(( " exch" ));            tmp     = args[0];            args[0] = args[1];            args[1] = tmp;            args   += 2;          }          break;        case cff_op_index:          {            FT_Int  index = args[0] >> 16;            FT_TRACE4(( " index" ));            if ( index < 0 )              index = 0;            else if ( index > num_args - 2 )              index = num_args - 2;            args[0] = args[-( index + 1 )];            args++;          }          break;        case cff_op_roll:          {            FT_Int  count = (FT_Int)( args[0] >> 16 );            FT_Int  index = (FT_Int)( args[1] >> 16 );            FT_TRACE4(( " roll" ));            if ( count <= 0 )              count = 1;            args -= count;            if ( args < stack )              goto Stack_Underflow;

⌨️ 快捷键说明

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