misc/libfreetype/src/base/ftsnames.c
author Medo <smaxein@googlemail.com>
Wed, 23 May 2012 22:46:37 +0200
changeset 7123 9fe1c4091dd1
parent 5172 88f2e05288ba
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
/*  ftsnames.c                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    Simple interface to access SFNT name tables (which are used          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*    to hold font names, copyright info, notices, etc.) (body).           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*    This is _not_ used to retrieve glyph names!                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  Copyright 1996-2001, 2002, 2009 by                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_SFNT_NAMES_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_INTERNAL_TRUETYPE_TYPES_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#ifdef TT_CONFIG_OPTION_SFNT_NAMES
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  /* documentation is in ftsnames.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  FT_EXPORT_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  FT_Get_Sfnt_Name_Count( FT_Face  face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
    return ( face && FT_IS_SFNT( face ) ) ? ((TT_Face)face)->num_names : 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  /* documentation is in ftsnames.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  FT_Get_Sfnt_Name( FT_Face       face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
                    FT_UInt       idx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
                    FT_SfntName  *aname )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    FT_Error  error = FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
    if ( aname && face && FT_IS_SFNT( face ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
      TT_Face  ttface = (TT_Face)face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
      if ( idx < (FT_UInt)ttface->num_names )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
        TT_NameEntryRec*  entry = ttface->name_table.names + idx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
        /* load name on demand */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
        if ( entry->stringLength > 0 && entry->string == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
          FT_Memory  memory = face->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
          FT_Stream  stream = face->stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
          if ( FT_NEW_ARRAY  ( entry->string, entry->stringLength ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
               FT_STREAM_SEEK( entry->stringOffset )                ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
               FT_STREAM_READ( entry->string, entry->stringLength ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
            FT_FREE( entry->string );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
            entry->stringLength = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
        aname->platform_id = entry->platformID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
        aname->encoding_id = entry->encodingID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
        aname->language_id = entry->languageID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
        aname->name_id     = entry->nameID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
        aname->string      = (FT_Byte*)entry->string;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
        aname->string_len  = entry->stringLength;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
        error = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
#endif /* TT_CONFIG_OPTION_SFNT_NAMES */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
/* END */