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

📄 ftdump.c

📁 freetype库的应用demo,里面包含freetype的很多实例
💻 C
📖 第 1 页 / 共 2 页
字号:
      case 0x2013:        fputs( "--", stdout );        break;      case 0x2019:        fputs( "\'", stdout );        break;      case 0x2122:        fputs( "(tm)", stdout );        break;      default:        if ( ch < 256 )          putchar( ch );        else          printf( "\\U+%04X", ch );        break;      }    }    if ( ch != '\n' )      putchar( '"' );  }  void  Print_Sfnt_Names( FT_Face  face )  {    FT_SfntName  name;    FT_UInt      num_names, i;    printf( "font string entries\n" );    num_names = FT_Get_Sfnt_Name_Count( face );    for ( i = 0; i < num_names; i++ )    {      error = FT_Get_Sfnt_Name( face, i, &name );      if ( error == FT_Err_Ok )      {        printf( "   %-15s [%s]", name_id( name.name_id ),                                 platform_id( name.platform_id ) );        switch ( name.platform_id )        {        case TT_PLATFORM_APPLE_UNICODE:          switch ( name.encoding_id )          {          case TT_APPLE_ID_DEFAULT:          case TT_APPLE_ID_UNICODE_1_1:          case TT_APPLE_ID_ISO_10646:          case TT_APPLE_ID_UNICODE_2_0:            put_unicode_be16( name.string, name.string_len, 6 );            break;          default:            printf( "{unsupported encoding %d}", name.encoding_id );            break;          }          break;        case TT_PLATFORM_MACINTOSH:          if ( name.language_id != TT_MAC_LANGID_ENGLISH )            printf( " (language=%d)", name.language_id );          fputs( ":\n", stdout );          switch ( name.encoding_id )          {          case TT_MAC_ID_ROMAN:            /* FIXME: convert from MacRoman to ASCII/ISO8895-1/whatever */            /* (MacRoman is mostly like ISO8895-1 but there are         */            /* differences)                                             */            put_ascii( name.string, name.string_len, 6 );            break;          default:            printf( "{unsupported encoding %d}", name.encoding_id );            break;          }          break;        case TT_PLATFORM_ISO:          switch ( name.encoding_id )          {          case TT_ISO_ID_7BIT_ASCII:          case TT_ISO_ID_8859_1:            put_ascii( name.string, name.string_len, 6 );            break;          case TT_ISO_ID_10646:            put_unicode_be16( name.string, name.string_len, 6 );            break;          default:            printf( "{unsupported encoding %d}", name.encoding_id );            break;          }          break;        case TT_PLATFORM_MICROSOFT:          if ( name.language_id != TT_MS_LANGID_ENGLISH_UNITED_STATES )            printf( " (language=0x%04x)", name.language_id );          fputs( ":\n", stdout );          switch ( name.encoding_id )          {          /* TT_MS_ID_SYMBOL_CS is supposed to be Unicode, according to */          /* information from the MS font development team              */          case TT_MS_ID_SYMBOL_CS:          case TT_MS_ID_UNICODE_CS:            put_unicode_be16( name.string, name.string_len, 6 );            break;          default:            printf( "{unsupported encoding %d}", name.encoding_id );            break;          }          break;        default:          printf( "{unsupported platform}" );          break;        }        printf( "\n" );      }    }  }  void  Print_Fixed( FT_Face  face )  {    int  i;    /* num_fixed_size */    printf( "fixed size\n" );    /* available size */    for ( i = 0; i < face->num_fixed_sizes; i++ )    {      FT_Bitmap_Size*  bsize = face->available_sizes + i;      printf( "   %3d: height %d, width %d\n",              i, bsize->height, bsize->width );      printf( "        size %.3f, x_ppem %.3f, y_ppem %.3f\n",              bsize->size / 64.0,              bsize->x_ppem / 64.0, bsize->y_ppem / 64.0 );    }  }  void  Print_Charmaps( FT_Face  face )  {    int  i;    /* CharMaps */    printf( "charmaps\n" );    for( i = 0; i < face->num_charmaps; i++ )    {      printf( "   %d: platform: %d, encoding: %d\n",              i,              face->charmaps[i]->platform_id,              face->charmaps[i]->encoding_id );    }  }  int  main( int    argc,        char*  argv[] )  {    int    i, file;    char   filename[128 + 4];    char   alt_filename[128 + 4];    char*  execname;    int    num_faces;    int    option;    FT_Library  library;      /* the FreeType library */    FT_Face     face;         /* the font face        */    execname = ft_basename( argv[0] );    while ( 1 )    {      option = getopt( argc, argv, "dl:n" );      if ( option == -1 )        break;      switch ( option )      {      case 'd':        debug = 1;        break;      case 'l':        trace_level = atoi( optarg );        if ( trace_level < 1 || trace_level > 7 )          usage( execname );        break;      case 'n':        name_tables = 1;        break;      default:        usage( execname );        break;      }    }    argc -= optind;    argv += optind;    if ( argc != 1 )      usage( execname );#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 0 && FREETYPE_PATCH <= 8    if ( debug )    {#  ifdef FT_DEBUG_LEVEL_TRACE      FT_SetTraceLevel( trace_any, (FT_Byte)trace_level );#  else      trace_level = 0;#  endif    }#elif 0       /* "setenv/putenv" is not ANSI and I don't want to mess */       /* with this portability issue right now                */    if ( debug )    {      char  temp[32];            sprintf( temp, "any=%d", trace_level );      setenv( "FT2_DEBUG", temp );    }#endif    file = 0;    /* Initialize engine */    error = FT_Init_FreeType( &library );    if ( error )      PanicZ( "Could not initialize FreeType library" );    filename[128]     = '\0';    alt_filename[128] = '\0';    strncpy( filename, argv[file], 128 );    strncpy( alt_filename, argv[file], 128 );    /* try to load the file name as is, first */    error = FT_New_Face( library, argv[file], 0, &face );    if ( !error )      goto Success;#ifndef macintosh    i = strlen( argv[file] );    while ( i > 0 && argv[file][i] != '\\' && argv[file][i] != '/' )    {      if ( argv[file][i] == '.' )        i = 0;      i--;    }    if ( i >= 0 )    {      strncpy( filename + strlen( filename ), ".ttf", 4 );      strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );    }#endif    /* Load face */    error = FT_New_Face( library, filename, 0, &face );    if ( error )      PanicZ( "Could not open face." );  Success:    num_faces = face->num_faces;    FT_Done_Face( face );    printf( "There %s %d %s in this file.\n",            num_faces == 1 ? (char *)"is" : (char *)"are",            num_faces,            num_faces == 1 ? (char *)"face" : (char *)"faces" );    for ( i = 0; i < num_faces; i++ )    {      error = FT_New_Face( library, filename, i, &face );      if ( error )        PanicZ( "Could not open face." );      printf( "\n----- Face number: %d -----\n\n", i );      Print_Name( face );      printf( "\n" );      Print_Type( face );      if ( name_tables && FT_IS_SFNT( face ) )      {        printf( "\n" );        Print_Sfnt_Names( face );      }      if ( face->num_fixed_sizes )      {        printf( "\n" );        Print_Fixed( face );      }      if ( face->num_charmaps )      {        printf( "\n" );        Print_Charmaps( face );      }      FT_Done_Face( face );    }    FT_Done_FreeType( library );    exit( 0 );      /* for safety reasons */    return 0;       /* never reached */  }/* End */

⌨️ 快捷键说明

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