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

📄 ttload.c

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 C
📖 第 1 页 / 共 5 页
字号:
          for ( ; cur < limit; cur++ )          cur->string = names->storage + cur->stringOffset;      }#ifdef FT_DEBUG_LEVEL_TRACE        /* Print Name Record Table in case of debugging */      {        TT_NameRec*  cur   = names->names;        TT_NameRec*  limit = cur + names->numNameRecords;        for ( ; cur < limit; cur++ )        {          TT_UInt  j;              FT_TRACE2(( "%d %d %x %d ",                       cur->platformID,                       cur->encodingID,                       cur->languageID,                       cur->nameID ));              /* I know that M$ encoded strings are Unicode,            */          /* but this works reasonable well for debugging purposes. */          if ( cur->string )            for ( j = 0; j < cur->stringLength; j++ )            {              TT_Char  c = *(cur->string + j);                  if ( (TT_Byte)c < 128 )                FT_TRACE2(( "%c", c ));            }        }      }      FT_TRACE2(( "\n" ));#endif    }    FT_TRACE2(( "loaded\n" ));  Exit:    return error;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    TT_Free_Names                                                      */  /*                                                                       */  /* <Description>                                                         */  /*    Frees the name records.                                            */  /*                                                                       */  /* <Input>                                                               */  /*    face :: A handle to the target face object.                        */  /*                                                                       */  LOCAL_FUNC  void  TT_Free_Names( TT_Face  face )  {    FT_Memory      memory = face->root.driver->memory;    TT_NameTable*  names  = &face->name_table;    /* free strings table */    FREE( names->names );    /* free strings storage */    FREE( names->storage );    names->numNameRecords = 0;    names->format         = 0;    names->storageOffset  = 0;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    TT_Load_CMap                                                       */  /*                                                                       */  /* <Description>                                                         */  /*    Loads the cmap directory in a face object.  The cmaps itselves are */  /*    loaded on demand in the `ttcmap.c' module.                         */  /*                                                                       */  /* <Input>                                                               */  /*    face    :: A handle to the target face object.                     */  /*    stream  :: A handle to the input stream.                           */  /*                                                                       */  /* <Return>                                                              */  /*     TrueType error code.  0 means success.                            */  /*                                                                       */  LOCAL_FUNC  TT_Error  TT_Load_CMap( TT_Face    face,                          FT_Stream  stream )  {    TT_Error    error;    FT_Memory   memory = stream->memory;    TT_Long     table_start;    TT_CMapDir  cmap_dir;#ifdef READ_FIELDS    const FT_Frame_Field  cmap_fields[] = {              { ft_frame_start, 0, 4 },                FT_FRAME_USHORT( TT_CMapDir, tableVersionNumber ),                FT_FRAME_USHORT( TT_CMapDir, numCMaps ),              { ft_frame_end } };    const FT_Frame_Field  cmap_rec_fields[] = {              { ft_frame_start, 0, 6 },                FT_FRAME_USHORT( TT_CMapTable, format ),                FT_FRAME_USHORT( TT_CMapTable, length ),                FT_FRAME_USHORT( TT_CMapTable, version ),              { ft_frame_end } };#endif    FT_TRACE2(( "CMaps " ));    error = face->goto_table( face, TTAG_cmap, stream, 0 );    if (error)    {      error = TT_Err_CMap_Table_Missing;      goto Exit;    }    table_start = FILE_Pos();#ifdef READ_FIELDS    if ( READ_Fields( cmap_fields, &cmap_dir ) ) goto Exit;#else    if ( ACCESS_Frame( 4L ) )           /* 4 bytes cmap header */      goto Exit;    cmap_dir.tableVersionNumber = GET_UShort();    cmap_dir.numCMaps           = GET_UShort();    FORGET_Frame();#endif    /* save space in face table for cmap tables */    if ( ALLOC_ARRAY( face->charmaps,                      cmap_dir.numCMaps,                      TT_CharMapRec ) )      goto Exit;    face->num_charmaps = cmap_dir.numCMaps;    {      TT_CharMap  charmap = face->charmaps;      TT_CharMap  limit   = charmap + face->num_charmaps;      /* read the header of each charmap first */      if ( ACCESS_Frame( face->num_charmaps*8L ) ) goto Exit;      for ( ; charmap < limit; charmap++ )      {        TT_CMapTable*  cmap;        charmap->root.face = (FT_Face)face;        cmap               = &charmap->cmap;        cmap->loaded             = FALSE;        cmap->platformID         = GET_UShort();        cmap->platformEncodingID = GET_UShort();        cmap->offset             = (TT_ULong)GET_Long();      }      FORGET_Frame();            /* now read the rest of each table */      for ( charmap = face->charmaps; charmap < limit; charmap++ )      {        TT_CMapTable* cmap = &charmap->cmap;        #ifdef READ_FIELDS        if ( FILE_Seek( table_start + (TT_Long)cmap->offset ) ||             READ_Fields( cmap_rec_fields, cmap )             )          goto Exit;#else        if ( FILE_Seek( table_start + (TT_Long)cmap->offset ) ||             ACCESS_Frame(6L) )          goto Exit;                cmap->format  = GET_UShort();        cmap->length  = GET_UShort();        cmap->version = GET_UShort();                FORGET_Frame();#endif        cmap->offset = FILE_Pos();      }    }    FT_TRACE2(( "loaded\n" ));  Exit:    return error;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    TT_Load_OS2                                                        */  /*                                                                       */  /* <Description>                                                         */  /*    Loads the OS2 table.                                               */  /*                                                                       */  /* <Input>                                                               */  /*    face   :: A handle to the target face object.                      */  /*    stream :: A handle to the input stream.                            */  /*                                                                       */  /* <Return>                                                              */  /*    TrueType error code.  0 means success.                             */  /*                                                                       */  LOCAL_FUNC  TT_Error  TT_Load_OS2( TT_Face    face,                         FT_Stream  stream )  {    TT_Error  error;    TT_OS2*   os2;#ifdef READ_FIELDS    const FT_Frame_Field  os2_fields[] = {              { ft_frame_start, 0, 78 },                FT_FRAME_USHORT( TT_OS2, version ),                FT_FRAME_SHORT(  TT_OS2, xAvgCharWidth ),                FT_FRAME_USHORT( TT_OS2, usWeightClass ),                FT_FRAME_USHORT( TT_OS2, usWidthClass ),                FT_FRAME_SHORT(  TT_OS2, fsType ),                FT_FRAME_SHORT(  TT_OS2, ySubscriptXSize ),                FT_FRAME_SHORT(  TT_OS2, ySubscriptYSize ),                FT_FRAME_SHORT(  TT_OS2, ySubscriptXOffset ),                FT_FRAME_SHORT(  TT_OS2, ySubscriptYOffset ),                FT_FRAME_SHORT(  TT_OS2, ySuperscriptXSize ),                FT_FRAME_SHORT(  TT_OS2, ySuperscriptYSize ),                FT_FRAME_SHORT(  TT_OS2, ySuperscriptXOffset ),                FT_FRAME_SHORT(  TT_OS2, ySuperscriptYOffset ),                FT_FRAME_SHORT(  TT_OS2, yStrikeoutSize ),                FT_FRAME_SHORT(  TT_OS2, yStrikeoutPosition ),                FT_FRAME_SHORT(  TT_OS2, sFamilyClass ),                FT_FRAME_BYTE(   TT_OS2, panose[0] ),                FT_FRAME_BYTE(   TT_OS2, panose[1] ),                FT_FRAME_BYTE(   TT_OS2, panose[2] ),                FT_FRAME_BYTE(   TT_OS2, panose[3] ),                FT_FRAME_BYTE(   TT_OS2, panose[4] ),                FT_FRAME_BYTE(   TT_OS2, panose[5] ),                FT_FRAME_BYTE(   TT_OS2, panose[6] ),                FT_FRAME_BYTE(   TT_OS2, panose[7] ),                FT_FRAME_BYTE(   TT_OS2, panose[8] ),                FT_FRAME_BYTE(   TT_OS2, panose[9] ),                FT_FRAME_ULONG(  TT_OS2, ulUnicodeRange1 ),                FT_FRAME_ULONG(  TT_OS2, ulUnicodeRange2 ),                FT_FRAME_ULONG(  TT_OS2, ulUnicodeRange3 ),                FT_FRAME_ULONG(  TT_OS2, ulUnicodeRange4 ),                FT_FRAME_BYTE(   TT_OS2, achVendID[0] ),                FT_FRAME_BYTE(   TT_OS2, achVendID[1] ),                FT_FRAME_BYTE(   TT_OS2, achVendID[2] ),                FT_FRAME_BYTE(   TT_OS2, achVendID[3] ),                FT_FRAME_USHORT( TT_OS2, fsSelection ),                FT_FRAME_USHORT( TT_OS2, usFirstCharIndex ),                FT_FRAME_USHORT( TT_OS2, usLastCharIndex ),                FT_FRAME_SHORT(  TT_OS2, sTypoAscender ),                FT_FRAME_SHORT(  TT_OS2, sTypoDescender ),                FT_FRAME_SHORT(  TT_OS2, sTypoLineGap ),                FT_FRAME_USHORT( TT_OS2, usWinAscent ),                FT_FRAME_USHORT( TT_OS2, usWinDescent ),              { ft_frame_end } };                  const FT_Frame_Field  os2_fields_extra[] = {              { ft_frame_start, 0, 8 },                FT_FRAME_ULONG( TT_OS2, ulCodePageRange1 ),                FT_FRAME_ULONG( TT_OS2, ulCodePageRange2 ),              { ft_frame_end } };#else    TT_Int    j;#endif    FT_TRACE2(( "OS/2 Table " ));    /* 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)    {      FT_TRACE2(( "is missing\n!" ));      face->os2.version = 0xFFFF;      error = TT_Err_Ok;      goto Exit;    }    os2 = &face->os2;#ifdef READ_FIELDS    if ( READ_Fields( os2_fields, os2 ) ) goto Exit;#else    if ( ACCESS_Frame( 78L ) )      goto Exit;    os2->version             = GET_UShort();    os2->xAvgCharWidth       = GET_Short();    os2->usWeightClass       = GET_UShort();    os2->usWidthClass        = GET_UShort();    os2->fsType              = GET_Short();    os2->ySubscriptXSize     = GET_Short();    os2->ySubscriptYSize     = GET_Short();    os2->ySubscriptXOffset   = GET_Short();    os2->ySubscriptYOffset   = GET_Short();    os2->ySuperscriptXSize   = GET_Short();    os2->ySuperscriptYSize   = GET_Short();    os2->ySuperscriptXOffset = GET_Short();    os2->ySuperscriptYOffset = GET_Short();    os2->yStrikeoutSize      = GET_Short();    os2->yStrikeoutPosition  = GET_Short();    os2->sFamilyClass        = GET_Short();    for ( j = 0; j < 10; j++ )      os2->panose[j] = GET_Byte();    os2->ulUnicodeRange1     = GET_ULong();    os2->ulUnicodeRange2     = GET_ULong();    os2->ulUnicodeRange3     = GET_ULong();    os2->ulUnicodeRange4     = GET_ULong();    for ( j = 0; j < 4; j++ )      os2->achVendID[j] = GET_Byte();    os2->fsSelection         = GET_UShort();    os2->usFirstCharIndex    = GET_UShort();    os2->usLastCharIndex     = GET_UShort();    os2->sTypoAscender       = GET_Short();    os2->sTypoDescender      = GET_Short();    os2->sTypoLineGap        = GET_Short();    os2->usWinAscent         = GET_UShort();    os2->usWinDescent        = GET_UShort();    FORGET_Frame();#endif    os2->ulCodePageRange1 = 0;

⌨️ 快捷键说明

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