From 5dc8aba72bf072ad5000c26d974d86bcc95aaa92 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 10 Feb 2000 17:01:24 +0000 Subject: [PATCH] some modifications used to introduce the Type 1 AFM parser and psnames module --- src/shared/psnames.h | 214 +++++++++++++++++++++++++++++++++++++++++++ src/shared/t1types.h | 13 ++- src/shared/tttypes.h | 4 + 3 files changed, 227 insertions(+), 4 deletions(-) create mode 100644 src/shared/psnames.h diff --git a/src/shared/psnames.h b/src/shared/psnames.h new file mode 100644 index 000000000..ef6dbeb3a --- /dev/null +++ b/src/shared/psnames.h @@ -0,0 +1,214 @@ +/***************************************************************************/ +/* */ +/* psnames.h */ +/* */ +/* High-level interface for the "psnames" module (in charge of */ +/* various functions related to Postscript glyph names conversion) */ +/* */ +/* Copyright 1996-2000 by */ +/* 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. */ +/* */ +/***************************************************************************/ + +#ifndef PSNAMES_H +#define PSNAMES_H + +#include + + /************************************************************************** + * + * + * PS_Unicode_Value_Func + * + * + * A function used to return the Unicode index corresponding to a + * given glyph name. + * + * + * glyph_name :: the glyph name + * + * + * The Unicode character index. The non-Unicode value 0xFFFF if the + * glyph name has no known Unicode meaning.. + * + * + * This function is able to map several different glyph names to the + * same Unicode value, according to the rules defined in the Adobe + * Glyph List table. + * + * This function will not be compiled if the configuration macro + * FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined. + * + **************************************************************************/ + + typedef FT_ULong (*PS_Unicode_Value_Func)( const char* glyph_name ); + + + /************************************************************************** + * + * + * PS_Unicode_Index_Func + * + * + * A function used to return the glyph index corresponding to + * a given unicode value. + * + * + * num_glyphs :: number of glyphs in face + * glyph_names :: array of glyph name pointers + * uncode :: unicode value. + * + * + * The glyph index. 0xFFFF is no glyph correspond to this Unicode + * value.. + * + * + * This function is able to recognize several glyph names per + * unicode values, according to the Adobe Glyph List. + * + * This function will not be compiled if the configuration macro + * FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined. + * + **************************************************************************/ + + typedef FT_UInt (*PS_Unicode_Index_Func)( FT_UInt num_glyphs, + const char** glyph_names, + FT_ULong unicode ); + + /************************************************************************** + * + * + * PS_Macintosh_Name_Func + * + * + * A function used to return the glyph name corresponding to one + * Apple glyph name index. + * + * + * name_index :: index of the Mac name + * + * + * The glyph name, or 0 if the index is incorrect. + * + * + * This function will not be compiled if the configuration macro + * FT_CONFIG_OPTION_POSTSCRIPT_NAMES is undefined + * + **************************************************************************/ + + typedef const char* (*PS_Macintosh_Name_Func)( FT_UInt name_index ); + + + + typedef const char* (*PS_Adobe_Std_Strings_Func)( FT_UInt string_index ); + + /*************************************************************************** + * + * + * PS_Unicodes + * + * + * a simple table used to map Unicode values to glyph indices. It is + * built by the PS_Build_Unicodes table according to the glyphs present + * in a font file.. + * + * + * num_codes :: number of glyphs in the font that match a given Unicode + * value.. + * + * unicodes :: array of unicode values, sorted in increasing order + * gindex :: array of glyph indices, corresponding to each unicode + * + * + * Use the function PS_Lookup_Unicode to retrieve the glyph index + * corresponding to a given Unicode character code. + * + ***************************************************************************/ + + typedef struct PS_UniMap_ + { + FT_UInt unicode; + FT_UInt glyph_index; + + } PS_UniMap; + + typedef struct PS_Unicodes_ + { + FT_UInt num_maps; + PS_UniMap* maps; + + } PS_Unicodes; + + + typedef FT_Error (*PS_Build_Unicodes_Func)( FT_Memory memory, + FT_UInt num_glyphs, + const char** glyph_names, + PS_Unicodes* unicodes ); + + typedef FT_UInt (*PS_Lookup_Unicode_Func)( PS_Unicodes* unicodes, + FT_UInt unicode ); + + /************************************************************************* + * + * + * PSNames_Interface + * + * + * this structure holds pointers to the functions used to load and + * free the basic tables that are required in a `sfnt' font file. + * + * + * unicode_value :: a function used to convert a glyph name into + * a Unicode character code + * + * unicode_index :: a function used to return the glyph index + * corresponding to a given Unicode character + * + * macintosh_name :: a function used to return the standard Apple + * glyph Postscript name corresponding to a given + * string index (used by the TrueType "post" table) + * + * adobe_std_strings :: a function that returns a pointer to a given + * Adobe Standard Strings given a SID + * + * adobe_std_encoding :: a table of 256 unsigned shorts that maps + * character codes in the Adobe Standard Encoding + * to SIDs + * + * adobe_expert_encoding :: a table of 256 unsigned shorts that maps + * character codes in the Adobe Expert Encoding + * to SIDs. + * + * + * The 'unicode_value' and 'unicode_index' will be set to 0 if the + * configuration macro FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined + * + * The 'macintosh_name' will be set to 0 if the configuration macro + * FT_CONFIG_OPTION_POSTSCRIPT_NAMES is undefined + * + *************************************************************************/ + + typedef struct PSNames_Interface_ + { + PS_Unicode_Value_Func unicode_value; + PS_Build_Unicodes_Func build_unicodes; + PS_Lookup_Unicode_Func lookup_unicode; + PS_Macintosh_Name_Func macintosh_name; + + PS_Adobe_Std_Strings_Func adobe_std_strings; + const unsigned short* adobe_std_encoding; + const unsigned short* adobe_expert_encoding; + + } PSNames_Interface; + +#endif /* PSNAMES_H */ + + + +/* END */ diff --git a/src/shared/t1types.h b/src/shared/t1types.h index 8bf5a5b15..9d74ebec9 100644 --- a/src/shared/t1types.h +++ b/src/shared/t1types.h @@ -22,7 +22,7 @@ #define T1TYPES_H #include - +#include #ifdef __cplusplus extern "C" { @@ -290,7 +290,7 @@ T1_Int code_first; T1_Int code_last; - T1_Short* char_index; + T1_UShort* char_index; T1_String** char_name; } T1_Encoding; @@ -427,8 +427,13 @@ typedef struct T1_FaceRec_ { - FT_FaceRec root; - T1_Font type1; + FT_FaceRec root; + T1_Font type1; + void* psnames; + void* afm_data; + FT_CharMapRec charmaprecs[2]; + FT_CharMap charmaps[2]; + PS_Unicodes unicode_map; } T1_FaceRec; diff --git a/src/shared/tttypes.h b/src/shared/tttypes.h index fb4abcd91..eb31b5c51 100644 --- a/src/shared/tttypes.h +++ b/src/shared/tttypes.h @@ -1999,6 +1999,10 @@ /* the basic TrueType tables in the face object */ void* sfnt; + /* a typeless pointer to the PSNames_Interface table used to */ + /* handle glyph names <-> unicode & Mac values */ + void* psnames; + /***********************************************************************/ /* */ /* Optional TrueType/OpenType tables */