コード例 #1
0
ファイル: ttpost.c プロジェクト: hsmith/freetype
  tt_face_get_ps_name( TT_Face      face,
                       FT_UInt      idx,
                       FT_String**  PSname )
  {
    FT_Error       error;
    TT_Post_Names  names;
    FT_Fixed       format;

#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
    FT_Service_PsCMaps  psnames;
#endif


    if ( !face )
      return FT_THROW( Invalid_Face_Handle );

    if ( idx >= (FT_UInt)face->max_profile.numGlyphs )
      return FT_THROW( Invalid_Glyph_Index );

#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
    psnames = (FT_Service_PsCMaps)face->psnames;
    if ( !psnames )
      return FT_THROW( Unimplemented_Feature );
#endif

    names = &face->postscript_names;

    /* `.notdef' by default */
    *PSname = MAC_NAME( 0 );

    format = face->postscript.FormatType;

    if ( format == 0x00010000L )
    {
      if ( idx < 258 )                    /* paranoid checking */
        *PSname = MAC_NAME( idx );
    }
    else if ( format == 0x00020000L )
    {
      TT_Post_20  table = &names->names.format_20;


      if ( !names->loaded )
      {
        error = load_post_names( face );
        if ( error )
          goto End;
      }

      if ( idx < (FT_UInt)table->num_glyphs )
      {
        FT_UShort  name_index = table->glyph_indices[idx];


        if ( name_index < 258 )
          *PSname = MAC_NAME( name_index );
        else
          *PSname = (FT_String*)table->glyph_names[name_index - 258];
      }
    }
    else if ( format == 0x00028000L )
    {
      TT_Post_25  table = &names->names.format_25;


      if ( !names->loaded )
      {
        error = load_post_names( face );
        if ( error )
          goto End;
      }

      if ( idx < (FT_UInt)table->num_glyphs )    /* paranoid checking */
        *PSname = MAC_NAME( (FT_Int)idx + table->offsets[idx] );
    }

    /* nothing to do for format == 0x00030000L */

  End:
    return FT_Err_Ok;
  }
コード例 #2
0
ファイル: ttpost.c プロジェクト: Joincheng/lithtech
  FT_LOCAL_DEF
  FT_Error  TT_Get_PS_Name( TT_Face      face,
                            FT_UInt      index,
                            FT_String**  PSname )
  {
    FT_Error            error;
    TT_Post_Names*      names;

#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
    PSNames_Interface*  psnames;
#endif


    if ( !face )
      return TT_Err_Invalid_Face_Handle;

    if ( index >= (FT_UInt)face->root.num_glyphs )
      return TT_Err_Invalid_Glyph_Index;

#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
    psnames = (PSNames_Interface*)face->psnames;
    if ( !psnames )
      return TT_Err_Unimplemented_Feature;
#endif

    names = &face->postscript_names;

    /* `.notdef' by default */
    *PSname = MAC_NAME( 0 );

    switch ( face->postscript.FormatType )
    {
    case 0x00010000L:
      if ( index < 258 )                    /* paranoid checking */
        *PSname = MAC_NAME( index );
      break;

    case 0x00020000L:
      {
        TT_Post_20*  table = &names->names.format_20;


        if ( !names->loaded )
        {
          error = Load_Post_Names( face );
          if ( error )
            break;
        }

        if ( index < (FT_UInt)table->num_glyphs )
        {
          FT_UShort  name_index = table->glyph_indices[index];


          if ( name_index < 258 )
            *PSname = MAC_NAME( name_index );
          else
            *PSname = (FT_String*)table->glyph_names[name_index - 258];
        }
      }
      break;

    case 0x00028000L:
      {
        TT_Post_25*  table = &names->names.format_25;


        if ( !names->loaded )
        {
          error = Load_Post_Names( face );
          if ( error )
            break;
        }

        if ( index < (FT_UInt)table->num_glyphs )    /* paranoid checking */
        {
          index  += table->offsets[index];
          *PSname = MAC_NAME( index );
        }
      }
      break;

    case 0x00030000L:
      break;                                /* nothing to do */
    }

    return TT_Err_Ok;
  }