2018-06-03 09:01:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* ftsnames.c
|
|
|
|
*
|
|
|
|
* Simple interface to access SFNT name tables (which are used
|
|
|
|
* to hold font names, copyright info, notices, etc.) (body).
|
|
|
|
*
|
|
|
|
* This is _not_ used to retrieve glyph names!
|
|
|
|
*
|
2020-01-19 17:05:19 +01:00
|
|
|
* Copyright (C) 1996-2020 by
|
2018-06-03 09:01:17 +02:00
|
|
|
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
|
|
|
*
|
|
|
|
* This file is part of the FreeType project, and may only be used,
|
|
|
|
* modified, and distributed under the terms of the FreeType project
|
|
|
|
* license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
|
|
* this file you indicate that you have read the license and
|
|
|
|
* understand and accept it fully.
|
|
|
|
*
|
|
|
|
*/
|
2000-07-20 08:57:41 +02:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/internal/ftdebug.h>
|
2017-03-17 07:52:30 +01:00
|
|
|
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/ftsnames.h>
|
|
|
|
#include <freetype/internal/tttypes.h>
|
|
|
|
#include <freetype/internal/ftstream.h>
|
2000-07-19 19:13:03 +02:00
|
|
|
|
|
|
|
|
2000-10-15 19:59:17 +02:00
|
|
|
#ifdef TT_CONFIG_OPTION_SFNT_NAMES
|
2000-07-19 19:13:03 +02:00
|
|
|
|
|
|
|
|
2009-04-04 09:20:14 +02:00
|
|
|
/* documentation is in ftsnames.h */
|
2000-11-07 18:21:11 +01:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_UInt )
|
|
|
|
FT_Get_Sfnt_Name_Count( FT_Face face )
|
2000-07-19 19:13:03 +02:00
|
|
|
{
|
2009-04-04 09:11:58 +02:00
|
|
|
return ( face && FT_IS_SFNT( face ) ) ? ((TT_Face)face)->num_names : 0;
|
2000-07-19 19:13:03 +02:00
|
|
|
}
|
2000-10-31 21:42:18 +01:00
|
|
|
|
|
|
|
|
2009-04-04 09:20:14 +02:00
|
|
|
/* documentation is in ftsnames.h */
|
2000-11-07 18:21:11 +01:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Get_Sfnt_Name( FT_Face face,
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
FT_UInt idx,
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_SfntName *aname )
|
2000-07-19 19:13:03 +02:00
|
|
|
{
|
2013-03-14 17:50:49 +01:00
|
|
|
FT_Error error = FT_ERR( Invalid_Argument );
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-07-20 08:57:41 +02:00
|
|
|
|
|
|
|
if ( aname && face && FT_IS_SFNT( face ) )
|
2000-07-19 19:13:03 +02:00
|
|
|
{
|
|
|
|
TT_Face ttface = (TT_Face)face;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-07-20 08:57:41 +02:00
|
|
|
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
if ( idx < (FT_UInt)ttface->num_names )
|
2000-07-19 19:13:03 +02:00
|
|
|
{
|
2017-01-25 15:08:41 +01:00
|
|
|
TT_Name entry = ttface->name_table.names + idx;
|
2002-05-28 01:52:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* load name on demand */
|
2016-12-26 17:08:17 +01:00
|
|
|
if ( entry->stringLength > 0 && !entry->string )
|
2002-05-28 01:52:01 +02:00
|
|
|
{
|
|
|
|
FT_Memory memory = face->memory;
|
2002-05-28 08:03:10 +02:00
|
|
|
FT_Stream stream = face->stream;
|
2002-05-28 01:52:01 +02:00
|
|
|
|
|
|
|
|
2002-05-28 08:03:10 +02:00
|
|
|
if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) ||
|
|
|
|
FT_STREAM_SEEK( entry->stringOffset ) ||
|
|
|
|
FT_STREAM_READ( entry->string, entry->stringLength ) )
|
2002-05-28 01:52:01 +02:00
|
|
|
{
|
|
|
|
FT_FREE( entry->string );
|
|
|
|
entry->stringLength = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aname->platform_id = entry->platformID;
|
|
|
|
aname->encoding_id = entry->encodingID;
|
|
|
|
aname->language_id = entry->languageID;
|
|
|
|
aname->name_id = entry->nameID;
|
|
|
|
aname->string = (FT_Byte*)entry->string;
|
|
|
|
aname->string_len = entry->stringLength;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-07-19 19:13:03 +02:00
|
|
|
error = FT_Err_Ok;
|
|
|
|
}
|
|
|
|
}
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-07-19 19:13:03 +02:00
|
|
|
return error;
|
2000-10-31 21:42:18 +01:00
|
|
|
}
|
2000-07-20 08:57:41 +02:00
|
|
|
|
|
|
|
|
2017-01-27 00:06:52 +01:00
|
|
|
/* documentation is in ftsnames.h */
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Get_Sfnt_LangTag( FT_Face face,
|
|
|
|
FT_UInt langID,
|
|
|
|
FT_SfntLangTag *alangTag )
|
|
|
|
{
|
|
|
|
FT_Error error = FT_ERR( Invalid_Argument );
|
|
|
|
|
|
|
|
|
|
|
|
if ( alangTag && face && FT_IS_SFNT( face ) )
|
|
|
|
{
|
|
|
|
TT_Face ttface = (TT_Face)face;
|
|
|
|
|
|
|
|
|
|
|
|
if ( ttface->name_table.format != 1 )
|
|
|
|
return FT_THROW( Invalid_Table );
|
|
|
|
|
|
|
|
if ( langID > 0x8000U &&
|
|
|
|
langID - 0x8000U < ttface->name_table.numLangTagRecords )
|
|
|
|
{
|
|
|
|
TT_LangTag entry = ttface->name_table.langTags +
|
|
|
|
( langID - 0x8000U );
|
|
|
|
|
|
|
|
|
|
|
|
/* load name on demand */
|
|
|
|
if ( entry->stringLength > 0 && !entry->string )
|
|
|
|
{
|
|
|
|
FT_Memory memory = face->memory;
|
|
|
|
FT_Stream stream = face->stream;
|
|
|
|
|
|
|
|
|
|
|
|
if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) ||
|
|
|
|
FT_STREAM_SEEK( entry->stringOffset ) ||
|
|
|
|
FT_STREAM_READ( entry->string, entry->stringLength ) )
|
|
|
|
{
|
|
|
|
FT_FREE( entry->string );
|
|
|
|
entry->stringLength = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
alangTag->string = (FT_Byte*)entry->string;
|
|
|
|
alangTag->string_len = entry->stringLength;
|
|
|
|
|
|
|
|
error = FT_Err_Ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-14 09:42:20 +02:00
|
|
|
#else /* !TT_CONFIG_OPTION_SFNT_NAMES */
|
|
|
|
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_UInt )
|
|
|
|
FT_Get_Sfnt_Name_Count( FT_Face face )
|
|
|
|
{
|
|
|
|
FT_UNUSED( face );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Get_Sfnt_Name( FT_Face face,
|
|
|
|
FT_UInt idx,
|
|
|
|
FT_SfntName *aname )
|
|
|
|
{
|
|
|
|
FT_UNUSED( face );
|
|
|
|
FT_UNUSED( idx );
|
|
|
|
FT_UNUSED( aname );
|
|
|
|
|
|
|
|
return FT_THROW( Unimplemented_Feature );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Get_Sfnt_LangTag( FT_Face face,
|
|
|
|
FT_UInt langID,
|
|
|
|
FT_SfntLangTag *alangTag )
|
|
|
|
{
|
|
|
|
FT_UNUSED( face );
|
|
|
|
FT_UNUSED( langID );
|
|
|
|
FT_UNUSED( alangTag );
|
|
|
|
|
|
|
|
return FT_THROW( Unimplemented_Feature );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* !TT_CONFIG_OPTION_SFNT_NAMES */
|
2000-07-20 08:57:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* END */
|