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

📄 ttgload.c

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    FT_Stream  stream = loader->stream;    FT_FRAME_EXIT();  }  FT_CALLBACK_DEF( FT_Error )  TT_Load_Glyph_Header( TT_Loader  loader )  {    FT_Stream  stream   = loader->stream;    FT_Int     byte_len = loader->byte_len - 10;    if ( byte_len < 0 )      return TT_Err_Invalid_Outline;    loader->n_contours = FT_GET_SHORT();    loader->bbox.xMin = FT_GET_SHORT();    loader->bbox.yMin = FT_GET_SHORT();    loader->bbox.xMax = FT_GET_SHORT();    loader->bbox.yMax = FT_GET_SHORT();    FT_TRACE5(( "  # of contours: %d\n", loader->n_contours ));    FT_TRACE5(( "  xMin: %4d  xMax: %4d\n", loader->bbox.xMin,                                            loader->bbox.xMax ));    FT_TRACE5(( "  yMin: %4d  yMax: %4d\n", loader->bbox.yMin,                                            loader->bbox.yMax ));    loader->byte_len = byte_len;    return TT_Err_Ok;  }  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, *flag_limit;    FT_Byte         c, count;    FT_Vector       *vec, *vec_limit;    FT_Pos          x;    FT_Short        *cont, *cont_limit;    /* reading the contours' endpoints & number of points */    cont       = gloader->current.outline.contours;    cont_limit = cont + n_contours;    /* check space for contours array + instructions count */    byte_len -= 2 * ( n_contours + 1 );    if ( byte_len < 0 )      goto Invalid_Outline;    for ( ; cont < cont_limit; cont++ )      cont[0] = FT_GET_USHORT();    n_points = 0;    if ( n_contours > 0 )      n_points = cont[-1] + 1;    error = FT_GlyphLoader_CheckPoints( gloader, n_points + 4, 0 );    if ( error )      goto Fail;    /* we'd better check the contours table right now */    outline = &gloader->current.outline;    for ( cont = outline->contours + 1; cont < cont_limit; cont++ )      if ( cont[-1] >= cont[0] )        goto Invalid_Outline;    /* reading the bytecode instructions */    slot->control_len  = 0;    slot->control_data = 0;    n_ins = FT_GET_USHORT();    FT_TRACE5(( "  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;    FT_ASSERT( flag != NULL );    while ( flag < flag_limit )    {      if ( --byte_len < 0 )        goto Invalid_Outline;      *flag++ = c = FT_GET_BYTE();      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 */    vec       = 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 & 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;    }    /* reading the Y coordinates */    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;  }  FT_CALLBACK_DEF( FT_Error )  TT_Load_Composite_Glyph( TT_Loader  loader )  {    FT_Error        error;    FT_Stream       stream  = loader->stream;    FT_GlyphLoader  gloader = loader->gloader;    FT_SubGlyph     subglyph;    FT_UInt         num_subglyphs;    FT_Int          byte_len = loader->byte_len;    num_subglyphs = 0;    do    {      FT_Fixed  xx, xy, yy, yx;      /* check that we can load a new subglyph */      error = FT_GlyphLoader_CheckSubGlyphs( gloader, num_subglyphs + 1 );      if ( error )        goto Fail;      /* check space */      byte_len -= 4;      if ( byte_len < 0 )        goto Invalid_Composite;      subglyph = gloader->current.subglyphs + num_subglyphs;      subglyph->arg1 = subglyph->arg2 = 0;      subglyph->flags = FT_GET_USHORT();      subglyph->index = FT_GET_USHORT();      /* check space */      byte_len -= 2;      if ( subglyph->flags & ARGS_ARE_WORDS )        byte_len -= 2;      if ( subglyph->flags & WE_HAVE_A_SCALE )        byte_len -= 2;      else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )        byte_len -= 4;      else if ( subglyph->flags & WE_HAVE_A_2X2 )        byte_len -= 8;      if ( byte_len < 0 )        goto Invalid_Composite;      /* read arguments */      if ( subglyph->flags & ARGS_ARE_WORDS )      {        subglyph->arg1 = FT_GET_SHORT();        subglyph->arg2 = FT_GET_SHORT();      }      else      {        subglyph->arg1 = FT_GET_CHAR();        subglyph->arg2 = FT_GET_CHAR();      }      /* read transform */      xx = yy = 0x10000L;      xy = yx = 0;      if ( subglyph->flags & WE_HAVE_A_SCALE )      {        xx = (FT_Fixed)FT_GET_SHORT() << 2;        yy = xx;      }      else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )      {        xx = (FT_Fixed)FT_GET_SHORT() << 2;        yy = (FT_Fixed)FT_GET_SHORT() << 2;      }      else if ( subglyph->flags & WE_HAVE_A_2X2 )      {        xx = (FT_Fixed)FT_GET_SHORT() << 2;        yx = (FT_Fixed)FT_GET_SHORT() << 2;        xy = (FT_Fixed)FT_GET_SHORT() << 2;        yy = (FT_Fixed)FT_GET_SHORT() << 2;      }      subglyph->transform.xx = xx;      subglyph->transform.xy = xy;      subglyph->transform.yx = yx;      subglyph->transform.yy = yy;      num_subglyphs++;    } while ( subglyph->flags & MORE_COMPONENTS );    gloader->current.num_subglyphs = num_subglyphs;#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER    {      /* we must undo the FT_FRAME_ENTER in order to point to the */      /* composite instructions, if we find some.               */      /* we will process them later...                          */      /*                                                        */      loader->ins_pos = (FT_ULong)( FT_STREAM_POS() +                                    stream->cursor - stream->limit );    }#endif    loader->byte_len = byte_len;  Fail:    return error;  Invalid_Composite:    error = TT_Err_Invalid_Composite;    goto Fail;  }  FT_LOCAL_DEF( void )  TT_Init_Glyph_Loading( TT_Face  face )  {    face->access_glyph_frame   = TT_Access_Glyph_Frame;    face->read_glyph_header    = TT_Load_Glyph_Header;    face->read_simple_glyph    = TT_Load_Simple_Glyph;    face->read_composite_glyph = TT_Load_Composite_Glyph;    face->forget_glyph_frame   = TT_Forget_Glyph_Frame;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    TT_Process_Simple_Glyph                                            */  /*                                                                       */  /* <Description>                                                         */  /*    Once a simple glyph has been loaded, it needs to be processed.     */  /*    Usually, this means scaling and hinting through bytecode           */  /*    interpretation.                                                    */  /*                                                                       */  static FT_Error  TT_Process_Simple_Glyph( TT_Loader  load,                           FT_Bool    debug )  {    FT_GlyphLoader  gloader  = load->gloader;    FT_Outline*     outline  = &gloader->current.outline;    FT_UInt         n_points = outline->n_points;#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER    FT_UInt         n_ins;#endif    TT_GlyphZone    zone     = &load->zone;    FT_Error        error    = TT_Err_Ok;    FT_UNUSED( debug );  /* used by truetype interpreter only */#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER    n_ins = load->glyph->control_len;#endif    /* add shadow points */    /* Add two horizontal shadow points at n and n+1.   */    /* We need the left side bearing and advance width. */    /* Add two vertical shadow points at n+2 and n+3.   */    /* We need the top side bearing and advance height. */

⌨️ 快捷键说明

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