freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Devel] BUGREPORT: ATARI-PureC-Compiler with FT_SIZEOF_INT=2


From: PORTHOS
Subject: [Devel] BUGREPORT: ATARI-PureC-Compiler with FT_SIZEOF_INT=2
Date: Sat, 5 Oct 2002 21:47:01 +0200

Hallo "devel",

there are two remaining problems:

1. pshglob.c
============
My Compiler calculates a wrong pointer-difference. I do not know
exactly why. But there should be no problem to avoid this:

/*        dim->stdw.count = write - dim->stdw.widths; */
          dim->stdw.count = priv->num_snap_widths;

/*        dim->stdw.count = write - dim->stdw.widths; */
          dim->stdw.count = priv->num_snap_heights;

          Besides that, there should be a limitation to
PS_GLOBALS_MAX_STD_WIDTH (otherwise an array-overflow can happen).


2. ttgload.c
============
My compiler does this procedure wrong! I do not know why! There are
two chances to "solve" the problem:
1. I add a dummy TRACE-Instruction somewhere in the code - and it
works OR
2. I do not define variables with different types in blocks. As soon
as I write the code in the following way - it works:


  FT_CALLBACK_DEF( FT_Error )
  TT_Load_Simple_Glyph( TT_Loader  load )
{
    FT_Error        error;
    FT_Stream       stream     = load->stream;
    FT_GlyphLoader  gloader    = load->gloader;
    FT_Int          n_contours = load->n_contours;
    FT_Outline*     outline;
    TT_Face         face       = (TT_Face)load->face;
    TT_GlyphSlot    slot       = (TT_GlyphSlot)load->glyph;
    FT_UShort       n_ins;
    FT_Int          n, n_points;
    FT_Int          byte_len   = load->byte_len;


      FT_Byte*  flag;
      FT_Byte*  flag_limit;
      FT_Byte   c, count;
      FT_Pos      x;
     FT_Vector*  vec;
      FT_Vector*  vec_limit;
      
    /* reading the contours endpoints & number of points */
      FT_Int*  cur   = gloader->current.outline.contours;
      FT_Int*  limit = cur + n_contours;


      /* check space for contours array + instructions count */
      byte_len -= 2 * ( n_contours + 1 );
      if ( byte_len < 0 )
        goto Invalid_Outline;

      for ( ; cur < limit; cur++ )
        *cur = FT_GET_SHORT();

      n_points = 0;
      if ( n_contours > 0 )
        n_points = (*--cur) + 1;

      error = FT_GlyphLoader_CheckPoints( gloader, n_points + 2, 0 );
      if ( error )
        goto Fail;

      /* we'd better check the contours table right now */
      outline = &gloader->current.outline;

      for ( cur = outline->contours; cur < limit-1; cur++ )
        if ( cur[0] >= cur[1] )
          goto Invalid_Outline;






    /* reading the bytecode instructions */
    slot->control_len  = 0;
    slot->control_data = 0;

    n_ins = FT_GET_USHORT();

    FT_TRACE0(( "  Instructions size: %u\n", n_ins ));

    if ( n_ins > face->max_profile.maxSizeOfInstructions )
    {
      FT_TRACE0(( "TT_Load_Simple_Glyph: Too many instructions!\n" ));
      error = TT_Err_Too_Many_Hints;
      goto Fail;
    }

                byte_len -= (FT_Int) n_ins;
                
    if ( byte_len < 0 )
    {
      FT_TRACE0(( "TT_Load_Simple_Glyph: Instruction count mismatch!\n" ));
      error = TT_Err_Too_Many_Hints;
      goto Fail;
    }

#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER

    if ( ( load->load_flags                        &
         ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) == 0 &&
           load->instructions )
    {
      slot->control_len  = n_ins;
      slot->control_data = load->instructions;

      FT_MEM_COPY( load->instructions, stream->cursor, (FT_Long) n_ins );
    }

#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */

    stream->cursor += (FT_Int) n_ins;

    /* reading the point tags */

      flag  = (FT_Byte*)outline->tags;
      flag_limit = flag + n_points;
      c, count;


      while ( flag < flag_limit )
      {
        if ( --byte_len < 0 )
          goto Invalid_Outline;

                        c = FT_GET_BYTE();
        *flag++ = c;
        if ( c & 8 )
        {
          if ( --byte_len < 0 )
            goto Invalid_Outline;

          count = FT_GET_BYTE();
          if ( flag + (FT_Int) count > flag_limit )
            goto Invalid_Outline;

          for ( ; count > 0; count-- )
            *flag++ = c;
        }
      }

      /* check that there is enough room to load the coordinates */
      for ( flag = (FT_Byte*)outline->tags; flag < flag_limit; flag++ )
      {
        if ( *flag & 2 )
          byte_len -= 1;
        else if ( ( *flag & 16 ) == 0 )
          byte_len -= 2;

        if ( *flag & 4 )
          byte_len -= 1;
        else if ( ( *flag & 32 ) == 0 )
          byte_len -= 2;
      }

      if ( byte_len < 0 )
        goto Invalid_Outline;

    /* reading the X coordinates */

       flag  = (FT_Byte*)outline->tags;
        vec = outline->points;
        vec_limit = vec + n_points;
        x = 0;

      for ( ; vec < vec_limit; vec++, flag++ )
      {
        FT_Pos  y = 0;


        if ( *flag & 2 )
        {
          y = (FT_Pos) (FT_GET_BYTE());
          if ( ( *flag & 16 ) == 0 )
            y = -y;
        }
        else if ( ( *flag & 16 ) == 0 )
          y = (FT_Pos) (FT_GET_SHORT());

        x     += y;
        vec->x = x;
      }

      vec   = gloader->current.outline.points;
      vec_limit = vec + n_points;
      flag  = (FT_Byte*)outline->tags;
      x     = 0;


      for ( ; vec < vec_limit; vec++, flag++ )
      {
        FT_Pos  y = 0;


        if ( *flag & 4 )
        {
          y = (FT_Pos) (FT_GET_BYTE());
          if ( ( *flag & 32 ) == 0 )
            y = -y;
        }
        else if ( ( *flag & 32 ) == 0 )
          y = (FT_Pos) (FT_GET_SHORT());

        x     += y;
        vec->y = x;
      }

    /* clear the touch tags */
    for ( n = 0; n < n_points; n++ )
      outline->tags[n] &= FT_CURVE_TAG_ON;

    outline->n_points   = (FT_UShort)n_points;
    outline->n_contours = (FT_Short) n_contours;

    load->byte_len = byte_len;

  Fail:
    return error;

  Invalid_Outline:
    error = TT_Err_Invalid_Outline;
    goto Fail;
  }



-- 
Mit freundlichen Grüßen,
Wolfgang Domröse
mailto:address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]