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

📄 t2gload.c

📁 qt-embedded-2.3.8.tar.gz源码
💻 C
📖 第 1 页 / 共 4 页
字号:
              index = num_args - 2;            args[0] = args[-( index + 1 )];            args++;          }          break;        case t2_op_roll:          {            FT_Int  count = (FT_Int)( args[0] >> 16 );            FT_Int  index = (FT_Int)( args[1] >> 16 );            FT_TRACE4(( " roll" ));            if ( count <= 0 )              count = 1;            args -= count;            if ( args < stack )              goto Stack_Underflow;            if ( index >= 0 )            {              while ( index > 0 )              {                FT_Fixed  tmp = args[count - 1];                FT_Int    i;                for ( i = count - 2; i >= 0; i-- )                  args[i + 1] = args[i];                args[0] = tmp;                index--;              }            }            else            {              while ( index < 0 )              {                FT_Fixed  tmp = args[0];                FT_Int    i;                for ( i = 0; i < count - 1; i++ )                  args[i] = args[i + 1];                args[count - 1] = tmp;                index++;              }            }            args += count;          }          break;        case t2_op_dup:          FT_TRACE4(( " dup" ));          args[1] = args[0];          args++;          break;        case t2_op_put:          {            FT_Fixed  val   = args[0];            FT_Int    index = (FT_Int)( args[1] >> 16 );            FT_TRACE4(( " put" ));            if ( index >= 0 && index < decoder->len_buildchar )              decoder->buildchar[index] = val;          }          break;        case t2_op_get:          {            FT_Int   index = (FT_Int)( args[0] >> 16 );            FT_Fixed val   = 0;            FT_TRACE4(( " get" ));            if ( index >= 0 && index < decoder->len_buildchar )              val = decoder->buildchar[index];            args[0] = val;            args++;          }          break;        case t2_op_store:          FT_TRACE4(( " store "));          goto Unimplemented;        case t2_op_load:          FT_TRACE4(( " load" ));          goto Unimplemented;        case t2_op_and:          {            FT_Fixed  cond = args[0] && args[1];            FT_TRACE4(( " and" ));            args[0] = cond ? 0x10000L : 0;            args++;          }          break;        case t2_op_or:          {            FT_Fixed  cond = args[0] || args[1];            FT_TRACE4(( " or" ));            args[0] = cond ? 0x10000L : 0;            args++;          }          break;        case t2_op_eq:          {            FT_Fixed  cond = !args[0];            FT_TRACE4(( " eq" ));            args[0] = cond ? 0x10000L : 0;            args++;          }          break;        case t2_op_ifelse:          {            FT_Fixed  cond = (args[2] <= args[3]);            FT_TRACE4(( " ifelse" ));            if ( !cond )              args[0] = args[1];            args++;          }          break;        case t2_op_callsubr:          {            FT_UInt  index = (FT_UInt)( ( args[0] >> 16 ) +                                        decoder->locals_bias );            FT_TRACE4(( " callsubr(%d)", index ));            if ( index >= decoder->num_locals )            {              FT_ERROR(( "T2_Parse_CharStrings:" ));              FT_ERROR(( "  invalid local subr index\n" ));              goto Syntax_Error;            }            if ( zone - decoder->zones >= T2_MAX_SUBRS_CALLS )            {              FT_ERROR(( "T2_Parse_CharStrings: too many nested subrs\n" ));              goto Syntax_Error;            }            zone->cursor = ip;  /* save current instruction pointer */            zone++;            zone->base   = decoder->locals[index];            zone->limit  = decoder->locals[index+1];            zone->cursor = zone->base;            if ( !zone->base )            {              FT_ERROR(( "T2_Parse_CharStrings: invoking empty subrs!\n" ));              goto Syntax_Error;            }            decoder->zone = zone;            ip            = zone->base;            limit         = zone->limit;          }          break;        case t2_op_callgsubr:          {            FT_UInt  index = (FT_UInt)( ( args[0] >> 16 ) +                                        decoder->globals_bias );            FT_TRACE4(( " callgsubr(%d)", index ));            if ( index >= decoder->num_globals )            {              FT_ERROR(( "T2_Parse_CharStrings:" ));              FT_ERROR(( " invalid global subr index\n" ));              goto Syntax_Error;            }            if ( zone - decoder->zones >= T2_MAX_SUBRS_CALLS )            {              FT_ERROR(( "T2_Parse_CharStrings: too many nested subrs\n" ));              goto Syntax_Error;            }            zone->cursor = ip;  /* save current instruction pointer */            zone++;            zone->base   = decoder->globals[index];            zone->limit  = decoder->globals[index+1];            zone->cursor = zone->base;            if ( !zone->base )            {              FT_ERROR(( "T2_Parse_CharStrings: invoking empty subrs!\n" ));              goto Syntax_Error;            }            decoder->zone = zone;            ip            = zone->base;            limit         = zone->limit;          }          break;        case t2_op_return:          FT_TRACE4(( " return" ));          if ( decoder->zone <= decoder->zones )          {            FT_ERROR(( "T2_Parse_CharStrings: unexpected return\n" ));            goto Syntax_Error;          }          decoder->zone--;          zone  = decoder->zone;          ip    = zone->cursor;          limit = zone->limit;          break;        default:        Unimplemented:          FT_ERROR(( "Unimplemented opcode: %d", ip[-1] ));          if ( ip[-1] == 12 )            FT_ERROR(( " %d", ip[0] ));          FT_ERROR(( "\n" ));          return T2_Err_Unimplemented_Feature;        }      decoder->top = args;      } /* general operator processing */    } /* while ip < limit */    FT_TRACE4(( "..end..\n\n" ));    return error;  Syntax_Error:    FT_TRACE4(( "T2_Parse_CharStrings: syntax error!" ));    return T2_Err_Invalid_File_Format;  Stack_Underflow:    FT_TRACE4(( "T2_Parse_CharStrings: stack underflow!" ));    return T2_Err_Too_Few_Arguments;  Stack_Overflow:    FT_TRACE4(( "T2_Parse_CharStrings: stack overflow!" ));    return T2_Err_Stack_Overflow;  Memory_Error:    return builder->error;  }  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /**********                                                      *********/  /**********                                                      *********/  /**********            COMPUTE THE MAXIMUM ADVANCE WIDTH         *********/  /**********                                                      *********/  /**********    The following code is in charge of computing      *********/  /**********    the maximum advance width of the font.  It        *********/  /**********    quickly processes each glyph charstring to        *********/  /**********    extract the value from either a `sbw' or `seac'   *********/  /**********    operator.                                         *********/  /**********                                                      *********/  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/#if 0 /* unused until we support pure CFF fonts */  FT_LOCAL_DEF  FT_Error  T2_Compute_Max_Advance( TT_Face  face,                                    FT_Int*  max_advance )  {    FT_Error    error = 0;    T2_Decoder  decoder;    FT_Int      glyph_index;    CFF_Font*   cff = (CFF_Font*)face->other;    *max_advance = 0;    /* Initialize load decoder */    T2_Init_Decoder( &decoder, face, 0, 0 );    decoder.builder.metrics_only = 1;    decoder.builder.load_points  = 0;    /* For each glyph, parse the glyph charstring and extract */    /* the advance width.                                     */    for ( glyph_index = 0; glyph_index < face->root.num_glyphs;          glyph_index++ )    {      FT_Byte*  charstring;      FT_ULong  charstring_len;      /* now get load the unscaled outline */      error = T2_Access_Element( &cff->charstrings_index, glyph_index,                                 &charstring, &charstring_len );      if ( !error )      {        T2_Prepare_Decoder( &decoder, glyph_index );        error = T2_Parse_CharStrings( &decoder, charstring, charstring_len );        T2_Forget_Element( &cff->charstrings_index, &charstring );      }      /* ignore the error if one has occurred -- skip to next glyph */      error = 0;    }    *max_advance = decoder.builder.advance.x;    return T2_Err_Ok;  }#endif /* 0 */  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  /**********                                                      *********/  /**********                                                      *********/  /**********               UNHINTED GLYPH LOADER                  *********/  /**********                                                      *********/  /**********    The following code is in charge of loading a      *********/  /**********    single outline.  It completely ignores hinting    *********/  /**********    and is used when FT_LOAD_NO_HINTING is set.       *********/  /**********                                                      *********/  /*************************************************************************/  /*************************************************************************/  /*************************************************************************/  FT_LOCAL_DEF  FT_Error  T2_Load_Glyph( T2_GlyphSlot  glyph,                           T2_Size       size,                           FT_Int        glyph_index,                           FT_Int        load_flags )  {    FT_Error    error;    T2_Decoder  decoder;    TT_Face     face = (TT_Face)glyph->root.face;    FT_Bool     hinting;    CFF_Font*   cff = (CFF_Font*)face->extra.data;    if ( load_flags & FT_LOAD_NO_RECURSE )      load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;    glyph->x_scale = 0x10000L;    glyph->y_scale = 0x10000L;    if ( size )    {      glyph->x_scale = size->metrics.x_scale;      glyph->y_scale = size->metrics.y_scale;    }    glyph->root.outline.n_points   = 0;    glyph->root.outline.n_contours = 0;    hinting = ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&              ( load_flags & FT_LOAD_NO_HINTING ) == 0;    glyph->root.format = ft_glyph_format_outline;  /* by default */    {      FT_Byte*  charstring;      FT_ULong  charstring_len;      T2_Init_Decoder( &decoder, face, size, glyph );      decoder.builder.no_recurse =        (FT_Bool)( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );      /* now load the unscaled outline */      error = T2_Access_Element( &cff->charstrings_index, glyph_index,                                 &charstring, &charstring_len );      if ( !error )      {        T2_Prepare_Decoder( &decoder, glyph_index );        error = T2_Parse_CharStrings( &decoder, charstring, charstring_len );        T2_Forget_Element( &cff->charstrings_index, &charstring );      }      /* save new glyph tables */      T2_Done_Builder( &decoder.builder );    }    /* Now, set the metrics -- this is rather simple, as   */    /* the left side bearing is the xMin, and the top side */    /* bearing the yMax.                                   */    if ( !error )    {      /* for composite glyphs, return only left side bearing and */      /* advance width                                           */      if ( glyph->root.format == ft_glyph_format_composite )      {        glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;        glyph->root.metrics.horiAdvance  = decoder.glyph_width;      }      else      {        FT_BBox            cbox;        FT_Glyph_Metrics*  metrics = &glyph->root.metrics;        /* copy the _unscaled_ advance width */        metrics->horiAdvance          = decoder.glyph_width;        glyph->root.linearHoriAdvance = decoder.glyph_width;        /* make up vertical metrics */        metrics->vertBearingX = 0;        metrics->vertBearingY = 0;        metrics->vertAdvance  = 0;        glyph->root.linearVertAdvance = 0;        glyph->root.format = ft_glyph_format_outline;        glyph->root.outline.flags = 0;        if ( size && size->metrics.y_ppem < 24 )          glyph->root.outline.flags |= ft_outline_high_precision;        glyph->root.outline.flags |= ft_outline_reverse_fill;        if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )        {          /* scale the outline and the metrics */          FT_Int       n;          FT_Outline*  cur     = &glyph->root.outline;          FT_Vector*   vec     = cur->points;          FT_Fixed     x_scale = glyph->x_scale;          FT_Fixed     y_scale = glyph->y_scale;          /* First of all, scale the points */          for ( n = cur->n_points; n > 0; n--, vec++ )          {            vec->x = FT_MulFix( vec->x, x_scale );            vec->y = FT_MulFix( vec->y, y_scale );          }          FT_Outline_Get_CBox( &glyph->root.outline, &cbox );          /* Then scale the metrics */          metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );          metrics->vertAdvance  = FT_MulFix( metrics->vertAdvance,  y_scale );          metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );          metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );        }#if 0        /* apply the font matrix */        FT_Outline_Transform( &glyph->root.outline, cff->font_matrix );#endif        /* compute the other metrics */        FT_Outline_Get_CBox( &glyph->root.outline, &cbox );        /* grid fit the bounding box if necessary */        if ( hinting )        {          cbox.xMin &= -64;          cbox.yMin &= -64;          cbox.xMax  = ( cbox.xMax + 63 ) & -64;          cbox.yMax  = ( cbox.yMax + 63 ) & -64;        }        metrics->width  = cbox.xMax - cbox.xMin;        metrics->height = cbox.yMax - cbox.yMin;        metrics->horiBearingX = cbox.xMin;        metrics->horiBearingY = cbox.yMax;      }    }    return error;  }/* END */

⌨️ 快捷键说明

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