您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ FT_STREAM_READ_FIELDS函数代码示例

51自学网 2021-06-01 20:44:43
  C++
这篇教程C++ FT_STREAM_READ_FIELDS函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中FT_STREAM_READ_FIELDS函数的典型用法代码示例。如果您正苦于以下问题:C++ FT_STREAM_READ_FIELDS函数的具体用法?C++ FT_STREAM_READ_FIELDS怎么用?C++ FT_STREAM_READ_FIELDS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了FT_STREAM_READ_FIELDS函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: check_table_dir

  static FT_Error  check_table_dir( SFNT_Header  sfnt,                   FT_Stream    stream )  {    FT_Error   error;    FT_UShort  nn, valid_entries = 0;    FT_UInt    has_head = 0, has_sing = 0, has_meta = 0;    FT_ULong   offset = sfnt->offset + 12;    static const FT_Frame_Field  table_dir_entry_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TT_TableRec      FT_FRAME_START( 16 ),        FT_FRAME_ULONG( Tag ),        FT_FRAME_ULONG( CheckSum ),        FT_FRAME_ULONG( Offset ),        FT_FRAME_ULONG( Length ),      FT_FRAME_END    };    if ( FT_STREAM_SEEK( offset ) )      goto Exit;    for ( nn = 0; nn < sfnt->num_tables; nn++ )    {      TT_TableRec  table;      if ( FT_STREAM_READ_FIELDS( table_dir_entry_fields, &table ) )      {        nn--;        FT_TRACE2(( "check_table_dir:"                    " can read only %d table%s in font (instead of %d)/n",                    nn, nn == 1 ? "" : "s", sfnt->num_tables ));        sfnt->num_tables = nn;        break;      }      /* we ignore invalid tables */      if ( table.Offset + table.Length > stream->size )      {		//BUGID: 53876, the cmap table is invalid, the font file couldn't be used.		if (table.Tag == TTAG_cmap) break;        FT_TRACE2(( "check_table_dir: table entry %d invalid/n", nn ));        continue;      }      else        valid_entries++;      if ( table.Tag == TTAG_head || table.Tag == TTAG_bhed )      {        FT_UInt32  magic;#ifndef TT_CONFIG_OPTION_EMBEDDED_BITMAPS        if ( table.Tag == TTAG_head )#endif          has_head = 1;        /*         * The table length should be 0x36, but certain font tools make it         * 0x38, so we will just check that it is greater.         *         * Note that according to the specification, the table must be         * padded to 32-bit lengths, but this doesn't apply to the value of         * its `Length' field!         *         */        if ( table.Length < 0x36 )        {          FT_TRACE2(( "check_table_dir: `head' table too small/n" ));          error = FT_THROW( Table_Missing );          goto Exit;        }        if ( FT_STREAM_SEEK( table.Offset + 12 ) ||             FT_READ_ULONG( magic )              )          goto Exit;        if ( magic != 0x5F0F3CF5UL )        {          FT_TRACE2(( "check_table_dir:"                      " no magic number found in `head' table/n"));          error = FT_THROW( Table_Missing );          goto Exit;        }        if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) )          goto Exit;      }      else if ( table.Tag == TTAG_SING )        has_sing = 1;      else if ( table.Tag == TTAG_META )        has_meta = 1;    }    sfnt->num_tables = valid_entries;//.........这里部分代码省略.........
开发者ID:WHS-TechOps,项目名称:Aviator,代码行数:101,


示例2: tt_face_load_font_dir

  tt_face_load_font_dir( TT_Face    face,                         FT_Stream  stream )  {    SFNT_HeaderRec  sfnt;    FT_Error        error;    FT_Memory       memory = stream->memory;    TT_TableRec*    entry;    FT_Int          nn;    static const FT_Frame_Field  offset_table_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  SFNT_HeaderRec      FT_FRAME_START( 8 ),        FT_FRAME_USHORT( num_tables ),        FT_FRAME_USHORT( search_range ),        FT_FRAME_USHORT( entry_selector ),        FT_FRAME_USHORT( range_shift ),      FT_FRAME_END    };    FT_TRACE2(( "tt_face_load_font_dir: %08p/n", face ));    /* read the offset table */    sfnt.offset = FT_STREAM_POS();    if ( FT_READ_ULONG( sfnt.format_tag )                    ||         FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) )      goto Exit;    /* many fonts don't have these fields set correctly */#if 0    if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 )        ||         sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 )      return FT_THROW( Unknown_File_Format );#endif    /* load the table directory */    FT_TRACE2(( "-- Number of tables: %10u/n",    sfnt.num_tables ));    FT_TRACE2(( "-- Format version:   0x%08lx/n", sfnt.format_tag ));    if ( sfnt.format_tag != TTAG_OTTO )    {      /* check first */      error = check_table_dir( &sfnt, stream );      if ( error )      {        FT_TRACE2(( "tt_face_load_font_dir:"                    " invalid table directory for TrueType/n" ));        goto Exit;      }    }    face->num_tables = sfnt.num_tables;    face->format_tag = sfnt.format_tag;    if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) )      goto Exit;    if ( FT_STREAM_SEEK( sfnt.offset + 12 )       ||         FT_FRAME_ENTER( face->num_tables * 16L ) )      goto Exit;    entry = face->dir_tables;    FT_TRACE2(( "/n"                "  tag    offset    length   checksum/n"                "  ----------------------------------/n" ));    for ( nn = 0; nn < sfnt.num_tables; nn++ )    {      entry->Tag      = FT_GET_TAG4();      entry->CheckSum = FT_GET_ULONG();      entry->Offset   = FT_GET_LONG();      entry->Length   = FT_GET_LONG();      /* ignore invalid tables */      if ( entry->Offset + entry->Length > stream->size )        continue;      else      {        FT_TRACE2(( "  %c%c%c%c  %08lx  %08lx  %08lx/n",                    (FT_Char)( entry->Tag >> 24 ),                    (FT_Char)( entry->Tag >> 16 ),                    (FT_Char)( entry->Tag >> 8  ),                    (FT_Char)( entry->Tag       ),                    entry->Offset,                    entry->Length,                    entry->CheckSum ));        entry++;      }    }    FT_FRAME_EXIT();//.........这里部分代码省略.........
开发者ID:WHS-TechOps,项目名称:Aviator,代码行数:101,


示例3: fnt_face_get_dll_fonts

  static FT_Error  fnt_face_get_dll_fonts( FNT_Face  face )  {    FT_Error         error;    FT_Stream        stream = FT_FACE( face )->stream;    FT_Memory        memory = FT_FACE( face )->memory;    WinMZ_HeaderRec  mz_header;    face->fonts     = 0;    face->num_fonts = 0;    /* does it begin with a MZ header? */    if ( FT_STREAM_SEEK( 0 )                                 ||         FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )      goto Exit;    error = FNT_Err_Unknown_File_Format;    if ( mz_header.magic == WINFNT_MZ_MAGIC )    {      /* yes, now look for a NE header in the file */      WinNE_HeaderRec  ne_header;      if ( FT_STREAM_SEEK( mz_header.lfanew )                  ||           FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) )        goto Exit;      error = FNT_Err_Unknown_File_Format;      if ( ne_header.magic == WINFNT_NE_MAGIC )      {        /* good, now look in the resource table for each FNT resource */        FT_ULong   res_offset = mz_header.lfanew +                                ne_header.resource_tab_offset;        FT_UShort  size_shift;        FT_UShort  font_count  = 0;        FT_ULong   font_offset = 0;        if ( FT_STREAM_SEEK( res_offset ) ||             FT_FRAME_ENTER( ne_header.rname_tab_offset -                             ne_header.resource_tab_offset ) )          goto Exit;        size_shift = FT_GET_USHORT_LE();        for (;;)        {          FT_UShort  type_id, count;          type_id = FT_GET_USHORT_LE();          if ( !type_id )            break;          count = FT_GET_USHORT_LE();          if ( type_id == 0x8008 )          {            font_count  = count;            font_offset = (FT_ULong)( FT_STREAM_POS() + 4 +                                      ( stream->cursor - stream->limit ) );            break;          }          stream->cursor += 4 + count * 12;        }        FT_FRAME_EXIT();        if ( !font_count || !font_offset )        {          FT_TRACE2(( "this file doesn't contain any FNT resources!/n" ));          error = FNT_Err_Unknown_File_Format;          goto Exit;        }        if ( FT_STREAM_SEEK( font_offset )           ||             FT_NEW_ARRAY( face->fonts, font_count ) )          goto Exit;        face->num_fonts = font_count;        if ( FT_FRAME_ENTER( (FT_Long)font_count * 12 ) )          goto Exit;        /* now read the offset and position of each FNT font */        {          FNT_Font  cur   = face->fonts;          FNT_Font  limit = cur + font_count;          for ( ; cur < limit; cur++ )          {            cur->offset     = (FT_ULong)FT_GET_USHORT_LE() << size_shift;            cur->fnt_size   = (FT_ULong)FT_GET_USHORT_LE() << size_shift;            cur->size_shift = size_shift;            stream->cursor += 8;          }        }//.........这里部分代码省略.........
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:101,


示例4: sfnt_open_font

  /* synthesized into a TTC with one offset table.              */  static FT_Error  sfnt_open_font( FT_Stream  stream,                  TT_Face    face )  {    FT_Memory  memory = stream->memory;    FT_Error   error;    FT_ULong   tag, offset;    static const FT_Frame_Field  ttc_header_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TTC_HeaderRec      FT_FRAME_START( 8 ),        FT_FRAME_LONG( version ),        FT_FRAME_LONG( count   ),      FT_FRAME_END    };    face->ttc_header.tag     = 0;    face->ttc_header.version = 0;    face->ttc_header.count   = 0;    offset = FT_STREAM_POS();    if ( FT_READ_ULONG( tag ) )      return error;    if ( tag != 0x00010000UL                      &&         tag != TTAG_ttcf                         &&         tag != FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) &&         tag != TTAG_true                         &&         tag != 0x00020000UL                      )      return SFNT_Err_Unknown_File_Format;    face->ttc_header.tag = TTAG_ttcf;    if ( tag == TTAG_ttcf )    {      FT_Int  n;      FT_TRACE3(( "sfnt_open_font: file is a collection/n" ));      if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )        return error;      /* now read the offsets of each font in the file */      if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )        return error;      if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )        return error;      for ( n = 0; n < face->ttc_header.count; n++ )        face->ttc_header.offsets[n] = FT_GET_ULONG();      FT_FRAME_EXIT();    }    else    {      FT_TRACE3(( "sfnt_open_font: synthesize TTC/n" ));      face->ttc_header.version = 1 << 16;      face->ttc_header.count   = 1;      if ( FT_NEW( face->ttc_header.offsets) )        return error;      face->ttc_header.offsets[0] = offset;    }    return error;  }
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:76,


示例5: pcf_read_TOC

  static FT_Error  pcf_read_TOC( FT_Stream  stream,                PCF_Face   face )  {    FT_Error   error;    PCF_Toc    toc = &face->toc;    PCF_Table  tables;    FT_Memory  memory = FT_FACE(face)->memory;    FT_UInt    n;    if ( FT_STREAM_SEEK ( 0 )                          ||         FT_STREAM_READ_FIELDS ( pcf_toc_header, toc ) )      return PCF_Err_Cannot_Open_Resource;    if ( toc->version != PCF_FILE_VERSION                 ||         toc->count   >  FT_ARRAY_MAX( face->toc.tables ) ||         toc->count   == 0                                )      return PCF_Err_Invalid_File_Format;    if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) )      return PCF_Err_Out_Of_Memory;    tables = face->toc.tables;    for ( n = 0; n < toc->count; n++ )    {      if ( FT_STREAM_READ_FIELDS( pcf_table_header, tables ) )        goto Exit;      tables++;    }    /* Sort tables and check for overlaps.  Because they are almost      */    /* always ordered already, an in-place bubble sort with simultaneous */    /* boundary checking seems appropriate.                              */    tables = face->toc.tables;    for ( n = 0; n < toc->count - 1; n++ )    {      FT_UInt  i, have_change;      have_change = 0;      for ( i = 0; i < toc->count - 1 - n; i++ )      {        PCF_TableRec  tmp;        if ( tables[i].offset > tables[i + 1].offset )        {          tmp           = tables[i];          tables[i]     = tables[i + 1];          tables[i + 1] = tmp;          have_change = 1;        }        if ( ( tables[i].size   > tables[i + 1].offset )                  ||             ( tables[i].offset > tables[i + 1].offset - tables[i].size ) )          return PCF_Err_Invalid_Offset;      }      if ( !have_change )        break;    }#ifdef FT_DEBUG_LEVEL_TRACE    {      FT_UInt      i, j;      const char*  name = "?";      FT_TRACE4(( "pcf_read_TOC:/n" ));      FT_TRACE4(( "  number of tables: %ld/n", face->toc.count ));      tables = face->toc.tables;      for ( i = 0; i < toc->count; i++ )      {        for ( j = 0; j < sizeof ( tableNames ) / sizeof ( tableNames[0] );              j++ )          if ( tables[i].type == (FT_UInt)( 1 << j ) )            name = tableNames[j];        FT_TRACE4(( "  %d: type=%s, format=0x%X, "                    "size=%ld (0x%lX), offset=%ld (0x%lX)/n",                    i, name,                    tables[i].format,                    tables[i].size, tables[i].size,                    tables[i].offset, tables[i].offset ));      }    }#endif    return PCF_Err_Ok;  Exit://.........这里部分代码省略.........
开发者ID:sheldonrobinson,项目名称:VcXsrv,代码行数:101,


示例6: pcf_read_TOC

  static FT_Error  pcf_read_TOC( FT_Stream  stream,                PCF_Face   face )  {    FT_Error   error;    PCF_Toc    toc = &face->toc;    PCF_Table  tables;    FT_Memory  memory = FT_FACE( face )->memory;    FT_UInt    n;    FT_ULong   size;    if ( FT_STREAM_SEEK( 0 )                          ||         FT_STREAM_READ_FIELDS( pcf_toc_header, toc ) )      return FT_THROW( Cannot_Open_Resource );    if ( toc->version != PCF_FILE_VERSION                 ||         toc->count   >  FT_ARRAY_MAX( face->toc.tables ) ||         toc->count   == 0                                )      return FT_THROW( Invalid_File_Format );    if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) )      return FT_THROW( Out_Of_Memory );    tables = face->toc.tables;    for ( n = 0; n < toc->count; n++ )    {      if ( FT_STREAM_READ_FIELDS( pcf_table_header, tables ) )        goto Exit;      tables++;    }    /* Sort tables and check for overlaps.  Because they are almost      */    /* always ordered already, an in-place bubble sort with simultaneous */    /* boundary checking seems appropriate.                              */    tables = face->toc.tables;    for ( n = 0; n < toc->count - 1; n++ )    {      FT_UInt  i, have_change;      have_change = 0;      for ( i = 0; i < toc->count - 1 - n; i++ )      {        PCF_TableRec  tmp;        if ( tables[i].offset > tables[i + 1].offset )        {          tmp           = tables[i];          tables[i]     = tables[i + 1];          tables[i + 1] = tmp;          have_change = 1;        }        if ( ( tables[i].size   > tables[i + 1].offset )                  ||             ( tables[i].offset > tables[i + 1].offset - tables[i].size ) )        {          error = FT_THROW( Invalid_Offset );          goto Exit;        }      }      if ( !have_change )        break;    }    /*     *  We now check whether the `size' and `offset' values are reasonable:     *  `offset' + `size' must not exceed the stream size.     *     *  Note, however, that X11's `pcfWriteFont' routine (used by the     *  `bdftopcf' program to create PDF font files) has two special     *  features.     *     *  - It always assigns the accelerator table a size of 100 bytes in the     *    TOC, regardless of its real size, which can vary between 34 and 72     *    bytes.     *     *  - Due to the way the routine is designed, it ships out the last font     *    table with its real size, ignoring the TOC's size value.  Since     *    the TOC size values are always rounded up to a multiple of 4, the     *    difference can be up to three bytes for all tables except the     *    accelerator table, for which the difference can be as large as 66     *    bytes.     *     */    tables = face->toc.tables;    size   = stream->size;    for ( n = 0; n < toc->count - 1; n++ )    {      /* we need two checks to avoid overflow */      if ( ( tables->size   > size                ) ||//.........这里部分代码省略.........
开发者ID:OpenTechEngine,项目名称:OpenTechBFG,代码行数:101,


示例7: sfnt_open_font

  /* synthesized into a TTC with one offset table.              */  static FT_Error  sfnt_open_font( FT_Stream  stream,                  TT_Face    face )  {    FT_Memory  memory = stream->memory;    FT_Error   error;    FT_ULong   tag, offset;    static const FT_Frame_Field  ttc_header_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TTC_HeaderRec      FT_FRAME_START( 8 ),        FT_FRAME_LONG( version ),        FT_FRAME_LONG( count   ),  /* this is ULong in the specs */      FT_FRAME_END    };    face->ttc_header.tag     = 0;    face->ttc_header.version = 0;    face->ttc_header.count   = 0;    offset = FT_STREAM_POS();    if ( FT_READ_ULONG( tag ) )      return error;    if ( tag != 0x00010000UL &&         tag != TTAG_ttcf    &&         tag != TTAG_OTTO    &&         tag != TTAG_true    &&         tag != TTAG_typ1    &&         tag != 0x00020000UL )    {      FT_TRACE2(( "  not a font using the SFNT container format/n" ));      return FT_THROW( Unknown_File_Format );    }    face->ttc_header.tag = TTAG_ttcf;    if ( tag == TTAG_ttcf )    {      FT_Int  n;      FT_TRACE3(( "sfnt_open_font: file is a collection/n" ));      if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )        return error;      if ( face->ttc_header.count == 0 )        return FT_THROW( Invalid_Table );      /* a rough size estimate: let's conservatively assume that there   */      /* is just a single table info in each subfont header (12 + 16*1 = */      /* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */      /* size of the TTC header plus `28*count' bytes for all subfont    */      /* headers                                                         */      if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )        return FT_THROW( Array_Too_Large );      /* now read the offsets of each font in the file */      if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )        return error;      if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )        return error;      for ( n = 0; n < face->ttc_header.count; n++ )        face->ttc_header.offsets[n] = FT_GET_ULONG();      FT_FRAME_EXIT();    }    else    {      FT_TRACE3(( "sfnt_open_font: synthesize TTC/n" ));      face->ttc_header.version = 1 << 16;      face->ttc_header.count   = 1;      if ( FT_NEW( face->ttc_header.offsets ) )        return error;      face->ttc_header.offsets[0] = offset;    }    return error;  }
开发者ID:kobolabs,项目名称:qt-everywhere-4.8.0,代码行数:91,


示例8: tt_face_load_os2

  tt_face_load_os2( TT_Face    face,                    FT_Stream  stream )  {    FT_Error  error;    TT_OS2*   os2;    static const FT_Frame_Field  os2_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TT_OS2      FT_FRAME_START( 78 ),        FT_FRAME_USHORT( version ),        FT_FRAME_SHORT ( xAvgCharWidth ),        FT_FRAME_USHORT( usWeightClass ),        FT_FRAME_USHORT( usWidthClass ),        FT_FRAME_SHORT ( fsType ),        FT_FRAME_SHORT ( ySubscriptXSize ),        FT_FRAME_SHORT ( ySubscriptYSize ),        FT_FRAME_SHORT ( ySubscriptXOffset ),        FT_FRAME_SHORT ( ySubscriptYOffset ),        FT_FRAME_SHORT ( ySuperscriptXSize ),        FT_FRAME_SHORT ( ySuperscriptYSize ),        FT_FRAME_SHORT ( ySuperscriptXOffset ),        FT_FRAME_SHORT ( ySuperscriptYOffset ),        FT_FRAME_SHORT ( yStrikeoutSize ),        FT_FRAME_SHORT ( yStrikeoutPosition ),        FT_FRAME_SHORT ( sFamilyClass ),        FT_FRAME_BYTE  ( panose[0] ),        FT_FRAME_BYTE  ( panose[1] ),        FT_FRAME_BYTE  ( panose[2] ),        FT_FRAME_BYTE  ( panose[3] ),        FT_FRAME_BYTE  ( panose[4] ),        FT_FRAME_BYTE  ( panose[5] ),        FT_FRAME_BYTE  ( panose[6] ),        FT_FRAME_BYTE  ( panose[7] ),        FT_FRAME_BYTE  ( panose[8] ),        FT_FRAME_BYTE  ( panose[9] ),        FT_FRAME_ULONG ( ulUnicodeRange1 ),        FT_FRAME_ULONG ( ulUnicodeRange2 ),        FT_FRAME_ULONG ( ulUnicodeRange3 ),        FT_FRAME_ULONG ( ulUnicodeRange4 ),        FT_FRAME_BYTE  ( achVendID[0] ),        FT_FRAME_BYTE  ( achVendID[1] ),        FT_FRAME_BYTE  ( achVendID[2] ),        FT_FRAME_BYTE  ( achVendID[3] ),        FT_FRAME_USHORT( fsSelection ),        FT_FRAME_USHORT( usFirstCharIndex ),        FT_FRAME_USHORT( usLastCharIndex ),        FT_FRAME_SHORT ( sTypoAscender ),        FT_FRAME_SHORT ( sTypoDescender ),        FT_FRAME_SHORT ( sTypoLineGap ),        FT_FRAME_USHORT( usWinAscent ),        FT_FRAME_USHORT( usWinDescent ),      FT_FRAME_END    };    static const FT_Frame_Field  os2_fields_extra[] =    {      FT_FRAME_START( 8 ),        FT_FRAME_ULONG( ulCodePageRange1 ),        FT_FRAME_ULONG( ulCodePageRange2 ),      FT_FRAME_END    };    static const FT_Frame_Field  os2_fields_extra2[] =    {      FT_FRAME_START( 10 ),        FT_FRAME_SHORT ( sxHeight ),        FT_FRAME_SHORT ( sCapHeight ),        FT_FRAME_USHORT( usDefaultChar ),        FT_FRAME_USHORT( usBreakChar ),        FT_FRAME_USHORT( usMaxContext ),      FT_FRAME_END    };    /* We now support old Mac fonts where the OS/2 table doesn't  */    /* exist.  Simply put, we set the `version' field to 0xFFFF   */    /* and test this value each time we need to access the table. */    error = face->goto_table( face, TTAG_OS2, stream, 0 );    if ( error )      goto Exit;    os2 = &face->os2;    if ( FT_STREAM_READ_FIELDS( os2_fields, os2 ) )      goto Exit;    os2->ulCodePageRange1 = 0;    os2->ulCodePageRange2 = 0;    os2->sxHeight         = 0;    os2->sCapHeight       = 0;    os2->usDefaultChar    = 0;    os2->usBreakChar      = 0;    os2->usMaxContext     = 0;    if ( os2->version >= 0x0001 )    {//.........这里部分代码省略.........
开发者ID:WHS-TechOps,项目名称:Aviator,代码行数:101,


示例9: tt_face_load_maxp

  tt_face_load_maxp( TT_Face    face,                     FT_Stream  stream )  {    FT_Error        error;    TT_MaxProfile*  maxProfile = &face->max_profile;    const FT_Frame_Field  maxp_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TT_MaxProfile      FT_FRAME_START( 6 ),        FT_FRAME_LONG  ( version ),        FT_FRAME_USHORT( numGlyphs ),      FT_FRAME_END    };    const FT_Frame_Field  maxp_fields_extra[] =    {      FT_FRAME_START( 26 ),        FT_FRAME_USHORT( maxPoints ),        FT_FRAME_USHORT( maxContours ),        FT_FRAME_USHORT( maxCompositePoints ),        FT_FRAME_USHORT( maxCompositeContours ),        FT_FRAME_USHORT( maxZones ),        FT_FRAME_USHORT( maxTwilightPoints ),        FT_FRAME_USHORT( maxStorage ),        FT_FRAME_USHORT( maxFunctionDefs ),        FT_FRAME_USHORT( maxInstructionDefs ),        FT_FRAME_USHORT( maxStackElements ),        FT_FRAME_USHORT( maxSizeOfInstructions ),        FT_FRAME_USHORT( maxComponentElements ),        FT_FRAME_USHORT( maxComponentDepth ),      FT_FRAME_END    };    error = face->goto_table( face, TTAG_maxp, stream, 0 );    if ( error )      goto Exit;    if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) )      goto Exit;    maxProfile->maxPoints             = 0;    maxProfile->maxContours           = 0;    maxProfile->maxCompositePoints    = 0;    maxProfile->maxCompositeContours  = 0;    maxProfile->maxZones              = 0;    maxProfile->maxTwilightPoints     = 0;    maxProfile->maxStorage            = 0;    maxProfile->maxFunctionDefs       = 0;    maxProfile->maxInstructionDefs    = 0;    maxProfile->maxStackElements      = 0;    maxProfile->maxSizeOfInstructions = 0;    maxProfile->maxComponentElements  = 0;    maxProfile->maxComponentDepth     = 0;    if ( maxProfile->version >= 0x10000L )    {      if ( FT_STREAM_READ_FIELDS( maxp_fields_extra, maxProfile ) )        goto Exit;      /* XXX: an adjustment that is necessary to load certain */      /*      broken fonts like `Keystrokes MT' :-(           */      /*                                                      */      /*   We allocate 64 function entries by default when    */      /*   the maxFunctionDefs field is null.                 */      if ( maxProfile->maxFunctionDefs == 0 )        maxProfile->maxFunctionDefs = 64;    }    FT_TRACE3(( "numGlyphs: %u/n", maxProfile->numGlyphs ));  Exit:    return error;  }
开发者ID:ShaneIsley,项目名称:challengeq3,代码行数:78,


示例10: cff_font_load

  cff_font_load( FT_Stream  stream,                 FT_Int     face_index,                 CFF_Font   font )  {    static const FT_Frame_Field  cff_header_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  CFF_FontRec      FT_FRAME_START( 4 ),        FT_FRAME_BYTE( version_major ),        FT_FRAME_BYTE( version_minor ),        FT_FRAME_BYTE( header_size ),        FT_FRAME_BYTE( absolute_offsize ),      FT_FRAME_END    };    FT_Error         error;    FT_Memory        memory = stream->memory;    FT_ULong         base_offset;    CFF_FontRecDict  dict;    FT_ZERO( font );    font->stream = stream;    font->memory = memory;    dict         = &font->top_font.font_dict;    base_offset  = FT_STREAM_POS();    /* read CFF font header */    if ( FT_STREAM_READ_FIELDS( cff_header_fields, font ) )      goto Exit;    /* check format */    if ( font->version_major   != 1 ||         font->header_size      < 4 ||         font->absolute_offsize > 4 )    {      FT_TRACE2(( "[not a CFF font header!]/n" ));      error = CFF_Err_Unknown_File_Format;      goto Exit;    }    /* skip the rest of the header */    if ( FT_STREAM_SKIP( font->header_size - 4 ) )      goto Exit;    /* read the name, top dict, string and global subrs index */    if ( FT_SET_ERROR( cff_new_index( &font->name_index,         stream, 0 )) ||         FT_SET_ERROR( cff_new_index( &font->font_dict_index,    stream, 0 )) ||         FT_SET_ERROR( cff_new_index( &font->string_index,       stream, 0 )) ||         FT_SET_ERROR( cff_new_index( &font->global_subrs_index, stream, 1 )) )      goto Exit;    /* well, we don't really forget the `disabled' fonts... */    font->num_faces = font->name_index.count;    if ( face_index >= (FT_Int)font->num_faces )    {      FT_ERROR(( "cff_font_load: incorrect face index = %d/n",                 face_index ));      error = CFF_Err_Invalid_Argument;    }    /* in case of a font format check, simply exit now */    if ( face_index < 0 )      goto Exit;    /* now, parse the top-level font dictionary */    error = cff_subfont_load( &font->top_font,                              &font->font_dict_index,                              face_index,                              stream,                              base_offset );    if ( error )      goto Exit;    /* now, check for a CID font */    if ( dict->cid_registry )    {      CFF_IndexRec  fd_index;      CFF_SubFont   sub;      FT_UInt       idx;      /* this is a CID-keyed font, we must now allocate a table of */      /* sub-fonts, then load each of them separately              */      if ( FT_STREAM_SEEK( base_offset + dict->cid_fd_array_offset ) )        goto Exit;      error = cff_new_index( &fd_index, stream, 0 );      if ( error )        goto Exit;      if ( fd_index.count > CFF_MAX_CID_FONTS )      {        FT_ERROR(( "cff_font_load: FD array too large in CID font/n" ));        goto Fail_CID;      }      /* allocate & read each font dict independently *///.........这里部分代码省略.........
开发者ID:1tgr,项目名称:mobius,代码行数:101,


示例11: tt_face_load_font_dir

  tt_face_load_font_dir( TT_Face    face,                         FT_Stream  stream )  {    SFNT_HeaderRec  sfnt;    FT_Error        error;    FT_Memory       memory = stream->memory;    TT_TableRec*    entry;    TT_TableRec*    limit;    static const FT_Frame_Field  offset_table_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  SFNT_HeaderRec      FT_FRAME_START( 8 ),        FT_FRAME_USHORT( num_tables ),        FT_FRAME_USHORT( search_range ),        FT_FRAME_USHORT( entry_selector ),        FT_FRAME_USHORT( range_shift ),      FT_FRAME_END    };    FT_TRACE2(( "tt_face_load_font_dir: %08p/n", face ));    /* read the offset table */    sfnt.offset = FT_STREAM_POS();    if ( FT_READ_ULONG( sfnt.format_tag )                    ||         FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) )      return error;    /* many fonts don't have these fields set correctly */#if 0    if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 )        ||         sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 )      return SFNT_Err_Unknown_File_Format;#endif    /* load the table directory */    FT_TRACE2(( "-- Tables count:   %12u/n",  sfnt.num_tables ));    FT_TRACE2(( "-- Format version: %08lx/n", sfnt.format_tag ));    /* check first */    error = check_table_dir( &sfnt, stream );    if ( error )    {      FT_TRACE2(( "tt_face_load_font_dir: invalid table directory!/n" ));      return error;    }    face->num_tables = sfnt.num_tables;    face->format_tag = sfnt.format_tag;    if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) )      return error;    if ( FT_STREAM_SEEK( sfnt.offset + 12 )       ||         FT_FRAME_ENTER( face->num_tables * 16L ) )      return error;    entry = face->dir_tables;    limit = entry + face->num_tables;    for ( ; entry < limit; entry++ )    {      entry->Tag      = FT_GET_TAG4();      entry->CheckSum = FT_GET_ULONG();      entry->Offset   = FT_GET_LONG();      entry->Length   = FT_GET_LONG();      FT_TRACE2(( "  %c%c%c%c  -  %08lx  -  %08lx/n",                  (FT_Char)( entry->Tag >> 24 ),                  (FT_Char)( entry->Tag >> 16 ),                  (FT_Char)( entry->Tag >> 8  ),                  (FT_Char)( entry->Tag       ),                  entry->Offset,                  entry->Length ));    }    FT_FRAME_EXIT();    FT_TRACE2(( "table directory loaded/n/n" ));    return error;  }
开发者ID:ShaneIsley,项目名称:challengeq3,代码行数:89,


示例12: check_table_dir

  static FT_Error  check_table_dir( SFNT_Header  sfnt,                   FT_Stream    stream )  {    FT_Error        error;    FT_UInt         nn;    FT_UInt         has_head = 0, has_sing = 0, has_meta = 0;    FT_ULong        offset = sfnt->offset + 12;    const FT_ULong  glyx_tag = FT_MAKE_TAG( 'g', 'l', 'y', 'x' );    const FT_ULong  locx_tag = FT_MAKE_TAG( 'l', 'o', 'c', 'x' );    static const FT_Frame_Field  table_dir_entry_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TT_TableRec      FT_FRAME_START( 16 ),        FT_FRAME_ULONG( Tag ),        FT_FRAME_ULONG( CheckSum ),        FT_FRAME_ULONG( Offset ),        FT_FRAME_ULONG( Length ),      FT_FRAME_END    };    if ( sfnt->num_tables == 0                         ||         offset + sfnt->num_tables * 16 > stream->size )      return SFNT_Err_Unknown_File_Format;    if ( FT_STREAM_SEEK( offset ) )      return error;    for ( nn = 0; nn < sfnt->num_tables; nn++ )    {      TT_TableRec  table;      if ( FT_STREAM_READ_FIELDS( table_dir_entry_fields, &table ) )        return error;      if ( table.Offset + table.Length > stream->size &&           table.Tag != glyx_tag                      &&           table.Tag != locx_tag                      )        return SFNT_Err_Unknown_File_Format;      if ( table.Tag == TTAG_head || table.Tag == TTAG_bhed )      {        FT_UInt32  magic;#ifndef TT_CONFIG_OPTION_EMBEDDED_BITMAPS        if ( table.Tag == TTAG_head )#endif          has_head = 1;        /*         * The table length should be 0x36, but certain font tools make it         * 0x38, so we will just check that it is greater.         *         * Note that according to the specification, the table must be         * padded to 32-bit lengths, but this doesn't apply to the value of         * its `Length' field!         *         */        if ( table.Length < 0x36 )          return SFNT_Err_Unknown_File_Format;        if ( FT_STREAM_SEEK( table.Offset + 12 ) ||             FT_READ_ULONG( magic )              )          return error;        if ( magic != 0x5F0F3CF5UL )          return SFNT_Err_Unknown_File_Format;        if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) )          return error;      }      else if ( table.Tag == TTAG_SING )        has_sing = 1;      else if ( table.Tag == TTAG_META )        has_meta = 1;    }    /* if `sing' and `meta' tables are present, there is no `head' table */    if ( has_head || ( has_sing && has_meta ) )      return SFNT_Err_Ok;    else      return SFNT_Err_Unknown_File_Format;  }
开发者ID:ShaneIsley,项目名称:challengeq3,代码行数:90,


示例13: woff_open_font

  static FT_Error  woff_open_font( FT_Stream  stream,                  TT_Face    face )  {    FT_Memory       memory = stream->memory;    FT_Error        error  = FT_Err_Ok;    WOFF_HeaderRec  woff;    WOFF_Table      tables  = NULL;    WOFF_Table*     indices = NULL;    FT_ULong        woff_offset;    FT_Byte*        sfnt        = NULL;    FT_Stream       sfnt_stream = NULL;    FT_Byte*        sfnt_header;    FT_ULong        sfnt_offset;    FT_Int          nn;    FT_ULong        old_tag = 0;    static const FT_Frame_Field  woff_header_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  WOFF_HeaderRec      FT_FRAME_START( 44 ),        FT_FRAME_ULONG ( signature ),        FT_FRAME_ULONG ( flavor ),        FT_FRAME_ULONG ( length ),        FT_FRAME_USHORT( num_tables ),        FT_FRAME_USHORT( reserved ),        FT_FRAME_ULONG ( totalSfntSize ),        FT_FRAME_USHORT( majorVersion ),        FT_FRAME_USHORT( minorVersion ),        FT_FRAME_ULONG ( metaOffset ),        FT_FRAME_ULONG ( metaLength ),        FT_FRAME_ULONG ( metaOrigLength ),        FT_FRAME_ULONG ( privOffset ),        FT_FRAME_ULONG ( privLength ),      FT_FRAME_END    };    FT_ASSERT( stream == face->root.stream );    FT_ASSERT( FT_STREAM_POS() == 0 );    if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) )      return error;    /* Make sure we don't recurse back here or hit TTC code. */    if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf )      return FT_THROW( Invalid_Table );    /* Miscellaneous checks. */    if ( woff.length != stream->size                              ||         woff.num_tables == 0                                     ||         44 + woff.num_tables * 20UL >= woff.length               ||         12 + woff.num_tables * 16UL >= woff.totalSfntSize        ||         ( woff.totalSfntSize & 3 ) != 0                          ||         ( woff.metaOffset == 0 && ( woff.metaLength != 0     ||                                     woff.metaOrigLength != 0 ) ) ||         ( woff.metaLength != 0 && woff.metaOrigLength == 0 )     ||         ( woff.privOffset == 0 && woff.privLength != 0 )         )      return FT_THROW( Invalid_Table );    if ( FT_ALLOC( sfnt, woff.totalSfntSize ) ||         FT_NEW( sfnt_stream )                )      goto Exit;    sfnt_header = sfnt;    /* Write sfnt header. */    {      FT_UInt  searchRange, entrySelector, rangeShift, x;      x             = woff.num_tables;      entrySelector = 0;      while ( x )      {        x            >>= 1;        entrySelector += 1;      }      entrySelector--;      searchRange = ( 1 << entrySelector ) * 16;      rangeShift  = woff.num_tables * 16 - searchRange;      WRITE_ULONG ( sfnt_header, woff.flavor );      WRITE_USHORT( sfnt_header, woff.num_tables );      WRITE_USHORT( sfnt_header, searchRange );      WRITE_USHORT( sfnt_header, entrySelector );      WRITE_USHORT( sfnt_header, rangeShift );    }    /* While the entries in the sfnt header must be sorted by the */    /* tag value, the tables themselves are not.  We thus have to */    /* sort them by offset and check that they don't overlap.     *///.........这里部分代码省略.........
开发者ID:johndpope,项目名称:Medusa,代码行数:101,


示例14: tt_face_load_maxp

  tt_face_load_maxp( TT_Face    face,                     FT_Stream  stream )  {    FT_Error        error;    TT_MaxProfile*  maxProfile = &face->max_profile;    static const FT_Frame_Field  maxp_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TT_MaxProfile      FT_FRAME_START( 6 ),        FT_FRAME_LONG  ( version ),        FT_FRAME_USHORT( numGlyphs ),      FT_FRAME_END    };    static const FT_Frame_Field  maxp_fields_extra[] =    {      FT_FRAME_START( 26 ),        FT_FRAME_USHORT( maxPoints ),        FT_FRAME_USHORT( maxContours ),        FT_FRAME_USHORT( maxCompositePoints ),        FT_FRAME_USHORT( maxCompositeContours ),        FT_FRAME_USHORT( maxZones ),        FT_FRAME_USHORT( maxTwilightPoints ),        FT_FRAME_USHORT( maxStorage ),        FT_FRAME_USHORT( maxFunctionDefs ),        FT_FRAME_USHORT( maxInstructionDefs ),        FT_FRAME_USHORT( maxStackElements ),        FT_FRAME_USHORT( maxSizeOfInstructions ),        FT_FRAME_USHORT( maxComponentElements ),        FT_FRAME_USHORT( maxComponentDepth ),      FT_FRAME_END    };    error = face->goto_table( face, TTAG_maxp, stream, 0 );    if ( error )      goto Exit;    if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) )      goto Exit;    maxProfile->maxPoints             = 0;    maxProfile->maxContours           = 0;    maxProfile->maxCompositePoints    = 0;    maxProfile->maxCompositeContours  = 0;    maxProfile->maxZones              = 0;    maxProfile->maxTwilightPoints     = 0;    maxProfile->maxStorage            = 0;    maxProfile->maxFunctionDefs       = 0;    maxProfile->maxInstructionDefs    = 0;    maxProfile->maxStackElements      = 0;    maxProfile->maxSizeOfInstructions = 0;    maxProfile->maxComponentElements  = 0;    maxProfile->maxComponentDepth     = 0;    if ( maxProfile->version >= 0x10000L )    {      if ( FT_STREAM_READ_FIELDS( maxp_fields_extra, maxProfile ) )        goto Exit;      /* XXX: an adjustment that is necessary to load certain */      /*      broken fonts like `Keystrokes MT' :-(           */      /*                                                      */      /*   We allocate 64 function entries by default when    */      /*   the maxFunctionDefs value is smaller.              */      if ( maxProfile->maxFunctionDefs < 64 )        maxProfile->maxFunctionDefs = 64;      /* we add 4 phantom points later */      if ( maxProfile->maxTwilightPoints > ( 0xFFFFU - 4 ) )      {        FT_TRACE0(( "tt_face_load_maxp:"                    " too much twilight points in `maxp' table;/n"                    "                  "                    " some glyphs might be rendered incorrectly/n" ));        maxProfile->maxTwilightPoints = 0xFFFFU - 4;      }      /* we arbitrarily limit recursion to avoid stack exhaustion */      if ( maxProfile->maxComponentDepth > 100 )      {        FT_TRACE0(( "tt_face_load_maxp:"                    " abnormally large component depth (%d) set to 100/n",                    maxProfile->maxComponentDepth ));        maxProfile->maxComponentDepth = 100;      }    }    FT_TRACE3(( "numGlyphs: %u/n", maxProfile->numGlyphs ));  Exit:    return error;  }
开发者ID:WHS-TechOps,项目名称:Aviator,代码行数:98,


示例15: fnt_face_get_dll_font

static FT_Errorfnt_face_get_dll_font( FNT_Face  face,                       FT_Int    face_index ){    FT_Error         error;    FT_Stream        stream = FT_FACE( face )->stream;    FT_Memory        memory = FT_FACE( face )->memory;    WinMZ_HeaderRec  mz_header;    face->font = 0;    /* does it begin with an MZ header? */    if ( FT_STREAM_SEEK( 0 )                                      ||            FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )        goto Exit;    error = FNT_Err_Unknown_File_Format;    if ( mz_header.magic == WINFNT_MZ_MAGIC )    {        /* yes, now look for an NE header in the file */        WinNE_HeaderRec  ne_header;        if ( FT_STREAM_SEEK( mz_header.lfanew )                       ||                FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) )            goto Exit;        error = FNT_Err_Unknown_File_Format;        if ( ne_header.magic == WINFNT_NE_MAGIC )        {            /* good, now look into the resource table for each FNT resource */            FT_ULong   res_offset  = mz_header.lfanew +                                     ne_header.resource_tab_offset;            FT_UShort  size_shift;            FT_UShort  font_count  = 0;            FT_ULong   font_offset = 0;            if ( FT_STREAM_SEEK( res_offset )                    ||                    FT_FRAME_ENTER( ne_header.rname_tab_offset -                                    ne_header.resource_tab_offset ) )                goto Exit;            size_shift = FT_GET_USHORT_LE();            for (;;)            {                FT_UShort  type_id, count;                type_id = FT_GET_USHORT_LE();                if ( !type_id )                    break;                count = FT_GET_USHORT_LE();                if ( type_id == 0x8008U )                {                    font_count  = count;                    font_offset = (FT_ULong)( FT_STREAM_POS() + 4 +                                              ( stream->cursor - stream->limit ) );                    break;                }                stream->cursor += 4 + count * 12;            }            FT_FRAME_EXIT();            if ( !font_count || !font_offset )            {                FT_TRACE2(( "this file doesn't contain any FNT resources!/n" ));                error = FNT_Err_Unknown_File_Format;                goto Exit;            }            face->root.num_faces = font_count;            if ( face_index >= font_count )            {                error = FNT_Err_Bad_Argument;                goto Exit;            }            if ( FT_NEW( face->font ) )                goto Exit;            if ( FT_STREAM_SEEK( font_offset + face_index * 12 ) ||                    FT_FRAME_ENTER( 12 )                            )                goto Fail;            face->font->offset     = (FT_ULong)FT_GET_USHORT_LE() << size_shift;            face->font->fnt_size   = (FT_ULong)FT_GET_USHORT_LE() << size_shift;            face->font->size_shift = size_shift;            stream->cursor += 8;            FT_FRAME_EXIT();//.........这里部分代码省略.........
开发者ID:1tgr,项目名称:mobius,代码行数:101,


示例16: tt_face_load_name

  tt_face_load_name( TT_Face    face,                     FT_Stream  stream )  {    FT_Error      error;    FT_Memory     memory = stream->memory;    FT_ULong      table_pos, table_len;    FT_ULong      storage_start, storage_limit;    FT_UInt       count;    TT_NameTable  table;    static const FT_Frame_Field  name_table_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TT_NameTableRec      FT_FRAME_START( 6 ),        FT_FRAME_USHORT( format ),        FT_FRAME_USHORT( numNameRecords ),        FT_FRAME_USHORT( storageOffset ),      FT_FRAME_END    };    static const FT_Frame_Field  name_record_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TT_NameEntryRec      /* no FT_FRAME_START */        FT_FRAME_USHORT( platformID ),        FT_FRAME_USHORT( encodingID ),        FT_FRAME_USHORT( languageID ),        FT_FRAME_USHORT( nameID ),        FT_FRAME_USHORT( stringLength ),        FT_FRAME_USHORT( stringOffset ),      FT_FRAME_END    };    table         = &face->name_table;    table->stream = stream;    error = face->goto_table( face, TTAG_name, stream, &table_len );    if ( error )      goto Exit;    table_pos = FT_STREAM_POS();    if ( FT_STREAM_READ_FIELDS( name_table_fields, table ) )      goto Exit;    /* Some popular Asian fonts have an invalid `storageOffset' value   */    /* (it should be at least "6 + 12*num_names").  However, the string */    /* offsets, computed as "storageOffset + entry->stringOffset", are  */    /* valid pointers within the name table...                          */    /*                                                                  */    /* We thus can't check `storageOffset' right now.                   */    /*                                                                  */    storage_start = table_pos + 6 + 12*table->numNameRecords;    storage_limit = table_pos + table_len;    if ( storage_start > storage_limit )    {      FT_ERROR(( "tt_face_load_name: invalid `name' table/n" ));      error = FT_THROW( Name_Table_Missing );      goto Exit;    }    /* Allocate the array of name records. */    count                 = table->numNameRecords;    table->numNameRecords = 0;    if ( FT_NEW_ARRAY( table->names, count ) ||         FT_FRAME_ENTER( count * 12 )        )      goto Exit;    /* Load the name records and determine how much storage is needed */    /* to hold the strings themselves.                                */    {      TT_NameEntryRec*  entry = table->names;      for ( ; count > 0; count-- )      {        if ( FT_STREAM_READ_FIELDS( name_record_fields, entry ) )          continue;        /* check that the name is not empty */        if ( entry->stringLength == 0 )          continue;        /* check that the name string is within the table */        entry->stringOffset += table_pos + table->storageOffset;        if ( entry->stringOffset                       < storage_start ||             entry->stringOffset + entry->stringLength > storage_limit )        {          /* invalid entry - ignore it */          entry->stringOffset = 0;          entry->stringLength = 0;          continue;//.........这里部分代码省略.........
开发者ID:WHS-TechOps,项目名称:Aviator,代码行数:101,


示例17: cff_font_load

  cff_font_load( FT_Library library,                 FT_Stream  stream,                 FT_Int     face_index,                 CFF_Font   font,                 FT_Bool    pure_cff )  {    static const FT_Frame_Field  cff_header_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  CFF_FontRec      FT_FRAME_START( 4 ),        FT_FRAME_BYTE( version_major ),        FT_FRAME_BYTE( version_minor ),        FT_FRAME_BYTE( header_size ),        FT_FRAME_BYTE( absolute_offsize ),      FT_FRAME_END    };    FT_Error         error;    FT_Memory        memory = stream->memory;    FT_ULong         base_offset;    CFF_FontRecDict  dict;    CFF_IndexRec     string_index;    FT_UInt          subfont_index;    FT_ZERO( font );    FT_ZERO( &string_index );    font->stream = stream;    font->memory = memory;    dict         = &font->top_font.font_dict;    base_offset  = FT_STREAM_POS();    /* read CFF font header */    if ( FT_STREAM_READ_FIELDS( cff_header_fields, font ) )      goto Exit;    /* check format */    if ( font->version_major   != 1 ||         font->header_size      < 4 ||         font->absolute_offsize > 4 )    {      FT_TRACE2(( "  not a CFF font header/n" ));      error = FT_THROW( Unknown_File_Format );      goto Exit;    }    /* skip the rest of the header */    if ( FT_STREAM_SKIP( font->header_size - 4 ) )      goto Exit;    /* read the name, top dict, string and global subrs index */    if ( FT_SET_ERROR( cff_index_init( &font->name_index,                                       stream, 0 ) )                  ||         FT_SET_ERROR( cff_index_init( &font->font_dict_index,                                       stream, 0 ) )                  ||         FT_SET_ERROR( cff_index_init( &string_index,                                       stream, 1 ) )                  ||         FT_SET_ERROR( cff_index_init( &font->global_subrs_index,                                       stream, 1 ) )                  ||         FT_SET_ERROR( cff_index_get_pointers( &string_index,                                               &font->strings,                                               &font->string_pool ) ) )      goto Exit;    font->num_strings = string_index.count;    if ( pure_cff )    {      /* well, we don't really forget the `disabled' fonts... */      subfont_index = (FT_UInt)( face_index & 0xFFFF );      if ( face_index > 0 && subfont_index >= font->name_index.count )      {        FT_ERROR(( "cff_font_load:"                   " invalid subfont index for pure CFF font (%d)/n",                   subfont_index ));        error = FT_THROW( Invalid_Argument );        goto Exit;      }      font->num_faces = font->name_index.count;    }    else    {      subfont_index = 0;      if ( font->name_index.count > 1 )      {        FT_ERROR(( "cff_font_load:"                   " invalid CFF font with multiple subfonts/n"                   "              "                   " in SFNT wrapper/n" ));        error = FT_THROW( Invalid_File_Format );        goto Exit;      }    }//.........这里部分代码省略.........
开发者ID:Johnny-Martin,项目名称:ComBase,代码行数:101,


示例18: tt_face_load_hhea

  tt_face_load_hhea( TT_Face    face,                     FT_Stream  stream,                     FT_Bool    vertical )  {    FT_Error        error;    TT_HoriHeader*  header;    static const FT_Frame_Field  metrics_header_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TT_HoriHeader      FT_FRAME_START( 36 ),        FT_FRAME_ULONG ( Version ),        FT_FRAME_SHORT ( Ascender ),        FT_FRAME_SHORT ( Descender ),        FT_FRAME_SHORT ( Line_Gap ),        FT_FRAME_USHORT( advance_Width_Max ),        FT_FRAME_SHORT ( min_Left_Side_Bearing ),        FT_FRAME_SHORT ( min_Right_Side_Bearing ),        FT_FRAME_SHORT ( xMax_Extent ),        FT_FRAME_SHORT ( caret_Slope_Rise ),        FT_FRAME_SHORT ( caret_Slope_Run ),        FT_FRAME_SHORT ( caret_Offset ),        FT_FRAME_SHORT ( Reserved[0] ),        FT_FRAME_SHORT ( Reserved[1] ),        FT_FRAME_SHORT ( Reserved[2] ),        FT_FRAME_SHORT ( Reserved[3] ),        FT_FRAME_SHORT ( metric_Data_Format ),        FT_FRAME_USHORT( number_Of_HMetrics ),      FT_FRAME_END    };    if ( vertical )    {      void  *v = &face->vertical;      error = face->goto_table( face, TTAG_vhea, stream, 0 );      if ( error )        goto Fail;      header = (TT_HoriHeader*)v;    }    else    {      error = face->goto_table( face, TTAG_hhea, stream, 0 );      if ( error )        goto Fail;      header = &face->horizontal;    }    if ( FT_STREAM_READ_FIELDS( metrics_header_fields, header ) )      goto Fail;    FT_TRACE3(( "Ascender:          %5d/n", header->Ascender ));    FT_TRACE3(( "Descender:         %5d/n", header->Descender ));    FT_TRACE3(( "number_Of_Metrics: %5u/n", header->number_Of_HMetrics ));    header->long_metrics  = NULL;    header->short_metrics = NULL;  Fail:    return error;  }
开发者ID:UnknownShadow200,项目名称:ClassicalSharp,代码行数:67,


示例19: pcf_get_properties

  static FT_Error  pcf_get_properties( FT_Stream  stream,                      PCF_Face   face )  {    PCF_ParseProperty  props      = 0;    PCF_Property       properties = 0;    FT_Int             nprops, i;    FT_ULong           format, size;    FT_Error           error;    FT_Memory          memory     = FT_FACE(face)->memory;    FT_ULong           string_size;    FT_String*         strings    = 0;    error = pcf_seek_to_table_type( stream,                                    face->toc.tables,                                    face->toc.count,                                    PCF_PROPERTIES,                                    &format,                                    &size );    if ( error )      goto Bail;    if ( FT_READ_ULONG_LE( format ) )      goto Bail;    FT_TRACE4(( "get_prop: format = %ld/n", format ));    if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )      goto Bail;    if ( PCF_BYTE_ORDER( format ) == MSBFirst )      (void)FT_READ_ULONG( nprops );    else      (void)FT_READ_ULONG_LE( nprops );    if ( error )      goto Bail;    FT_TRACE4(( "get_prop: nprop = %d/n", nprops ));    if ( FT_NEW_ARRAY( props, nprops ) )      goto Bail;    for ( i = 0; i < nprops; i++ )    {      if ( PCF_BYTE_ORDER( format ) == MSBFirst )      {        if ( FT_STREAM_READ_FIELDS( pcf_property_msb_header, props + i ) )          goto Bail;      }      else      {        if ( FT_STREAM_READ_FIELDS( pcf_property_header, props + i ) )          goto Bail;      }    }    /* pad the property array                                            */    /*                                                                   */    /* clever here - nprops is the same as the number of odd-units read, */    /* as only isStringProp are odd length   (Keith Packard)             */    /*                                                                   */    if ( nprops & 3 )    {      i = 4 - ( nprops & 3 );      FT_Stream_Skip( stream, i );    }    if ( PCF_BYTE_ORDER( format ) == MSBFirst )      (void)FT_READ_ULONG( string_size );    else      (void)FT_READ_ULONG_LE( string_size );    if ( error )      goto Bail;    FT_TRACE4(( "get_prop: string_size = %ld/n", string_size ));    if ( FT_NEW_ARRAY( strings, string_size ) )      goto Bail;    error = FT_Stream_Read( stream, (FT_Byte*)strings, string_size );    if ( error )      goto Bail;    if ( FT_NEW_ARRAY( properties, nprops ) )      goto Bail;    for ( i = 0; i < nprops; i++ )    {      /* XXX: make atom */      if ( FT_NEW_ARRAY( properties[i].name,                         ft_strlen( strings + props[i].name ) + 1 ) )        goto Bail;      ft_strcpy( properties[i].name,strings + props[i].name );      properties[i].isString = props[i].isString;      if ( props[i].isString )      {        if ( FT_NEW_ARRAY( properties[i].value.atom,//.........这里部分代码省略.........
开发者ID:stefanhendriks,项目名称:dune2themaker,代码行数:101,


示例20: pcf_get_properties

  static FT_Error  pcf_get_properties( FT_Stream  stream,                      PCF_Face   face )  {    PCF_ParseProperty  props      = 0;    PCF_Property       properties = NULL;    FT_ULong           nprops, i;    FT_ULong           format, size;    FT_Error           error;    FT_Memory          memory     = FT_FACE( face )->memory;    FT_ULong           string_size;    FT_String*         strings    = 0;    error = pcf_seek_to_table_type( stream,                                    face->toc.tables,                                    face->toc.count,                                    PCF_PROPERTIES,                                    &format,                                    &size );    if ( error )      goto Bail;    if ( FT_READ_ULONG_LE( format ) )      goto Bail;    FT_TRACE4(( "pcf_get_properties:/n" ));    FT_TRACE4(( "  format = %ld/n", format ));    if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )      goto Bail;    if ( PCF_BYTE_ORDER( format ) == MSBFirst )      (void)FT_READ_ULONG( nprops );    else      (void)FT_READ_ULONG_LE( nprops );    if ( error )      goto Bail;    FT_TRACE4(( "  nprop = %d (truncate %d props)/n",                (int)nprops, nprops - (int)nprops ));    nprops = (int)nprops;    /* rough estimate */    if ( nprops > size / PCF_PROPERTY_SIZE )    {      error = FT_THROW( Invalid_Table );      goto Bail;    }    face->nprops = (int)nprops;    if ( FT_NEW_ARRAY( props, nprops ) )      goto Bail;    for ( i = 0; i < nprops; i++ )    {      if ( PCF_BYTE_ORDER( format ) == MSBFirst )      {        if ( FT_STREAM_READ_FIELDS( pcf_property_msb_header, props + i ) )          goto Bail;      }      else      {        if ( FT_STREAM_READ_FIELDS( pcf_property_header, props + i ) )          goto Bail;      }    }    /* pad the property array                                            */    /*                                                                   */    /* clever here - nprops is the same as the number of odd-units read, */    /* as only isStringProp are odd length   (Keith Packard)             */    /*                                                                   */    if ( nprops & 3 )    {      i = 4 - ( nprops & 3 );      if ( FT_STREAM_SKIP( i ) )      {        error = FT_THROW( Invalid_Stream_Skip );        goto Bail;      }    }    if ( PCF_BYTE_ORDER( format ) == MSBFirst )      (void)FT_READ_ULONG( string_size );    else      (void)FT_READ_ULONG_LE( string_size );    if ( error )      goto Bail;    FT_TRACE4(( "  string_size = %ld/n", string_size ));    /* rough estimate */    if ( string_size > size - nprops * PCF_PROPERTY_SIZE )    {      error = FT_THROW( Invalid_Table );      goto Bail;//.........这里部分代码省略.........
开发者ID:OpenTechEngine,项目名称:OpenTechBFG,代码行数:101,


示例21: pcf_read_TOC

  static FT_Error  pcf_read_TOC( FT_Stream  stream,                PCF_Face   face )  {    FT_Error   error;    PCF_Toc    toc = &face->toc;    PCF_Table  tables;    FT_Memory  memory = FT_FACE(face)->memory;    FT_UInt    n;    if ( FT_STREAM_SEEK ( 0 )                          ||         FT_STREAM_READ_FIELDS ( pcf_toc_header, toc ) )      return PCF_Err_Cannot_Open_Resource;    if ( toc->version != PCF_FILE_VERSION )      return PCF_Err_Invalid_File_Format;    if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) )      return PCF_Err_Out_Of_Memory;    tables = face->toc.tables;    for ( n = 0; n < toc->count; n++ )    {      if ( FT_STREAM_READ_FIELDS( pcf_table_header, tables ) )        goto Exit;      tables++;    }#if defined( FT_DEBUG_LEVEL_TRACE )    {      FT_UInt      i, j;      const char*  name = "?";      FT_TRACE4(( "Tables count: %ld/n", face->toc.count ));      tables = face->toc.tables;      for ( i = 0; i < toc->count; i++ )      {        for( j = 0; j < sizeof ( tableNames ) / sizeof ( tableNames[0] ); j++ )          if ( tables[i].type == (FT_UInt)( 1 << j ) )            name = tableNames[j];        FT_TRACE4(( "Table %d: type=%-6s format=0x%04lX "                    "size=0x%06lX (%8ld) offset=0x%04lX/n",                    i, name,                    tables[i].format,                    tables[i].size, tables[i].size,                    tables[i].offset ));      }    }#endif    return PCF_Err_Ok;  Exit:    FT_FREE( face->toc.tables );    return error;  }
开发者ID:stefanhendriks,项目名称:dune2themaker,代码行数:62,


示例22: pcf_get_accel

  static FT_Error  pcf_get_accel( FT_Stream  stream,                 PCF_Face   face,                 FT_ULong   type )  {    FT_ULong   format, size;    FT_Error   error;    PCF_Accel  accel = &face->accel;    error = pcf_seek_to_table_type( stream,                                    face->toc.tables,                                    face->toc.count,                                    type,                                    &format,                                    &size );    if ( error )      goto Bail;    if ( FT_READ_ULONG_LE( format ) )      goto Bail;    if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT )    &&         !PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )      goto Bail;    if ( PCF_BYTE_ORDER( format ) == MSBFirst )    {      if ( FT_STREAM_READ_FIELDS( pcf_accel_msb_header, accel ) )        goto Bail;    }    else    {      if ( FT_STREAM_READ_FIELDS( pcf_accel_header, accel ) )        goto Bail;    }    error = pcf_get_metric( stream,                            format & ( ~PCF_FORMAT_MASK ),                            &(accel->minbounds) );    if ( error )      goto Bail;    error = pcf_get_metric( stream,                            format & ( ~PCF_FORMAT_MASK ),                            &(accel->maxbounds) );    if ( error )      goto Bail;    if ( PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )    {      error = pcf_get_metric( stream,                              format & ( ~PCF_FORMAT_MASK ),                              &(accel->ink_minbounds) );      if ( error )        goto Bail;      error = pcf_get_metric( stream,                              format & ( ~PCF_FORMAT_MASK ),                              &(accel->ink_maxbounds) );      if ( error )        goto Bail;    }    else    {      accel->ink_minbounds = accel->minbounds; /* I'm not sure about this */      accel->ink_maxbounds = accel->maxbounds;    }  Bail:    return error;  }
开发者ID:OpenTechEngine,项目名称:OpenTechBFG,代码行数:72,


示例23: tt_face_load_font_dir

  tt_face_load_font_dir( TT_Face    face,                         FT_Stream  stream )  {    SFNT_HeaderRec  sfnt;    FT_Error        error;    FT_Memory       memory = stream->memory;    FT_UShort       nn, valid_entries;    static const FT_Frame_Field  offset_table_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  SFNT_HeaderRec      FT_FRAME_START( 8 ),        FT_FRAME_USHORT( num_tables ),        FT_FRAME_USHORT( search_range ),        FT_FRAME_USHORT( entry_selector ),        FT_FRAME_USHORT( range_shift ),      FT_FRAME_END    };    FT_TRACE2(( "tt_face_load_font_dir: %08p/n", face ));    /* read the offset table */    sfnt.offset = FT_STREAM_POS();    if ( FT_READ_ULONG( sfnt.format_tag )                    ||         FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) )      goto Exit;    /* many fonts don't have these fields set correctly */#if 0    if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 )        ||         sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 )      return FT_THROW( Unknown_File_Format );#endif    /* load the table directory */    FT_TRACE2(( "-- Number of tables: %10u/n",    sfnt.num_tables ));    FT_TRACE2(( "-- Format version:   0x%08lx/n", sfnt.format_tag ));    if ( sfnt.format_tag != TTAG_OTTO )    {      /* check first */      error = check_table_dir( &sfnt, stream, &valid_entries );      if ( error )      {        FT_TRACE2(( "tt_face_load_font_dir:"                    " invalid table directory for TrueType/n" ));        goto Exit;      }    }    else      valid_entries = sfnt.num_tables;    face->num_tables = valid_entries;    face->format_tag = sfnt.format_tag;    if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) )      goto Exit;    if ( FT_STREAM_SEEK( sfnt.offset + 12 )      ||         FT_FRAME_ENTER( sfnt.num_tables * 16L ) )      goto Exit;    FT_TRACE2(( "/n"                "  tag    offset    length   checksum/n"                "  ----------------------------------/n" ));    valid_entries = 0;    for ( nn = 0; nn < sfnt.num_tables; nn++ )    {      TT_TableRec  entry;      FT_UShort    i;      FT_Bool      duplicate;      entry.Tag      = FT_GET_TAG4();      entry.CheckSum = FT_GET_ULONG();      entry.Offset   = FT_GET_ULONG();      entry.Length   = FT_GET_ULONG();      /* ignore invalid tables that can't be sanitized */      if ( entry.Offset > stream->size )        continue;      else if ( entry.Length > stream->size - entry.Offset )      {        if ( entry.Tag == TTAG_hmtx ||             entry.Tag == TTAG_vmtx )        {#ifdef FT_DEBUG_LEVEL_TRACE          FT_ULong  old_length = entry.Length;#endif          /* make metrics table length a multiple of 4 *///.........这里部分代码省略.........
开发者ID:yangacer,项目名称:freetype,代码行数:101,



注:本文中的FT_STREAM_READ_FIELDS函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ FT_STREAM_SEEK函数代码示例
C++ FT_STREAM_READ函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。