ftsnames.c

Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  ftsnames.c                                                             */
00004 /*                                                                         */
00005 /*    Simple interface to access SFNT name tables (which are used          */
00006 /*    to hold font names, copyright info, notices, etc.) (body).           */
00007 /*                                                                         */
00008 /*    This is _not_ used to retrieve glyph names!                          */
00009 /*                                                                         */
00010 /*  Copyright 1996-2001, 2002, 2009 by                                     */
00011 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
00012 /*                                                                         */
00013 /*  This file is part of the FreeType project, and may only be used,       */
00014 /*  modified, and distributed under the terms of the FreeType project      */
00015 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00016 /*  this file you indicate that you have read the license and              */
00017 /*  understand and accept it fully.                                        */
00018 /*                                                                         */
00019 /***************************************************************************/
00020 
00021 
00022 #include <ft2build.h>
00023 #include FT_SFNT_NAMES_H
00024 #include FT_INTERNAL_TRUETYPE_TYPES_H
00025 #include FT_INTERNAL_STREAM_H
00026 
00027 
00028 #ifdef TT_CONFIG_OPTION_SFNT_NAMES
00029 
00030 
00031   /* documentation is in ftsnames.h */
00032 
00033   FT_EXPORT_DEF( FT_UInt )
00034   FT_Get_Sfnt_Name_Count( FT_Face  face )
00035   {
00036     return ( face && FT_IS_SFNT( face ) ) ? ((TT_Face)face)->num_names : 0;
00037   }
00038 
00039 
00040   /* documentation is in ftsnames.h */
00041 
00042   FT_EXPORT_DEF( FT_Error )
00043   FT_Get_Sfnt_Name( FT_Face       face,
00044                     FT_UInt       idx,
00045                     FT_SfntName  *aname )
00046   {
00047     FT_Error  error = FT_Err_Invalid_Argument;
00048 
00049 
00050     if ( aname && face && FT_IS_SFNT( face ) )
00051     {
00052       TT_Face  ttface = (TT_Face)face;
00053 
00054 
00055       if ( idx < (FT_UInt)ttface->num_names )
00056       {
00057         TT_NameEntryRec*  entry = ttface->name_table.names + idx;
00058 
00059 
00060         /* load name on demand */
00061         if ( entry->stringLength > 0 && entry->string == NULL )
00062         {
00063           FT_Memory  memory = face->memory;
00064           FT_Stream  stream = face->stream;
00065 
00066 
00067           if ( FT_NEW_ARRAY  ( entry->string, entry->stringLength ) ||
00068                FT_STREAM_SEEK( entry->stringOffset )                ||
00069                FT_STREAM_READ( entry->string, entry->stringLength ) )
00070           {
00071             FT_FREE( entry->string );
00072             entry->stringLength = 0;
00073           }
00074         }
00075 
00076         aname->platform_id = entry->platformID;
00077         aname->encoding_id = entry->encodingID;
00078         aname->language_id = entry->languageID;
00079         aname->name_id     = entry->nameID;
00080         aname->string      = (FT_Byte*)entry->string;
00081         aname->string_len  = entry->stringLength;
00082 
00083         error = FT_Err_Ok;
00084       }
00085     }
00086 
00087     return error;
00088   }
00089 
00090 
00091 #endif /* TT_CONFIG_OPTION_SFNT_NAMES */
00092 
00093 
00094 /* END */

Generated on Tue Jul 5 14:13:42 2011 for ROOT_528-00b_version by  doxygen 1.5.1