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

📄 ttgload.c

📁 qt-embedded-2.3.8.tar.gz源码
💻 C
📖 第 1 页 / 共 4 页
字号:
            y = -y;        }        else if ( ( *flag & 16 ) == 0 )          y = GET_Short();        x     += y;        vec->x = x;      }    }    /* reading the Y coordinates */    {      FT_Vector*  vec   = gloader->current.outline.points;      FT_Vector*  limit = vec + n_points;      FT_Byte*    flag  = (FT_Byte*)outline->tags;      FT_Pos      x     = 0;      for ( ; vec < limit; vec++, flag++ )      {        FT_Pos  y = 0;        if ( *flag & 4 )        {          y = GET_Byte();          if ( ( *flag & 32 ) == 0 )            y = -y;        }        else if ( ( *flag & 32 ) == 0 )          y = 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   = n_points;    outline->n_contours = n_contours;  Fail:    return error;  }  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;    num_subglyphs = 0;    do    {      FT_Fixed  xx, xy, yy, yx;      /* check that we can load a new subglyph */      error = FT_GlyphLoader_Check_Subglyphs( gloader, num_subglyphs + 1 );      if ( error )        goto Fail;      subglyph = gloader->current.subglyphs + num_subglyphs;      subglyph->arg1 = subglyph->arg2 = 0;      subglyph->flags = GET_UShort();      subglyph->index = GET_UShort();      /* read arguments */      if ( subglyph->flags & ARGS_ARE_WORDS )      {        subglyph->arg1 = GET_Short();        subglyph->arg2 = GET_Short();      }      else      {        subglyph->arg1 = GET_Char();        subglyph->arg2 = GET_Char();      }      /* read transform */      xx = yy = 0x10000L;      xy = yx = 0;      if ( subglyph->flags & WE_HAVE_A_SCALE )      {        xx = (FT_Fixed)GET_Short() << 2;        yy = xx;      }      else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )      {        xx = (FT_Fixed)GET_Short() << 2;        yy = (FT_Fixed)GET_Short() << 2;      }      else if ( subglyph->flags & WE_HAVE_A_2X2 )      {        xx = (FT_Fixed)GET_Short() << 2;        xy = (FT_Fixed)GET_Short() << 2;        yx = (FT_Fixed)GET_Short() << 2;        yy = (FT_Fixed)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 ACCESS_Frame in order to point to the */      /* composite instructions, if we find some.               */      /* we will process them later...                          */      /*                                                        */      loader->ins_pos = FILE_Pos() + stream->cursor - stream->limit;    }#endif  Fail:    return error;  }  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;    FT_UInt          n_ins;    TT_GlyphZone*    zone     = &load->zone;    FT_Error         error    = FT_Err_Ok;    FT_UNUSED( debug );  /* used by truetype interpreter only */    n_ins = load->glyph->control_len;    /* add shadow points */    /* Now add the two shadow points at n and n + 1.    */    /* We need the left side bearing and advance width. */    {      FT_Vector*  pp1;      FT_Vector*  pp2;      /* pp1 = xMin - lsb */      pp1    = outline->points + n_points;      pp1->x = load->bbox.xMin - load->left_bearing;      pp1->y = 0;      /* pp2 = pp1 + aw */      pp2    = pp1 + 1;      pp2->x = pp1->x + load->advance;      pp2->y = 0;      outline->tags[n_points    ] = 0;      outline->tags[n_points + 1] = 0;    }    /* Note that we return two more points that are not */    /* part of the glyph outline.                       */    n_points += 2;    /* set up zone for hinting */    tt_prepare_zone( zone, &gloader->current, 0, 0 );    /* eventually scale the glyph */    if ( !( load->load_flags & FT_LOAD_NO_SCALE ) )    {      FT_Vector*  vec     = zone->cur;      FT_Vector*  limit   = vec + n_points;      FT_Fixed    x_scale = load->size->metrics.x_scale;      FT_Fixed    y_scale = load->size->metrics.y_scale;      /* first scale the glyph points */      for ( ; vec < limit; vec++ )      {        vec->x = FT_MulFix( vec->x, x_scale );        vec->y = FT_MulFix( vec->y, y_scale );      }    }    cur_to_org( n_points, zone );    /* eventually hint the glyph */    if ( IS_HINTED( load->load_flags ) )    {      FT_Pos  x = zone->org[n_points-2].x;      x = ( ( x + 32 ) & -64 ) - x;      translate_array( n_points, zone->org, x, 0 );      org_to_cur( n_points, zone );      zone->cur[n_points - 1].x = ( zone->cur[n_points - 1].x + 32 ) & -64;#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER      /* now consider hinting */      if ( n_ins > 0 )      {        error = TT_Set_CodeRange( load->exec, tt_coderange_glyph,                                  load->exec->glyphIns, n_ins );        if ( error )          goto Exit;        load->exec->is_composite     = FALSE;        load->exec->pedantic_hinting = (FT_Bool)( load->load_flags &                                                  FT_LOAD_PEDANTIC );        load->exec->pts              = *zone;        load->exec->pts.n_points    += 2;        error = TT_Run_Context( load->exec, debug );        if ( error && load->exec->pedantic_hinting )          goto Exit;        error = FT_Err_Ok;  /* ignore bytecode errors in non-pedantic mode */      }#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */    }    /* save glyph phantom points */    if ( !load->preserve_pps )    {      load->pp1 = zone->cur[n_points - 2];      load->pp2 = zone->cur[n_points - 1];    }#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER  Exit:#endif    return error;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    load_truetype_glyph                                                */  /*                                                                       */  /* <Description>                                                         */  /*    Loads a given truetype glyph.  Handles composites and uses a       */  /*    TT_Loader object.                                                  */  /*                                                                       */  static  FT_Error  load_truetype_glyph( TT_Loader*  loader,                                 FT_UInt     glyph_index )  {#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER    FT_Stream        stream = loader->stream;#endif    FT_Error         error;    TT_Face          face   = (TT_Face)loader->face;    FT_ULong         offset;    FT_Int           contours_count;    FT_UInt          index, num_points, num_contours, count;    FT_Fixed         x_scale, y_scale;    FT_ULong         ins_offset;    FT_GlyphLoader*  gloader = loader->gloader;    FT_Bool          opened_frame = 0;    /* check glyph index */    index = glyph_index;    if ( index >= (FT_UInt)face->root.num_glyphs )    {      error = TT_Err_Invalid_Glyph_Index;      goto Exit;    }    loader->glyph_index = glyph_index;    num_contours = 0;    num_points   = 0;    ins_offset   = 0;    x_scale = 0x10000L;    y_scale = 0x10000L;    if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )    {      x_scale = loader->size->metrics.x_scale;      y_scale = loader->size->metrics.y_scale;    }    /* get horizontal metrics */    {      FT_Short   left_bearing;      FT_UShort  advance_width;      Get_HMetrics( face, index,                    (FT_Bool)!(loader->load_flags &                                FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH),                    &left_bearing,                    &advance_width );      loader->left_bearing = left_bearing;      loader->advance      = advance_width;    }    offset = face->glyph_locations[index];    count  = 0;    if ( index < (FT_UInt)face->num_locations - 1 )       count = face->glyph_locations[index + 1] - offset;    if ( count == 0 )    {      /* as described by Frederic Loyer, these are spaces, and */      /* not the unknown glyph.                                */      loader->bbox.xMin = 0;      loader->bbox.xMax = 0;      loader->bbox.yMin = 0;      loader->bbox.yMax = 0;      loader->pp1.x = 0;      loader->pp2.x = loader->advance;      if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )        loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER      if ( loader->exec )        loader->exec->glyphSize = 0;#endif

⌨️ 快捷键说明

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