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

📄 psobjs.c

📁 一个Xpdf应用的例子
💻 C
📖 第 1 页 / 共 3 页
字号:
      default:        /* an error occured */        goto Fail;      }    }#if 0  /* obsolete - keep for reference */    if ( pflags )      *pflags |= 1L << field->flag_bit;#else    FT_UNUSED( pflags );#endif    error = PSaux_Err_Ok;  Exit:    return error;  Fail:    error = PSaux_Err_Invalid_File_Format;    goto Exit;  }#define T1_MAX_TABLE_ELEMENTS  32  FT_LOCAL_DEF FT_Error  T1_Load_Field_Table( T1_Parser*       parser,                       const T1_Field*  field,                       void**           objects,                       FT_UInt          max_objects,                       FT_ULong*        pflags )  {    T1_Token   elements[T1_MAX_TABLE_ELEMENTS];    T1_Token*  token;    FT_Int     num_elements;    FT_Error   error = 0;    FT_Byte*   old_cursor;    FT_Byte*   old_limit;    T1_Field   fieldrec = *(T1_Field*)field;#if 1    fieldrec.type = t1_field_integer;    if ( field->type == t1_field_fixed_array )      fieldrec.type = t1_field_fixed;#endif    T1_ToTokenArray( parser, elements, 32, &num_elements );    if ( num_elements < 0 )      goto Fail;    if ( num_elements > T1_MAX_TABLE_ELEMENTS )      num_elements = T1_MAX_TABLE_ELEMENTS;    old_cursor = parser->cursor;    old_limit  = parser->limit;    /* we store the elements count */    *(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) =      (FT_Byte)num_elements;    /* we now load each element, adjusting the field.offset on each one */    token = elements;    for ( ; num_elements > 0; num_elements--, token++ )    {      parser->cursor = token->start;      parser->limit  = token->limit;      T1_Load_Field( parser, &fieldrec, objects, max_objects, 0 );      fieldrec.offset += fieldrec.size;    }#if 0  /* obsolete -- keep for reference */    if ( pflags )      *pflags |= 1L << field->flag_bit;#else    FT_UNUSED( pflags );#endif    parser->cursor = old_cursor;    parser->limit  = old_limit;  Exit:    return error;  Fail:    error = PSaux_Err_Invalid_File_Format;    goto Exit;  }  FT_LOCAL_DEF FT_Long  T1_ToInt( T1_Parser*  parser )  {    return t1_toint( &parser->cursor, parser->limit );  }  FT_LOCAL_DEF FT_Fixed  T1_ToFixed( T1_Parser*  parser,              FT_Int      power_ten )  {    return t1_tofixed( &parser->cursor, parser->limit, power_ten );  }  FT_LOCAL_DEF FT_Int  T1_ToCoordArray( T1_Parser*  parser,                   FT_Int      max_coords,                   FT_Short*   coords )  {    return t1_tocoordarray( &parser->cursor, parser->limit,                            max_coords, coords );  }  FT_LOCAL_DEF FT_Int  T1_ToFixedArray( T1_Parser*  parser,                   FT_Int      max_values,                   FT_Fixed*   values,                   FT_Int      power_ten )  {    return t1_tofixedarray( &parser->cursor, parser->limit,                            max_values, values, power_ten );  }#if 0  FT_LOCAL_DEF FT_String*  T1_ToString( T1_Parser*  parser )  {    return t1_tostring( &parser->cursor, parser->limit, parser->memory );  }  FT_LOCAL_DEF FT_Bool  T1_ToBool( T1_Parser*  parser )  {    return t1_tobool( &parser->cursor, parser->limit );  }#endif /* 0 */  FT_LOCAL_DEF void  T1_Init_Parser( T1_Parser*  parser,                  FT_Byte*    base,                  FT_Byte*    limit,                  FT_Memory   memory )  {    parser->error  = 0;    parser->base   = base;    parser->limit  = limit;    parser->cursor = base;    parser->memory = memory;    parser->funcs  = t1_parser_funcs;  }  FT_LOCAL_DEF void  T1_Done_Parser( T1_Parser*  parser )  {    FT_UNUSED( parser );  }  /*************************************************************************/  /*************************************************************************/  /*****                                                               *****/  /*****                            T1 BUILDER                         *****/  /*****                                                               *****/  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    T1_Builder_Init                                                    */  /*                                                                       */  /* <Description>                                                         */  /*    Initializes a given glyph builder.                                 */  /*                                                                       */  /* <InOut>                                                               */  /*    builder :: A pointer to the glyph builder to initialize.           */  /*                                                                       */  /* <Input>                                                               */  /*    face    :: The current face object.                                */  /*                                                                       */  /*    size    :: The current size object.                                */  /*                                                                       */  /*    glyph   :: The current glyph object.                               */  /*                                                                       */  FT_LOCAL_DEF void  T1_Builder_Init( T1_Builder*   builder,                   FT_Face       face,                   FT_Size       size,                   FT_GlyphSlot  glyph,                   FT_Bool       hinting )  {    builder->path_begun  = 0;    builder->load_points = 1;    builder->face   = face;    builder->glyph  = glyph;    builder->memory = face->memory;    if ( glyph )    {      FT_GlyphLoader*  loader = glyph->internal->loader;      builder->loader  = loader;      builder->base    = &loader->base.outline;      builder->current = &loader->current.outline;      FT_GlyphLoader_Rewind( loader );      builder->hints_globals = size->internal;      builder->hints_funcs   = 0;                  if ( hinting )        builder->hints_funcs = glyph->internal->glyph_hints;    }    if ( size )    {      builder->scale_x = size->metrics.x_scale;      builder->scale_y = size->metrics.y_scale;    }    builder->pos_x = 0;    builder->pos_y = 0;    builder->left_bearing.x = 0;    builder->left_bearing.y = 0;    builder->advance.x      = 0;    builder->advance.y      = 0;    builder->funcs = t1_builder_funcs;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    T1_Builder_Done                                                    */  /*                                                                       */  /* <Description>                                                         */  /*    Finalizes a given glyph builder.  Its contents can still be used   */  /*    after the call, but the function saves important information       */  /*    within the corresponding glyph slot.                               */  /*                                                                       */  /* <Input>                                                               */  /*    builder :: A pointer to the glyph builder to finalize.             */  /*                                                                       */  FT_LOCAL_DEF void  T1_Builder_Done( T1_Builder*  builder )  {    FT_GlyphSlot  glyph = builder->glyph;    if ( glyph )      glyph->outline = *builder->base;  }  /* check that there is enough room for `count' more points */  FT_LOCAL_DEF FT_Error  T1_Builder_Check_Points( T1_Builder*  builder,                           FT_Int       count )  {    return FT_GlyphLoader_Check_Points( builder->loader, count, 0 );  }  /* add a new point, do not check space */  FT_LOCAL_DEF void  T1_Builder_Add_Point( T1_Builder*  builder,                        FT_Pos       x,                        FT_Pos       y,                        FT_Byte      flag )  {    FT_Outline*  outline = builder->current;    if ( builder->load_points )    {      FT_Vector*  point   = outline->points + outline->n_points;      FT_Byte*    control = (FT_Byte*)outline->tags + outline->n_points;      if ( builder->shift )      {        x >>= 16;        y >>= 16;      }      point->x = x;      point->y = y;      *control = (FT_Byte)( flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic );      builder->last = *point;    }    outline->n_points++;  }  /* check space for a new on-curve point, then add it */  FT_LOCAL_DEF FT_Error  T1_Builder_Add_Point1( T1_Builder*  builder,                         FT_Pos       x,                         FT_Pos       y )  {    FT_Error  error;    error = T1_Builder_Check_Points( builder, 1 );    if ( !error )      T1_Builder_Add_Point( builder, x, y, 1 );    return error;  }  /* check room for a new contour, then add it */  FT_LOCAL_DEF FT_Error  T1_Builder_Add_Contour( T1_Builder*  builder )  {    FT_Outline*  outline = builder->current;    FT_Error     error;    if ( !builder->load_points )    {      outline->n_contours++;      return PSaux_Err_Ok;    }    error = FT_GlyphLoader_Check_Points( builder->loader, 0, 1 );    if ( !error )    {      if ( outline->n_contours > 0 )        outline->contours[outline->n_contours - 1] =          (short)( outline->n_points - 1 );      outline->n_contours++;    }    return error;  }  /* if a path was begun, add its first on-curve point */  FT_LOCAL_DEF FT_Error  T1_Builder_Start_Point( T1_Builder*  builder,                          FT_Pos       x,                          FT_Pos       y )  {    FT_Error  error = 0;    /* test whether we are building a new contour */    if ( !builder->path_begun )    {      builder->path_begun = 1;      error = T1_Builder_Add_Contour( builder );      if ( !error )        error = T1_Builder_Add_Point1( builder, x, y );    }    return error;  }  /* close the current contour */  FT_LOCAL_DEF void  T1_Builder_Close_Contour( T1_Builder*  builder )  {    FT_Outline*  outline = builder->current;    /* XXXX: We must not include the last point in the path if it */    /*       is located on the first point.                       */    if ( outline->n_points > 1 )    {      FT_Int      first   = 0;      FT_Vector*  p1      = outline->points + first;      FT_Vector*  p2      = outline->points + outline->n_points - 1;      FT_Byte*    control = (FT_Byte*)outline->tags + outline->n_points - 1;      if ( outline->n_contours > 1 )      {        first = outline->contours[outline->n_contours - 2] + 1;        p1    = outline->points + first;      }      /* `delete' last point only if it coincides with the first */      /* point and it is not a control point (which can happen). */      if ( p1->x == p2->x && p1->y == p2->y )        if ( *control == FT_Curve_Tag_On )          outline->n_points--;    }    if ( outline->n_contours > 0 )      outline->contours[outline->n_contours - 1] =        (short)( outline->n_points - 1 );  }  /*************************************************************************/  /*************************************************************************/  /*****                                                               *****/  /*****                            OTHER                              *****/  /*****                                                               *****/  /*************************************************************************/  /*************************************************************************/  FT_LOCAL_DEF void  T1_Decrypt( FT_Byte*   buffer,              FT_Offset  length,              FT_UShort  seed )  {    while ( length > 0 )    {      FT_Byte  plain;      plain     = (FT_Byte)( *buffer ^ ( seed >> 8 ) );      seed      = (FT_UShort)( ( *buffer + seed ) * 52845U + 22719 );      *buffer++ = plain;      length--;    }  }/* END */

⌨️ 快捷键说明

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