Example #1
0
  int
  main( void )
  {
    int    i;
#ifdef HAVE_LIBINTL_H
    char*  domain;


    setlocale( LC_ALL, "" );
    bindtextdomain( "freetype", LOCALEDIR );
    domain = textdomain( "freetype" );
#endif

#if 0
    printf( "domain: %s\n", domain = textdomain( "" ) );
#endif
    printf( gettext( "Start of fterror.\n" ) );

    for ( i = 0; i < 10; i++ )
      printf( "Code: %i, %s\n", i, TT_ErrToString18( i ) );

#if 0
    printf( "domain: %s\n", domain = textdomain( "" ) );
#endif
    printf( gettext( "End of fterror.\n" ) );

    exit( EXIT_SUCCESS );      /* for safety reasons */

    return 0;       /* never reached */
  }
Example #2
0
/*
=item i_tt_push_error(code)

Push an error message and code onto the Imager error stack.

=cut
*/
static void
i_tt_push_error(TT_Error rc) {
#ifdef FTXERR18
  TT_String const *msg = TT_ErrToString18(rc);

  i_push_error(rc, msg);
#else
  i_push_errorf(rc, "Error code 0x%04x", (unsigned)rc);
#endif
}
Example #3
0
  int  main( int  argc, char**  argv )
  {
    int    i;
    char   filename[128 + 4];
    char   alt_filename[128 + 4];
    char*  execname;
    char*  fname;


#ifdef HAVE_LIBINTL_H
    setlocale( LC_ALL, "" );
    bindtextdomain( "freetype", LOCALEDIR );
    textdomain( "freetype" );
#endif

    execname = argv[0];

    if ( argc < 3 )
      Usage( execname );

    if ( sscanf( argv[1], "%d", &ptsize ) != 1 )
      Usage( execname );

    /* Initialize engine */
    if ( (error = TT_Init_FreeType( &engine )) )
    {
      fprintf( stderr, gettext( "Error while initializing engine.\n" ) );
      goto Failure;
    }

    if ( (error = TT_Init_SBit_Extension( engine )) )
    {
      fprintf( stderr, gettext(
               "Error while initializing embedded bitmap extension.\n" ) );
      goto Failure;
    }

    /* Now check all files */
    fname = argv[2];
    i     = strlen( fname );
    while ( i > 0 && fname[i] != '\\' && fname[i] != '/' )
    {
      if ( fname[i] == '.' )
        i = 0;
      i--;
    }

    filename[128] = '\0';
    alt_filename[128] = '\0';

    strncpy( filename, fname, 128 );
    strncpy( alt_filename, fname, 128 );

    if ( i >= 0 )
    {
      strncpy( filename + strlen( filename ), ".ttf", 4 );
      strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
    }

    /* Load face */
    error = TT_Open_Face( engine, filename, &face );
    if ( error == TT_Err_Could_Not_Open_File )
    {
      strcpy( filename, alt_filename );
      error = TT_Open_Face( engine, alt_filename, &face );
    }

    i     = strlen( filename );
    fname = filename;

    while ( i >= 0 )
      if ( filename[i] == '/' || filename[i] == '\\' )
      {
        fname = filename + i + 1;
        i = -1;
      }
      else
        i--;

    if ( error )
    {
      fprintf( stderr, gettext( "Could not find or open %s.\n" ),
               filename );
      goto Failure;
    }
    if ( error )
    {
      fprintf( stderr, gettext( "Error while opening %s.\n" ), filename );
      goto Failure;
    }

    /* get face properties */
    TT_Get_Face_Properties( face, &properties );
    num_glyphs = properties.num_Glyphs;

    error = TT_Get_Face_Bitmaps( face, &eblc );
    if ( error == TT_Err_Table_Missing )
    {
      fprintf( stderr, gettext(
               "Could not find embedded bitmaps in this font.\n" ) );
      goto Failure;
    }
    if ( error )
    {
      fprintf( stderr, gettext(
               "Error while loading embedded bitmaps.\n" ) );
      goto Failure;
    }

    /* create instance */
    error = TT_New_Instance( face, &instance );
    if ( error )
    {
      fprintf( stderr, gettext( "Could not create instance.\n" ) );
      goto Failure;
    }

    error = TT_Set_Instance_PixelSizes( instance,
                                        ptsize,
                                        ptsize,
                                        ptsize*3/4 );
    if ( error )
    {
      fprintf( stderr,
               gettext( "Could not set point size to %d.\n" ),
               ptsize );
      goto Failure;
    }

    error = TT_New_SBit_Image( &bitmap );
    if ( error )
    {
      fprintf( stderr, gettext(
               "Could not allocate glyph bitmap container.\n" ) );
      goto Failure;
    }

    for ( i = 3; i < argc; i++ )
    {
      unsigned short  glyph_index;


      /* we use %i to allow the prefixes `0x' and `0' */
      if ( sscanf( argv[i], "%hi", &glyph_index ) != 1 )
        Usage( execname );

      error = TT_Load_Glyph_Bitmap( face, instance, glyph_index, bitmap );

      if ( error == TT_Err_Invalid_Glyph_Index )
      {
        fprintf( stderr, gettext(
                 "  no bitmap for glyph %d.\n" ), glyph_index );
        continue;
      }
      if ( error )
      {
        fprintf( stderr, gettext(
                 "Can't load bitmap for glyph %d.\n" ), glyph_index );
        goto Failure;
      }

      /* Dump the resulting bitmap */
      {
        printf( gettext( "glyph index %d = %dx%d pixels, " ),
                glyph_index, bitmap->map.rows, bitmap->map.width );

        printf( gettext( "advance = %ld, minBearing = [%ld,%ld]\n" ),
                (long)(bitmap->metrics.horiAdvance / 64),
                (long)(bitmap->metrics.horiBearingX / 64),
                (long)(bitmap->metrics.horiBearingY / 64));

        Show_Single_Glyph( &bitmap->map );
      }
    }

    TT_Done_SBit_Image( bitmap );
    TT_Done_FreeType( engine );

    exit( EXIT_SUCCESS );      /* for safety reasons */

    return 0;       /* never reached */

  Failure:
    fprintf( stderr, "  " );
    fprintf( stderr, gettext( "FreeType error message: %s\n" ),
             TT_ErrToString18( error ) );

    exit( EXIT_FAILURE );

    return 0;       /* never reached */
  }
Example #4
0
  int
  main( int  argc, char**  argv )
  {
    int    i, orig_ptsize, file;
    char   filename[128 + 4];
    char   alt_filename[128 + 4];
    char*  execname;
    int    option;

    int    ptsize;
    int    num_Faces = 0;
    int    glyph_index = 0;
    int    load_flags = TTLOAD_DEFAULT;

    int    force_sbit = 0;

    TT_Engine    engine;

    TT_Face      face;
    TT_Instance  instance;
    TT_Glyph     glyph;

    TT_Raster_Map  map;

    TT_Big_Glyph_Metrics  metrics;
    TT_Face_Properties    properties;
    TT_Instance_Metrics   imetrics;

    TT_EBLC         eblc;
    TT_SBit_Image*  bitmap = NULL;

    TT_Error  error;


    int res = 72;

#ifdef HAVE_LIBINTL_H
    setlocale( LC_ALL, "" );
    bindtextdomain( "freetype", LOCALEDIR );
    textdomain( "freetype" );
#endif

    execname = ft_basename( argv[0] );

    while ( 1 )
    {
      option = ft_getopt( argc, argv, "c:r:i:B" );

      if ( option == -1 )
        break;

      switch ( option )
      {
      case 'r':
        res = atoi( ft_optarg );
        if ( res < 1 )
          usage( execname );
        break;

      case 'c':
        num_Faces = atoi( ft_optarg );
        if ( num_Faces < 0 )
          usage( execname );
        break;

      case 'i':
        glyph_index = atoi( ft_optarg );
        if ( glyph_index < 0 )
          usage( execname );
        break;

      case 'B':
        force_sbit = 1;
        break;

      default:
        usage( execname );
        break;
      }
    }

    argc -= ft_optind;
    argv += ft_optind;

    if ( argc <= 1 )
      usage( execname );

    if ( sscanf( argv[0], "%d", &orig_ptsize ) != 1 )
      orig_ptsize = 64;

    file = 1;

    ptsize = orig_ptsize;

    i = strlen( argv[file] );
    while ( i > 0 && argv[file][i] != '\\' && argv[file][i] != '/' )
    {
      if ( argv[file][i] == '.' )
        i = 0;
        i--;
    }

    filename[128] = '\0';
    alt_filename[128] = '\0';

    strncpy( filename, argv[file], 128 );
    strncpy( alt_filename, argv[file], 128 );

    if ( i >= 0 )
    {
      strncpy( filename + strlen( filename ), ".ttf", 4 );
      strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
    }

    /* Initialize engine */

    error = TT_Init_FreeType( &engine );
    if ( error )
    {
      fprintf( stderr, gettext( "Error while initializing engine.\n" ) );
      goto Failure;
    }

    error = TT_Init_SBit_Extension( engine );
    if ( error )
    {
      fprintf( stderr, gettext(
               "Error while initializing embedded bitmap extension.\n" ) );
      goto Failure;
    }

    /* Load face */

    error = TT_Open_Face( engine, filename, &face );

    if ( error == TT_Err_Could_Not_Open_File )
    {
      strcpy( filename, alt_filename );
      error = TT_Open_Face( engine, alt_filename, &face );
    }

    if ( error == TT_Err_Could_Not_Open_File )
      Panic( gettext( "Could not find or open %s.\n" ), filename );
    if ( error )
    {
      fprintf( stderr, gettext( "Error while opening %s.\n" ),
               filename );
      goto Failure;
    }

    TT_Get_Face_Properties( face, &properties );

    printf( gettext( "There are %d fonts in this collection.\n" ),
            (int)(properties.num_Faces) );

    if ( num_Faces >= properties.num_Faces )
      Panic( gettext(
             "There is no collection with index %d in this font file.\n" ),
             num_Faces );

    TT_Close_Face( face );

    error = TT_Open_Collection( engine, filename, num_Faces, &face );

    /* get face properties and eblc */

    TT_Get_Face_Properties( face, &properties );
    if ( force_sbit )
    {
      error = TT_Get_Face_Bitmaps( face, &eblc );
      if ( error == TT_Err_Table_Missing )
        Panic( gettext( "There is no embedded bitmap data in the font.\n" ) );
      if ( error )
      {
        fprintf( stderr, gettext(
                 "Error while retrieving embedded bitmaps table.\n" ) );
        goto Failure;
      }
    }

    /* create glyph */

    error = TT_New_Glyph( face, &glyph );
    if ( error )
    {
      fprintf( stderr, gettext( "Could not create glyph container.\n" ) );
      goto Failure;
    }

    /* create instance */

    error = TT_New_Instance( face, &instance );
    if ( error )
    {
      fprintf( stderr, gettext( "Could not create instance.\n" ) );
      goto Failure;
    }

    error = TT_Set_Instance_Resolutions( instance, res, res );
    if ( error )
    {
      fprintf( stderr, gettext( "Could not set device resolutions.\n" ) );
      goto Failure;
    }

    error = TT_Set_Instance_CharSize( instance, ptsize*64 );
    if ( error )
    {
      fprintf( stderr, gettext( "Could not reset instance.\n" ) );
      goto Failure;
    }

    TT_Get_Instance_Metrics( instance, &imetrics );

    printf( gettext( "Instance metrics: ppemX %d, ppemY %d\n" ),
            imetrics.x_ppem,
            imetrics.y_ppem );

    if ( force_sbit )
    {
      error = TT_New_SBit_Image( &bitmap );
      if ( error )
      {
        fprintf( stderr, gettext(
                 "Could not allocate glyph bitmap container.\n" ) );
        goto Failure;
      }

      error = TT_Load_Glyph_Bitmap( face, instance, glyph_index, bitmap );
      if ( error )
      {
        fprintf( stderr, gettext(
                 "Can't load bitmap for glyph %d.\n" ), glyph_index );
        goto Failure;
      }

      Show_Metrics( bitmap->metrics, "SBit's metrics" );

      printf( "SBit glyph:\n" );
      Show_Single_Glyph( &bitmap->map );
    }
    else
    {
      TT_Load_Glyph( instance, glyph, glyph_index, load_flags );
      TT_Get_Glyph_Big_Metrics( glyph, &metrics );

      map.width = ( metrics.bbox.xMax - metrics.bbox.xMin ) / 64;
      map.rows = ( metrics.bbox.yMax - metrics.bbox.yMin ) / 64;
      map.cols = ( map.width + 7 ) / 8;
      map.size = map.cols * map.rows;
      map.bitmap = malloc( map.size );
      map.flow = TT_Flow_Down;

      memset( map.bitmap, 0, map.size );

      error = TT_Get_Glyph_Bitmap( glyph, &map,
                                   -metrics.bbox.xMin,
                                   -metrics.bbox.yMin );

      Show_Metrics( metrics, gettext( "Outline's metrics" ) );

      printf( gettext( "Outline glyph\n" ) );
      Show_Single_Glyph( &map );
    }

    free( map.bitmap );

    if ( bitmap )
      TT_Done_SBit_Image( bitmap );

    TT_Done_Instance( instance );
    TT_Done_Glyph( glyph );
    TT_Done_FreeType( engine );

    exit( EXIT_SUCCESS );      /* for safety reasons */

    return 0;       /* never reached */

  Failure:
    fprintf( stderr, "  " );
    fprintf( stderr, gettext( "FreeType error message: %s\n" ),
             TT_ErrToString18( error ) );

    exit( EXIT_FAILURE );

    return 0;       /* never reached */
  }
Example #5
0
  int
  main( int  argc, char**  argv )
  {
    int    i;
    char   filename[128 + 4];
    char   alt_filename[128 + 4];
    char*  execname;
    char*  gt;


#ifdef HAVE_LIBINTL_H
    setlocale( LC_ALL, "" );
    bindtextdomain( "freetype", LOCALEDIR );
    textdomain( "freetype" );
#endif

    execname = argv[0];

    if ( argc != 2 )
    {
      gt = gettext( "ftdump: Simple TrueType Dumper -- part of the FreeType project" );
      fprintf( stderr, "%s\n", gt );
      separator_line( stderr, strlen( gt ) );

      fprintf( stderr, gettext( "Usage: %s fontname[.ttf|.ttc]\n\n" ),
               execname );

      exit( EXIT_FAILURE );
    }

    i = strlen( argv[1] );
    while ( i > 0 && argv[1][i] != '\\' )
    {
      if ( argv[1][i] == '.' )
        i = 0;
      i--;
    }

    filename[128] = '\0';
    alt_filename[128] = '\0';

    strncpy( filename, argv[1], 128 );
    strncpy( alt_filename, argv[1], 128 );

    if ( i >= 0 )
    {
      strncpy( filename + strlen( filename ), ".ttf", 4 );
      strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
    }

    /* Initialize engine */

    old_memory = 0;

    if ( (error = TT_Init_FreeType( &engine )) )
    {
      fprintf( stderr, gettext( "Error while initializing engine.\n" ) );
      goto Failure;
    }

    if ( (error = TT_Init_SBit_Extension( engine )) )
    {
      fprintf( stderr, gettext(
               "Error while initializing embedded bitmap extension.\n" ) );
      goto Failure;
    }

    if ( (error = TT_Init_GSUB_Extension( engine )) )
    {
      fprintf( stderr, gettext(
               "Error while initializing GSUB extension.\n" ) );
      goto Failure;
    }

    FOOTPRINT( initial_overhead );

    /* Open and Load face */

    error = TT_Open_Face( engine, filename, &face );
    if ( error == TT_Err_Could_Not_Open_File )
    {
      strcpy( filename, alt_filename );
      error = TT_Open_Face( engine, alt_filename, &face );
    }

    if ( error == TT_Err_Could_Not_Open_File )
      Panic( gettext( "Could not find or open %s.\n" ), filename );
    if ( error )
    {
      fprintf( stderr, gettext( "Error while opening %s.\n" ), filename );
      goto Failure;
    }

    FOOTPRINT( face_object );

    /* get face properties and allocate preload arrays */

    TT_Get_Face_Properties( face, &properties );
    num_glyphs = properties.num_Glyphs;

    /* Now do various dumps */

    if ( flag_names )
      Print_Names();

    if ( flag_encodings )
      Print_Encodings();

    if ( flag_cmap )
      Print_Cmap();

    if ( flag_sbits )
      Print_SBits();

    if ( flag_ttopen )
      Print_GSUB();

#ifndef FREETYPE_DLL  /* the statistics are meaningless if we use a DLL. */
    if ( flag_memory )
      Print_Memory();
#endif

    TT_Close_Face( face );

    TT_Done_FreeType( engine );

    exit( EXIT_SUCCESS );       /* for safety reasons */

    return 0;                   /* never reached */

  Failure:
    fprintf( stderr, "  " );
    Panic( gettext( "FreeType error message: %s\n" ),
           TT_ErrToString18( error ) );

    return 0;                   /* never reached */
}
Example #6
0
  static void
  Print_GSUB( void )
  {
    TTO_GSUBHeader  gsub;
    TT_Error        error;

    TT_UShort       i;
    TTO_Feature     f;
    TTO_Lookup*     lo;

    TT_ULong        *script_tag_list, *stl;
    TT_ULong        *language_tag_list, *ltl;
    TT_ULong        *feature_tag_list, *ftl;

    TT_UShort       script_index, language_index,
                    feature_index, req_feature_index;

    char            script_tag[4], language_tag[4], feature_tag[4];


    error = TT_Load_GSUB_Table( face, &gsub, NULL );
    if ( error == TT_Err_Table_Missing )
      return;
    if ( error )
    {
      fprintf( stderr, gettext( "Error while loading GSUB table.\n" ) );
      goto Failure;
    }

    printf( gettext( "GSUB table\n" ) );
    separator_line( stdout, 78 );

    error = TT_GSUB_Query_Scripts( &gsub, &script_tag_list );
    if ( error )
    {
      fprintf( stderr, gettext(
               "Error while querying GSUB script list.\n" ) );
      goto Failure;
    }

    stl = script_tag_list;
    for ( ; *stl; stl++ )
    {
      TAG2STRING( *stl, script_tag );

      error = TT_GSUB_Select_Script( &gsub, *stl, &script_index );
      if ( error )
      {
        fprintf( stderr, gettext(
                 "Error while selecting GSUB script `%4.4s'.\n" ),
                 script_tag );
        goto Failure;
      }

      printf( gettext( "  script `%4.4s' (index %hu):\n" ),
              script_tag, script_index );

      error = TT_GSUB_Query_Features( &gsub, script_index, 0xFFFF,
                                      &feature_tag_list );
      if ( error )
      {
        fprintf( stderr, gettext(
                 "Error while querying GSUB default language system for script `%4.4s'.\n" ),
                 script_tag );
        goto Failure;
      }

      printf( gettext( "    default language system:\n" ) );

      ftl = feature_tag_list;
      for ( ; *ftl; ftl++ )
      {
        TAG2STRING( *ftl, feature_tag );

        error = TT_GSUB_Select_Feature( &gsub, *ftl,
                                        script_index, 0xFFFF,
                                        &feature_index );
        if ( error )
        {
          fprintf( stderr, gettext(
                   "Error while selecting GSUB feature `%4.4s'\n"
                   "for default language system of script `%4.4s'.\n" ),
                   feature_tag, script_tag );
          goto Failure;
        }

        printf( gettext( "      feature `%4.4s' (index %hu; lookup " ),
                feature_tag, feature_index );

        f = gsub.FeatureList.FeatureRecord[feature_index].Feature;

        for ( i = 0; i < f.LookupListCount - 1; i++ )
          printf( "%hu, ", f.LookupListIndex[i] );
        printf( "%hu)\n", f.LookupListIndex[i] );
      }
      free( feature_tag_list );

      error = TT_GSUB_Query_Languages( &gsub, script_index,
                                       &language_tag_list );
      if ( error )
      {
        fprintf( stderr, gettext(
                 "Error while querying GSUB language list for script `%4.4s'.\n" ),
                 script_tag );
        goto Failure;
      }

      ltl = language_tag_list;
      for ( ; *ltl; ltl++ )
      {
        TAG2STRING( *ltl, language_tag );

        error = TT_GSUB_Select_Language( &gsub, *ltl, 
                                         script_index,
                                         &language_index,
                                         &req_feature_index );
        if ( error )
        {
          fprintf( stderr, gettext(
                   "Error while selecting GSUB language `%4.4s' for script `%4.4s'.\n" ),
                   language_tag, script_tag );
          goto Failure;
        }

        printf( gettext( "    language `%4.4s' (index %hu):\n" ),
                language_tag, language_index );

        if ( req_feature_index != 0xFFFF )
        {
          printf( gettext( "      required feature index %hu (lookup " ),
                  req_feature_index );

          f = gsub.FeatureList.FeatureRecord[req_feature_index].Feature;

          for ( i = 0; i < f.LookupListCount - 1; i++ )
            printf( "%hu, ", f.LookupListIndex[i] );
          printf( "%hu)\n", f.LookupListIndex[i] );
        }

        error = TT_GSUB_Query_Features( &gsub, script_index, language_index,
                                        &feature_tag_list );
        if ( error )
        {
          fprintf( stderr, gettext(
                   "Error while querying GSUB feature list\n"
                   "for script `%4.4s', language `%4.4s'.\n" ),
                   script_tag, language_tag );
          goto Failure;
        }

        ftl = feature_tag_list;
        for ( ; *ftl; ftl++ )
        {
          TAG2STRING( *ftl, feature_tag );

          error = TT_GSUB_Select_Feature( &gsub, *ftl,
                                          script_index, language_index,
                                          &feature_index );
          if ( error )
          {
            fprintf( stderr, gettext(
                     "Error while selecting GSUB feature `%4.4s'\n"
                     "for script `%4.4s', language `%4.4s'.\n" ),
                     feature_tag, script_tag, language_tag );
            goto Failure;
          }

          printf( gettext( "      feature `%4.4s' (index %hu; lookup " ),
                  feature_tag, feature_index );

          f = gsub.FeatureList.FeatureRecord[feature_index].Feature;

          for ( i = 0; i < f.LookupListCount - 1; i++ )
            printf( "%hu, ", f.LookupListIndex[i] );
          printf( "%hu)\n", f.LookupListIndex[i] );
        }
        free( feature_tag_list );
      }
      free( language_tag_list );
    }
    free( script_tag_list );

    printf( "\n" );

    lo = gsub.LookupList.Lookup;

    printf( gettext( "Lookups:\n\n" ) );

    for ( i = 0; i < gsub.LookupList.LookupCount; i++ )
      printf( gettext( "  %hu: type %hu, flag 0x%x\n" ),
              i, lo[i].LookupType, lo[i].LookupFlag );

    printf( "\n" );
    separator_line( stdout, 78 );

    return;

  Failure:
    fprintf( stderr, "  " );
    Panic( gettext( "FreeType error message: %s\n" ),
           TT_ErrToString18( error ) );
  }
Example #7
0
  static void
  Print_SBits( void )
  {
    TT_EBLC   eblc;
    TT_Error  error;


    error = TT_Get_Face_Bitmaps( face, &eblc );
    if ( error == TT_Err_Table_Missing )
      return;
    if ( error )
    {
      fprintf( stderr, gettext(
               "Error while retrieving embedded bitmaps table.\n" ) );
      goto Failure;
    }

    printf( gettext( "embedded bitmap table\n" ) );
    separator_line( stdout, 78 );

    printf( gettext( " version of embedded bitmap table:  0x%lx\n" ),
            eblc.version );
    printf( gettext( " number of embedded bitmap strikes: %lu\n" ),
            eblc.num_strikes );

    {
      TT_SBit_Strike*  strike = eblc.strikes;
      int              count  = 0;


      for ( ; count < eblc.num_strikes; count++, strike++ )
      {
        printf( gettext( "  bitmap strike %hu/%lu: " ),
                count + 1, eblc.num_strikes );

        printf( gettext( "%hux%hu pixels, %hu-bit depth, glyphs [%hu..%hu]\n" ),
                strike->x_ppem, strike->y_ppem, strike->bit_depth,
                strike->start_glyph, strike->end_glyph );
        {
          TT_SBit_Range*  range = strike->sbit_ranges;
          TT_SBit_Range*  limit = range + strike->num_ranges;


          for ( ; range < limit; range++ )
            printf( gettext( "      range format (%hu:%hu) glyphs %hu..%hu\n" ),
                    range->index_format,
                    range->image_format,
                    range->first_glyph,
                    range->last_glyph );
        }
      }
    }
    printf( "\n" );
    separator_line( stdout, 78 );

    return;

  Failure:
    fprintf( stderr, "  " );
    Panic( gettext( "FreeType error message: %s\n" ),
           TT_ErrToString18( error ) );
  }
Example #8
0
  void
  Print_Memory( void )
  {
    /* create glyph */
    error = TT_New_Glyph( face, &glyph );
    if ( error )
    {
      fprintf( stderr, gettext( "Could not create glyph container.\n" ) );
      goto Failure;
    }

    FOOTPRINT( glyph_object );

    /* create instance */
    error = TT_New_Instance( face, &instance );
    if ( error )
    {
      fprintf( stderr, gettext( "Could not create instance.\n" ) );
      goto Failure;
    }

    FOOTPRINT( first_instance );

    error = TT_New_Instance( face, &instance );
    if ( error )
    {
      fprintf( stderr, gettext( "Could not create second instance.\n" ) );
      goto Failure;
    }

    FOOTPRINT( second_instance );

    printf( gettext( "Memory footprint statistics:\n" ) );
    separator_line( stdout, 78 );

    /* NOTE: In our current implementation, the face's execution */
    /*       context object is created lazily with the first     */
    /*       instance.  However, all later instances share the   */
    /*       the same context.                                   */

    PRINT_MEM( face_object,     gettext( "face object" )     );
    PRINT_MEM( glyph_object,    gettext( "glyph object" )    );
    PRINT_MEM( second_instance, gettext( "instance object" ) );

    Print_Mem( memory_footprint.first_instance -
               memory_footprint.second_instance,
               gettext( "exec. context object" ) );

    separator_line( stdout, 78 );

    Print_Mem( memory_footprint.face_object  +
               memory_footprint.glyph_object +
               memory_footprint.first_instance,
               gettext( "total memory usage" ) );

    printf( "\n" );

    return;

  Failure:
    fprintf( stderr, "  " );
    Panic( gettext( "FreeType error message: %s\n" ),
           TT_ErrToString18( error ) );
  }