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

📄 ttload.c

📁 下载来的一个看图软件的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    FT_TRACE2(( "loaded\n" ));  Exit:    return error;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    tt_face_load_postscript                                            */  /*                                                                       */  /* <Description>                                                         */  /*    Loads the Postscript table.                                        */  /*                                                                       */  /* <Input>                                                               */  /*    face   :: A handle to the target face object.                      */  /*                                                                       */  /*    stream :: A handle to the input stream.                            */  /*                                                                       */  /* <Return>                                                              */  /*    FreeType error code.  0 means success.                             */  /*                                                                       */  FT_LOCAL_DEF( FT_Error )  tt_face_load_postscript( TT_Face    face,                           FT_Stream  stream )  {    FT_Error        error;    TT_Postscript*  post = &face->postscript;    static const FT_Frame_Field  post_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TT_Postscript      FT_FRAME_START( 32 ),        FT_FRAME_ULONG( FormatType ),        FT_FRAME_ULONG( italicAngle ),        FT_FRAME_SHORT( underlinePosition ),        FT_FRAME_SHORT( underlineThickness ),        FT_FRAME_ULONG( isFixedPitch ),        FT_FRAME_ULONG( minMemType42 ),        FT_FRAME_ULONG( maxMemType42 ),        FT_FRAME_ULONG( minMemType1 ),        FT_FRAME_ULONG( maxMemType1 ),      FT_FRAME_END    };    FT_TRACE2(( "PostScript " ));    error = face->goto_table( face, TTAG_post, stream, 0 );    if ( error )      return SFNT_Err_Post_Table_Missing;    if ( FT_STREAM_READ_FIELDS( post_fields, post ) )      return error;    /* we don't load the glyph names, we do that in another */    /* module (ttpost).                                     */    FT_TRACE2(( "loaded\n" ));    return SFNT_Err_Ok;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    tt_face_load_pclt                                                  */  /*                                                                       */  /* <Description>                                                         */  /*    Loads the PCL 5 Table.                                             */  /*                                                                       */  /* <Input>                                                               */  /*    face   :: A handle to the target face object.                      */  /*                                                                       */  /*    stream :: A handle to the input stream.                            */  /*                                                                       */  /* <Return>                                                              */  /*    FreeType error code.  0 means success.                             */  /*                                                                       */  FT_LOCAL_DEF( FT_Error )  tt_face_load_pclt( TT_Face    face,                     FT_Stream  stream )  {    static const FT_Frame_Field  pclt_fields[] =    {#undef  FT_STRUCTURE#define FT_STRUCTURE  TT_PCLT      FT_FRAME_START( 54 ),        FT_FRAME_ULONG ( Version ),        FT_FRAME_ULONG ( FontNumber ),        FT_FRAME_USHORT( Pitch ),        FT_FRAME_USHORT( xHeight ),        FT_FRAME_USHORT( Style ),        FT_FRAME_USHORT( TypeFamily ),        FT_FRAME_USHORT( CapHeight ),        FT_FRAME_BYTES ( TypeFace, 16 ),        FT_FRAME_BYTES ( CharacterComplement, 8 ),        FT_FRAME_BYTES ( FileName, 6 ),        FT_FRAME_CHAR  ( StrokeWeight ),        FT_FRAME_CHAR  ( WidthType ),        FT_FRAME_BYTE  ( SerifStyle ),        FT_FRAME_BYTE  ( Reserved ),      FT_FRAME_END    };    FT_Error  error;    TT_PCLT*  pclt = &face->pclt;    FT_TRACE2(( "PCLT " ));    /* optional table */    error = face->goto_table( face, TTAG_PCLT, stream, 0 );    if ( error )    {      FT_TRACE2(( "missing (optional)\n" ));      pclt->Version = 0;      return SFNT_Err_Ok;    }    if ( FT_STREAM_READ_FIELDS( pclt_fields, pclt ) )      goto Exit;    FT_TRACE2(( "loaded\n" ));  Exit:    return error;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    tt_face_load_gasp                                                  */  /*                                                                       */  /* <Description>                                                         */  /*    Loads the `gasp' table into a face object.                         */  /*                                                                       */  /* <Input>                                                               */  /*    face   :: A handle to the target face object.                      */  /*                                                                       */  /*    stream :: The input stream.                                        */  /*                                                                       */  /* <Return>                                                              */  /*    FreeType error code.  0 means success.                             */  /*                                                                       */  FT_LOCAL_DEF( FT_Error )  tt_face_load_gasp( TT_Face    face,                     FT_Stream  stream )  {    FT_Error   error;    FT_Memory  memory = stream->memory;    FT_UInt        j,num_ranges;    TT_GaspRange   gaspranges;    FT_TRACE2(( "tt_face_load_gasp: %08p\n", face ));    /* the gasp table is optional */    error = face->goto_table( face, TTAG_gasp, stream, 0 );    if ( error )      return SFNT_Err_Ok;    if ( FT_FRAME_ENTER( 4L ) )      goto Exit;    face->gasp.version   = FT_GET_USHORT();    face->gasp.numRanges = FT_GET_USHORT();    FT_FRAME_EXIT();    num_ranges = face->gasp.numRanges;    FT_TRACE3(( "number of ranges = %d\n", num_ranges ));    if ( FT_NEW_ARRAY( gaspranges, num_ranges ) ||         FT_FRAME_ENTER( num_ranges * 4L )      )      goto Exit;    face->gasp.gaspRanges = gaspranges;    for ( j = 0; j < num_ranges; j++ )    {      gaspranges[j].maxPPEM  = FT_GET_USHORT();      gaspranges[j].gaspFlag = FT_GET_USHORT();      FT_TRACE3(( " [max:%d flag:%d]",                    gaspranges[j].maxPPEM,                    gaspranges[j].gaspFlag ));    }    FT_TRACE3(( "\n" ));    FT_FRAME_EXIT();    FT_TRACE2(( "GASP loaded\n" ));  Exit:    return error;  }  FT_CALLBACK_DEF( int )  tt_kern_pair_compare( const void*  a,                        const void*  b );  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    tt_face_load_kern                                                  */  /*                                                                       */  /* <Description>                                                         */  /*    Loads the first kerning table with format 0 in the font.  Only     */  /*    accepts the first horizontal kerning table.  Developers should use */  /*    the `ftxkern' extension to access other kerning tables in the font */  /*    file, if they really want to.                                      */  /*                                                                       */  /* <Input>                                                               */  /*    face   :: A handle to the target face object.                      */  /*                                                                       */  /*    stream :: The input stream.                                        */  /*                                                                       */  /* <Return>                                                              */  /*    FreeType error code.  0 means success.                             */  /*                                                                       */  FT_LOCAL_DEF( FT_Error )  tt_face_load_kern( TT_Face    face,                     FT_Stream  stream )  {    FT_Error   error;    FT_Memory  memory = stream->memory;    FT_UInt    n, num_tables;    /* the kern table is optional; exit silently if it is missing */    error = face->goto_table( face, TTAG_kern, stream, 0 );    if ( error )      return SFNT_Err_Ok;    if ( FT_FRAME_ENTER( 4L ) )      goto Exit;    (void)FT_GET_USHORT();         /* version */    num_tables = FT_GET_USHORT();    FT_FRAME_EXIT();    for ( n = 0; n < num_tables; n++ )    {      FT_UInt  coverage;      FT_UInt  length;      if ( FT_FRAME_ENTER( 6L ) )        goto Exit;      (void)FT_GET_USHORT();           /* version                 */      length   = FT_GET_USHORT() - 6;  /* substract header length */      coverage = FT_GET_USHORT();      FT_FRAME_EXIT();      if ( coverage == 0x0001 )      {        FT_UInt        num_pairs;        TT_Kern0_Pair  pair;        TT_Kern0_Pair  limit;        /* found a horizontal format 0 kerning table! */        if ( FT_FRAME_ENTER( 8L ) )          goto Exit;        num_pairs = FT_GET_USHORT();        /* skip the rest */        FT_FRAME_EXIT();        /* allocate array of kerning pairs */        if ( FT_NEW_ARRAY( face->kern_pairs, num_pairs ) ||             FT_FRAME_ENTER( 6L * num_pairs )            )          goto Exit;        pair  = face->kern_pairs;        limit = pair + num_pairs;        for ( ; pair < limit; pair++ )        {          pair->left  = FT_GET_USHORT();          pair->right = FT_GET_USHORT();          pair->value = FT_GET_USHORT();        }        FT_FRAME_EXIT();        face->num_kern_pairs   = num_pairs;        face->kern_table_index = n;        /* ensure that the kerning pair table is sorted (yes, some */        /* fonts have unsorted tables!)                            */        {          FT_UInt        i;          TT_Kern0_Pair  pair0;          pair0 = face->kern_pairs;          for ( i = 1; i < num_pairs; i++, pair0++ )          {            if ( tt_kern_pair_compare( pair0, pair0 + 1 ) != -1 )            {              ft_qsort( (void*)face->kern_pairs, (int)num_pairs,                        sizeof ( TT_Kern0_PairRec ), tt_kern_pair_compare );              break;            }          }        }        goto Exit;      }      if ( FT_STREAM_SKIP( length ) )        goto Exit;    }    /* no kern table found -- doesn't matter */    face->kern_table_index = -1;    face->num_kern_pairs   = 0;    face->kern_pairs       = NULL;  Exit:    return error;  }#undef  TT_KERN_INDEX#define TT_KERN_INDEX( g1, g2 )  ( ( (FT_ULong)g1 << 16 ) | g2 )  FT_CALLBACK_DEF( int )  tt_kern_pair_compare( co

⌨️ 快捷键说明

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