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

📄 ttgload.c

📁 qt-embedded-2.3.8.tar.gz源码
💻 C
📖 第 1 页 / 共 4 页
字号:
      error = FT_Err_Ok;      goto Exit;    }    offset = loader->glyf_offset + offset;    /* access glyph frame */    error = face->access_glyph_frame( loader, glyph_index, offset, count );    if ( error )      goto Exit;    opened_frame = 1;    /* read first glyph header */    error = face->read_glyph_header( loader );    if ( error )      goto Fail;    contours_count = loader->n_contours;    count -= 10;    loader->pp1.x = loader->bbox.xMin - loader->left_bearing;    loader->pp1.y = 0;    loader->pp2.x = loader->pp1.x + loader->advance;    loader->pp2.y = 0;    if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )    {      loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );      loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );    }    /***********************************************************************/    /***********************************************************************/    /***********************************************************************/    /* if it is a simple glyph, load it */    if ( contours_count >= 0 )    {      /* check that we can add the contours to the glyph */      error = FT_GlyphLoader_Check_Points( gloader, 0, contours_count );      if ( error )        goto Fail;      error = face->read_simple_glyph( loader );      if ( error )        goto Fail;#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER      {        TT_Size size = (TT_Size)loader->size;        error = TT_Process_Simple_Glyph( loader,                                         (FT_Bool)( size && size->debug ) );      }#else      error = TT_Process_Simple_Glyph( loader, 0 );#endif      if ( error )        goto Fail;      FT_GlyphLoader_Add( gloader );      /* Note: We could have put the simple loader source there */      /*       but the code is fat enough already :-)           */    }    /***********************************************************************/    /***********************************************************************/    /***********************************************************************/    /* otherwise, load a composite! */    else    {      TT_GlyphSlot  glyph = (TT_GlyphSlot)loader->glyph;      FT_UInt       start_point, start_contour;      FT_ULong      ins_pos;  /* position of composite instructions, if any */      /* for each subglyph, read composite header */      start_point   = gloader->base.outline.n_points;      start_contour = gloader->base.outline.n_contours;      error = face->read_composite_glyph( loader );      if ( error )        goto Fail;      ins_pos = loader->ins_pos;      face->forget_glyph_frame( loader );      opened_frame = 0;      /* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */      /* `as is' in the glyph slot (the client application will be     */      /* responsible for interpreting this data)...                    */      /*                                                               */      if ( loader->load_flags & FT_LOAD_NO_RECURSE )      {        /* set up remaining glyph fields */        FT_GlyphLoader_Add( gloader );        glyph->num_subglyphs  = gloader->base.num_subglyphs;        glyph->format         = ft_glyph_format_composite;        glyph->subglyphs      = gloader->base.subglyphs;        goto Exit;      }      /*********************************************************************/      /*********************************************************************/      /*********************************************************************/      /* Now, read each subglyph independently. */      {        FT_Int        n, num_base_points, num_new_points;        FT_SubGlyph*  subglyph = 0;        FT_UInt num_subglyphs  = gloader->current.num_subglyphs;        FT_UInt num_base_subgs = gloader->base.num_subglyphs;        FT_GlyphLoader_Add( gloader );        for ( n = 0; n < (FT_Int)num_subglyphs; n++ )        {          FT_Vector  pp1, pp2;          FT_Pos     x, y;          /* Each time we call load_truetype_glyph in this loop, the   */          /* value of `gloader.base.subglyphs' can change due to table */          /* reallocations.  We thus need to recompute the subglyph    */          /* pointer on each iteration.                                */          subglyph = gloader->base.subglyphs + num_base_subgs + n;          pp1 = loader->pp1;          pp2 = loader->pp2;          num_base_points = gloader->base.outline.n_points;          error = load_truetype_glyph( loader, subglyph->index );          if ( error )            goto Fail;          subglyph = gloader->base.subglyphs + num_base_subgs + n;          if ( subglyph->flags & USE_MY_METRICS )          {            pp1 = loader->pp1;            pp2 = loader->pp2;          }          else          {            loader->pp1 = pp1;            loader->pp2 = pp2;          }          num_points = gloader->base.outline.n_points;          num_new_points = num_points - num_base_points;          /* now perform the transform required for this subglyph */          if ( subglyph->flags & ( WE_HAVE_A_SCALE     |                                   WE_HAVE_AN_XY_SCALE |                                   WE_HAVE_A_2X2       ) )          {            FT_Vector*  cur   = gloader->base.outline.points +                                  num_base_points;            FT_Vector*  org   = gloader->base.extra_points +                                  num_base_points;            FT_Vector*  limit = cur + num_new_points;            for ( ; cur < limit; cur++, org++ )            {              FT_Vector_Transform( cur, &subglyph->transform );              FT_Vector_Transform( org, &subglyph->transform );            }          }          /* apply offset */          if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )          {            FT_UInt     k = subglyph->arg1;            FT_UInt     l = subglyph->arg2;            FT_Vector*  p1;            FT_Vector*  p2;            if ( start_point + k >= (FT_UInt)num_base_points ||                               l >= (FT_UInt)num_new_points  )            {              error = TT_Err_Invalid_Composite;              goto Fail;            }            l += num_base_points;            p1 = gloader->base.outline.points + start_point + k;            p2 = gloader->base.outline.points + start_point + l;            x = p1->x - p2->x;            y = p1->y - p2->y;          }          else          {            x = subglyph->arg1;            y = subglyph->arg2;            if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )            {              x = FT_MulFix( x, x_scale );              y = FT_MulFix( y, y_scale );              if ( subglyph->flags & ROUND_XY_TO_GRID )              {                x = ( x + 32 ) & -64;                y = ( y + 32 ) & -64;              }            }          }          translate_array( num_new_points, loader->zone.cur, x, y );          cur_to_org( num_new_points, &loader->zone );        }        /*******************************************************************/        /*******************************************************************/        /*******************************************************************/        /* we have finished loading all sub-glyphs; now, look for */        /* instructions for this composite!                       */#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER        if ( num_subglyphs > 0               &&             loader->exec                    &&             ins_pos         > 0             &&             subglyph->flags & WE_HAVE_INSTR )        {          FT_UShort       n_ins;          TT_ExecContext  exec = loader->exec;          TT_GlyphZone*   pts;          FT_Vector*      pp1;          /* read size of instructions */          if ( FILE_Seek( ins_pos ) ||               READ_UShort( n_ins ) )            goto Fail;          FT_TRACE5(( "  Instructions size = %d\n", n_ins ));          /* in some fonts? */          if ( n_ins == 0xFFFF )            n_ins = 0;          /* check it */          if ( n_ins > face->max_profile.maxSizeOfInstructions )          {            FT_TRACE0(( "Too many instructions (%d) in composite glyph %ld\n",                        n_ins, subglyph->index ));            return TT_Err_Too_Many_Ins;          }          /* read the instructions */          if ( FILE_Read( exec->glyphIns, n_ins ) )            goto Fail;          glyph->control_data = exec->glyphIns;          glyph->control_len  = n_ins;          error = TT_Set_CodeRange( exec,                                    tt_coderange_glyph,                                    exec->glyphIns,                                    n_ins );          if ( error )            goto Fail;          /* prepare the execution context */          tt_prepare_zone( &exec->pts, &gloader->base,                           start_point, start_contour );          pts = &exec->pts;          pts->n_points   = num_points + 2;          pts->n_contours = gloader->base.outline.n_contours;          /* add phantom points */          pp1    = pts->cur + num_points;          pp1[0] = loader->pp1;          pp1[1] = loader->pp2;          pts->tags[num_points    ] = 0;          pts->tags[num_points + 1] = 0;          /* if hinting, round the phantom points */          if ( IS_HINTED( loader->load_flags ) )          {            pp1[0].x = ( ( loader->pp1.x + 32 ) & -64 );            pp1[1].x = ( ( loader->pp2.x + 32 ) & -64 );          }          {            FT_UInt  k;            for ( k = 0; k < num_points; k++ )              pts->tags[k] &= FT_Curve_Tag_On;          }          cur_to_org( num_points + 2, pts );          /* now consider hinting */          if ( IS_HINTED( loader->load_flags ) && n_ins > 0 )          {            exec->is_composite     = TRUE;            exec->pedantic_hinting =              (FT_Bool)( loader->load_flags & FT_LOAD_PEDANTIC );            error = TT_Run_Context( exec, ((TT_Size)loader->size)->debug );            if ( error && exec->pedantic_hinting )              goto Fail;          }          /* save glyph origin and advance points */          loader->pp1 = pp1[0];          loader->pp2 = pp1[1];        }#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */      }      /* end of composite loading */    }    /***********************************************************************/    /***********************************************************************/    /***********************************************************************/  Fail:    if ( opened_frame )      face->forget_glyph_frame( loader );  Exit:    return error;  }  static  void  compute_glyph_metrics( TT_Loader*  loader,                               FT_UInt     glyph_index )  {    FT_BBox       bbox;    TT_Face       face = (TT_Face)loader->face;    FT_Fixed      x_scale, y_scale;    TT_GlyphSlot  glyph = loader->glyph;    TT_Size       size = (TT_Size)loader->size;    x_scale = 0x10000L;    y_scale = 0x10000L;    if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )    {      x_scale = size->root.metrics.x_scale;      y_scale = size->root.metrics.y_scale;

⌨️ 快捷键说明

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