freetype2/src/psnames/psmodule.c

409 lines
9.8 KiB
C
Raw Normal View History

2000-06-25 08:47:11 +02:00
/***************************************************************************/
/* */
/* psmodule.c */
/* */
/* PSNames module implementation (body). */
/* */
/* Copyright 1996-2001, 2002, 2003 by */
2000-06-25 08:47:11 +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-12-08 17:17:16 +01:00
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_POSTSCRIPT_NAMES_H
Complete redesign of error codes. Please check ftmoderr.h for more details. * include/freetype/internal/cfferrs.h, include/freetype/internal/tterrors.h, include/freetype/internal/t1errors.h: Removed. Replaced with files local to the module. All extra error codes have been moved to `fterrors.h'. * src/sfnt/ttpost.h: Move error codes to `fterrors.h'. * src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h, src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h, src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h, src/smooth/ftsmerrs.h, src/truetype/tterrors.h, src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the error names for the module it belongs to. * include/freetype/ftmoderr.h: New file, defining the module error offsets. Its structure is similar to `fterrors.h'. * include/freetype/fterrors.h (FT_NOERRORDEF): New macro. (FT_ERRORDEF): Redefined to use module error offsets. All internal error codes are now public; unused error codes have been removed, some are new. * include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New macro. * include/freetype/config/ftoption.h (FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro. All other source files have been updated to use the new error codes; some already existing (internal) error codes local to a module have been renamed to give them the same name as in the base module. All make files have been updated to include the local error files. * src/cid/cidtokens.h: Replaced with... * src/cid/cidtoken.h: This file for 8+3 consistency. * src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
#include "psmodule.h"
#include "pstables.h"
2000-12-08 17:17:16 +01:00
Complete redesign of error codes. Please check ftmoderr.h for more details. * include/freetype/internal/cfferrs.h, include/freetype/internal/tterrors.h, include/freetype/internal/t1errors.h: Removed. Replaced with files local to the module. All extra error codes have been moved to `fterrors.h'. * src/sfnt/ttpost.h: Move error codes to `fterrors.h'. * src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h, src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h, src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h, src/smooth/ftsmerrs.h, src/truetype/tterrors.h, src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the error names for the module it belongs to. * include/freetype/ftmoderr.h: New file, defining the module error offsets. Its structure is similar to `fterrors.h'. * include/freetype/fterrors.h (FT_NOERRORDEF): New macro. (FT_ERRORDEF): Redefined to use module error offsets. All internal error codes are now public; unused error codes have been removed, some are new. * include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New macro. * include/freetype/config/ftoption.h (FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro. All other source files have been updated to use the new error codes; some already existing (internal) error codes local to a module have been renamed to give them the same name as in the base module. All make files have been updated to include the local error files. * src/cid/cidtokens.h: Replaced with... * src/cid/cidtoken.h: This file for 8+3 consistency. * src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
#include "psnamerr.h"
2000-06-22 02:27:15 +02:00
#ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
2000-06-25 08:47:11 +02:00
2000-06-22 02:27:15 +02:00
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
2000-06-25 08:47:11 +02:00
/* return the Unicode value corresponding to a given glyph. Note that */
/* we do deal with glyph variants by detecting a non-initial dot in */
/* the name, as in `A.swash' or `e.final', etc. */
/* */
* src/sfnt/ttpost.c (load_post_names, tt_face_free_ps_names, tt_face_get_ps_name): Replace switch statement with if clauses to make it more portable. * src/cff/cffobjs.c (cff_face_init): Ditto. * include/freetype/ftmodule.h (FT_Module_Class): Use `FT_Long' for `module_size'. * include/freetype/ftrender.h (FT_Glyph_Class_): Use `FT_Long' for `glyph_size'. * src/base/ftobjs.c (FT_Render_Glyph): Change second parameter to `FT_Render_Mode'. (FT_Render_Glyph_Internal): Change third parameter to `FT_Render_Mode'. * src/base/ftglyph.c (FT_Glyph_To_Bitmap): Change second parameter to `FT_Render_Mode'. * src/raster/ftrend1.c (ft_raster1_render): Change third parameter to `FT_Render_Mode'. * src/smooth/ftsmooth.c (ft_smooth_render, ft_smooth_render_lcd, ft_smooth_render_lcd_v): Ditto. (ft_smooth_render_generic): Change third and fifth parameter to `FT_Render_Mode'. * include/freetype/freetype.h, include/freetype/internal/ftobjs.h, include/freetype/ftglyph.h: Updated. * src/cff/cffdrivr.c (Load_Glyph), src/pcf/pcfdriver.c (PCF_Glyph_Load), src/pfr/pfrobjs.c (pfr_slot_load), src/winfonts/winfnt.c (FNT_Load_Glyph), src/t42/t42objs.c (T42_GlyphSlot_Load), src/bdf/bdfdrivr.c (BDF_Glyph_Load): Change fourth parameter to `FT_Int32'. * src/pfr/pfrobjs.c (pfr_face_init): Add two missing parameters and declare them as unused. * src/cid/cidparse.h (CID_Parser): Use FT_Long for `postscript_len'. * src/psnames/psnames.h (PS_Unicode_Value_Func): Change return value to FT_UInt32. * src/psnames/psmodule.c (ps_unicode_value, ps_build_unicode_table): Updated accordingly. * src/cff/cffdrivr.c (Get_Kerning): Use FT_Long for `middle'. (cff_get_glyph_name): Use cast for result of ft_strlen. * src/cff/cffparse.c (cff_parse_real): User cast for assigning `exp'. * src/cff/cffload.c (cff_index_get_pointers): Use FT_ULong for some local variables. (cff_charset_load, cff_encoding_load): Use casts to FT_UInt for some switch statements. (cff_font_load): Use cast in call to CFF_Load_FD_Select. * src/cff/cffobjs.c (cff_size_init): Use more casts. (cff_face_init): Use FT_Int32 for `flags'. * src/cff/cffgload.c (cff_operator_seac): Use cast for assigning `adx' and `ady'. (cff_decoder_parse_charstrings): Use FT_ULong for third parameter. Use more casts. * src/cff/cffcmap.c (cff_cmap_unicode_init): Use cast for `count'. * src/cid/cidload.c (cid_read_subrs): Use FT_ULong for `len'. * src/cid/cidgload.c (cid_load_glyph): Add missing cast for `cid_get_offset'. * src/psaux/t1decode.c (t1_decoder_parse_charstrings) <18>: Use cast for `num_points'. (t1_decoder_init): Use cast for assigning `decoder->num_glyphs'. * src/base/ftdebug.c (ft_debug_init): Use FT_Int. * include/freetype/internal/ftdriver.h (FT_Slot_LoadFunc): Use `FT_Int32' for fourth parameter. * src/base/ftobjs.c (open_face): Use cast for calling clazz->init_face. * src/raster/ftraster.c (Set_High_Precision): Use `1' instead of `1L'. (Finalize_Profile_Table, Line_Up, ft_black_init): Use casts. * src/raster/ftrend1.c (ft_raster1_render): Ditto. * src/sfnt/sfnt_dir_check: Compare `magic' with unsigned long constant. * builds/amiga/include/freetype/config/ftmodule.h: Updated.
2002-09-27 13:09:23 +02:00
static FT_UInt32
ps_unicode_value( const char* glyph_name )
2000-06-22 02:27:15 +02:00
{
FT_Int n;
char first = glyph_name[0];
char temp[64];
2000-06-25 08:47:11 +02:00
/* If the name begins with `uni', then the glyph name may be a */
2000-06-25 08:47:11 +02:00
/* hard-coded unicode character code. */
2000-06-22 02:27:15 +02:00
if ( glyph_name[0] == 'u' &&
glyph_name[1] == 'n' &&
glyph_name[2] == 'i' )
{
/* determine whether the next four characters following are */
/* hexadecimal. */
/* XXX: Add code to deal with ligatures, i.e. glyph names like */
/* `uniXXXXYYYYZZZZ'... */
2000-06-25 08:47:11 +02:00
FT_Int count;
FT_ULong value = 0;
const char* p = glyph_name + 3;
2000-06-25 08:47:11 +02:00
2000-06-22 02:27:15 +02:00
2000-06-25 08:47:11 +02:00
for ( count = 4; count > 0; count--, p++ )
2000-06-22 02:27:15 +02:00
{
char c = *p;
unsigned int d;
2000-06-22 02:27:15 +02:00
2000-06-25 08:47:11 +02:00
d = (unsigned char)c - '0';
if ( d >= 10 )
2000-06-22 02:27:15 +02:00
{
d = (unsigned char)c - 'A';
if ( d >= 6 )
d = 16;
else
d += 10;
}
/* exit if a non-uppercase hexadecimal character was found */
2000-06-25 08:47:11 +02:00
if ( d >= 16 )
2000-06-22 02:27:15 +02:00
break;
2000-06-25 08:47:11 +02:00
value = ( value << 4 ) + d;
2000-06-22 02:27:15 +02:00
}
/* there must be exactly four hex digits */
* src/winfonts/winfnt.c (FNT_Load_Glyph): Use first_char in computation of glyph_index. (FNT_Size_Set_Pixels): To find a strike, first check pixel_height only, then try to find a better hit by comparing pixel_width also. Without this fix it isn't possible to access all strikes. Also compute metrics.max_advance to be in sync with other bitmap drivers. * src/base/ftobjs.c (FT_Set_Char_Size): Remove redundant code. (FT_Set_Pixel_Size): Assign value to `metrics' after validation of arguments. Synchronize computation of height and width for bitmap strikes. The `width' field in the FT_Bitmap_Size structure is now only useful to enumerate different strikes. The `max_advance' field of the FT_Size_Metrics structure should be used to get the (maximum) width of a strike. * src/bdf/bdfdrivr.c (BDF_Face_Init): Don't use AVERAGE_WIDTH for computing `available_sizes->width' but make it always equal to `available_sizes->height'. * src/pcf/pcfread.c (pcf_load_font): Don't use RESOLUTION_X for computing `available_sizes->width' but make it always equal to `available_sizes->height'. * src/truetype/ttdriver.c (Set_Pixel_Sizes): Pass only single argument to function. * src/psnames/psmodule.c (ps_unicode_value): Handle `.' after `uniXXXX' and `uXXXX[X[X]]'. * src/bdf/bdfdrivr.c: s/FT_Err_/BDF_Err/. * src/cache/ftccache.c, src/cache/ftcsbits.c, src/cache/ftlru.c: s/FT_Err_/FTC_Err_/. * src/cff/cffcmap.c: s/FT_Err_/CFF_Err_/. * src/pcf/pcfdrivr.c: s/FT_Err_/PCF_Err_/. * src/psaux/t1cmap.c: Include psauxerr.h. s/FT_Err_/PSaux_Err_/. * src/pshinter/pshnterr.h: New file. * src/pshinter/rules.mk: Updated. * src/pshinter/pshalgo.c, src/pshinter/pshrec.c: Include pshnterr.h. s/FT_Err_/PSH_Err_/. * src/pfr/pfrdrivr.c, src/pfr/pfrobjs.c, src/pfr/pfrsbit.c: s/FT_Err_/PFR_Err_/. * src/sfnt/sfdriver.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c: s/FT_Err_/SFNT_Err_/. * src/truetype/ttgload.c: s/FT_Err_/TT_Err_/. * src/gzip/ftgzip.c: Load FT_MODULE_ERRORS_H and define FT_ERR_PREFIX and FT_ERR_BASE. s/FT_Err_/Gzip_Err_/.
2003-06-22 17:33:53 +02:00
if ( ( *p == '\0' || *p == '.' ) && count == 0 )
return value;
}
/* If the name begins with `u', followed by four to six uppercase */
/* hexadicimal digits, it is a hard-coded unicode character code. */
if ( glyph_name[0] == 'u' )
{
FT_Int count;
FT_ULong value = 0;
const char* p = glyph_name + 1;
for ( count = 6; count > 0; count--, p++ )
{
char c = *p;
unsigned int d;
d = (unsigned char)c - '0';
if ( d >= 10 )
{
d = (unsigned char)c - 'A';
if ( d >= 6 )
d = 16;
else
d += 10;
}
if ( d >= 16 )
break;
value = ( value << 4 ) + d;
}
* src/winfonts/winfnt.c (FNT_Load_Glyph): Use first_char in computation of glyph_index. (FNT_Size_Set_Pixels): To find a strike, first check pixel_height only, then try to find a better hit by comparing pixel_width also. Without this fix it isn't possible to access all strikes. Also compute metrics.max_advance to be in sync with other bitmap drivers. * src/base/ftobjs.c (FT_Set_Char_Size): Remove redundant code. (FT_Set_Pixel_Size): Assign value to `metrics' after validation of arguments. Synchronize computation of height and width for bitmap strikes. The `width' field in the FT_Bitmap_Size structure is now only useful to enumerate different strikes. The `max_advance' field of the FT_Size_Metrics structure should be used to get the (maximum) width of a strike. * src/bdf/bdfdrivr.c (BDF_Face_Init): Don't use AVERAGE_WIDTH for computing `available_sizes->width' but make it always equal to `available_sizes->height'. * src/pcf/pcfread.c (pcf_load_font): Don't use RESOLUTION_X for computing `available_sizes->width' but make it always equal to `available_sizes->height'. * src/truetype/ttdriver.c (Set_Pixel_Sizes): Pass only single argument to function. * src/psnames/psmodule.c (ps_unicode_value): Handle `.' after `uniXXXX' and `uXXXX[X[X]]'. * src/bdf/bdfdrivr.c: s/FT_Err_/BDF_Err/. * src/cache/ftccache.c, src/cache/ftcsbits.c, src/cache/ftlru.c: s/FT_Err_/FTC_Err_/. * src/cff/cffcmap.c: s/FT_Err_/CFF_Err_/. * src/pcf/pcfdrivr.c: s/FT_Err_/PCF_Err_/. * src/psaux/t1cmap.c: Include psauxerr.h. s/FT_Err_/PSaux_Err_/. * src/pshinter/pshnterr.h: New file. * src/pshinter/rules.mk: Updated. * src/pshinter/pshalgo.c, src/pshinter/pshrec.c: Include pshnterr.h. s/FT_Err_/PSH_Err_/. * src/pfr/pfrdrivr.c, src/pfr/pfrobjs.c, src/pfr/pfrsbit.c: s/FT_Err_/PFR_Err_/. * src/sfnt/sfdriver.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c: s/FT_Err_/SFNT_Err_/. * src/truetype/ttgload.c: s/FT_Err_/TT_Err_/. * src/gzip/ftgzip.c: Load FT_MODULE_ERRORS_H and define FT_ERR_PREFIX and FT_ERR_BASE. s/FT_Err_/Gzip_Err_/.
2003-06-22 17:33:53 +02:00
if ( ( *p == '\0' || *p == '.' ) && count <= 2 )
return value;
2000-06-22 02:27:15 +02:00
}
/* look for a non-initial dot in the glyph name in order to */
2000-06-25 08:47:11 +02:00
/* sort-out variants like `A.swash', `e.final', etc. */
2000-06-22 02:27:15 +02:00
{
const char* p;
int len;
2000-06-25 08:47:11 +02:00
2000-06-22 02:27:15 +02:00
p = glyph_name;
2000-06-25 08:47:11 +02:00
while ( *p && *p != '.' )
p++;
len = (int)( p - glyph_name );
2000-06-22 02:27:15 +02:00
if ( *p && len < 64 )
{
ft_strncpy( temp, glyph_name, len );
2000-06-22 02:27:15 +02:00
temp[len] = 0;
glyph_name = temp;
}
}
/* now, look up the glyph in the Adobe Glyph List */
2000-06-22 02:27:15 +02:00
for ( n = 0; n < NUM_ADOBE_GLYPHS; n++ )
{
const char* name = sid_standard_names[n];
2000-06-22 02:27:15 +02:00
2000-06-25 08:47:11 +02:00
if ( first == name[0] && ft_strcmp( glyph_name, name ) == 0 )
return ps_names_to_unicode[n];
2000-06-22 02:27:15 +02:00
}
2000-06-25 08:47:11 +02:00
2000-06-22 02:27:15 +02:00
/* not found, there is probably no Unicode value for this glyph name */
return 0;
}
/* ft_qsort callback to sort the unicode map */
2001-06-28 01:25:46 +02:00
FT_CALLBACK_DEF( int )
compare_uni_maps( const void* a,
const void* b )
2000-06-22 02:27:15 +02:00
{
PS_UniMap* map1 = (PS_UniMap*)a;
PS_UniMap* map2 = (PS_UniMap*)b;
2000-06-25 08:47:11 +02:00
return ( map1->unicode - map2->unicode );
2000-06-22 02:27:15 +02:00
}
2000-06-25 08:47:11 +02:00
/* Builds a table that maps Unicode values to glyph indices */
2001-06-28 01:25:46 +02:00
static FT_Error
ps_unicodes_init( FT_Memory memory,
FT_UInt num_glyphs,
const char** glyph_names,
PS_Unicodes* table )
2000-06-22 02:27:15 +02:00
{
FT_Error error;
2000-06-25 08:47:11 +02:00
2000-06-22 02:27:15 +02:00
/* we first allocate the table */
table->num_maps = 0;
table->maps = 0;
if ( !FT_NEW_ARRAY( table->maps, num_glyphs ) )
2000-06-22 02:27:15 +02:00
{
FT_UInt n;
FT_UInt count;
PS_UniMap* map;
* src/sfnt/ttpost.c (load_post_names, tt_face_free_ps_names, tt_face_get_ps_name): Replace switch statement with if clauses to make it more portable. * src/cff/cffobjs.c (cff_face_init): Ditto. * include/freetype/ftmodule.h (FT_Module_Class): Use `FT_Long' for `module_size'. * include/freetype/ftrender.h (FT_Glyph_Class_): Use `FT_Long' for `glyph_size'. * src/base/ftobjs.c (FT_Render_Glyph): Change second parameter to `FT_Render_Mode'. (FT_Render_Glyph_Internal): Change third parameter to `FT_Render_Mode'. * src/base/ftglyph.c (FT_Glyph_To_Bitmap): Change second parameter to `FT_Render_Mode'. * src/raster/ftrend1.c (ft_raster1_render): Change third parameter to `FT_Render_Mode'. * src/smooth/ftsmooth.c (ft_smooth_render, ft_smooth_render_lcd, ft_smooth_render_lcd_v): Ditto. (ft_smooth_render_generic): Change third and fifth parameter to `FT_Render_Mode'. * include/freetype/freetype.h, include/freetype/internal/ftobjs.h, include/freetype/ftglyph.h: Updated. * src/cff/cffdrivr.c (Load_Glyph), src/pcf/pcfdriver.c (PCF_Glyph_Load), src/pfr/pfrobjs.c (pfr_slot_load), src/winfonts/winfnt.c (FNT_Load_Glyph), src/t42/t42objs.c (T42_GlyphSlot_Load), src/bdf/bdfdrivr.c (BDF_Glyph_Load): Change fourth parameter to `FT_Int32'. * src/pfr/pfrobjs.c (pfr_face_init): Add two missing parameters and declare them as unused. * src/cid/cidparse.h (CID_Parser): Use FT_Long for `postscript_len'. * src/psnames/psnames.h (PS_Unicode_Value_Func): Change return value to FT_UInt32. * src/psnames/psmodule.c (ps_unicode_value, ps_build_unicode_table): Updated accordingly. * src/cff/cffdrivr.c (Get_Kerning): Use FT_Long for `middle'. (cff_get_glyph_name): Use cast for result of ft_strlen. * src/cff/cffparse.c (cff_parse_real): User cast for assigning `exp'. * src/cff/cffload.c (cff_index_get_pointers): Use FT_ULong for some local variables. (cff_charset_load, cff_encoding_load): Use casts to FT_UInt for some switch statements. (cff_font_load): Use cast in call to CFF_Load_FD_Select. * src/cff/cffobjs.c (cff_size_init): Use more casts. (cff_face_init): Use FT_Int32 for `flags'. * src/cff/cffgload.c (cff_operator_seac): Use cast for assigning `adx' and `ady'. (cff_decoder_parse_charstrings): Use FT_ULong for third parameter. Use more casts. * src/cff/cffcmap.c (cff_cmap_unicode_init): Use cast for `count'. * src/cid/cidload.c (cid_read_subrs): Use FT_ULong for `len'. * src/cid/cidgload.c (cid_load_glyph): Add missing cast for `cid_get_offset'. * src/psaux/t1decode.c (t1_decoder_parse_charstrings) <18>: Use cast for `num_points'. (t1_decoder_init): Use cast for assigning `decoder->num_glyphs'. * src/base/ftdebug.c (ft_debug_init): Use FT_Int. * include/freetype/internal/ftdriver.h (FT_Slot_LoadFunc): Use `FT_Int32' for fourth parameter. * src/base/ftobjs.c (open_face): Use cast for calling clazz->init_face. * src/raster/ftraster.c (Set_High_Precision): Use `1' instead of `1L'. (Finalize_Profile_Table, Line_Up, ft_black_init): Use casts. * src/raster/ftrend1.c (ft_raster1_render): Ditto. * src/sfnt/sfnt_dir_check: Compare `magic' with unsigned long constant. * builds/amiga/include/freetype/config/ftmodule.h: Updated.
2002-09-27 13:09:23 +02:00
FT_UInt32 uni_char;
2000-06-22 02:27:15 +02:00
2000-06-25 08:47:11 +02:00
2000-06-22 02:27:15 +02:00
map = table->maps;
2000-06-22 02:27:15 +02:00
for ( n = 0; n < num_glyphs; n++ )
{
const char* gname = glyph_names[n];
2000-06-25 08:47:11 +02:00
if ( gname )
2000-06-22 02:27:15 +02:00
{
uni_char = ps_unicode_value( gname );
if ( uni_char != 0 && uni_char != 0xFFFFL )
2000-06-22 02:27:15 +02:00
{
map->unicode = (FT_UInt)uni_char;
2000-06-22 02:27:15 +02:00
map->glyph_index = n;
map++;
}
}
}
/* now, compress the table a bit */
count = (FT_UInt)( map - table->maps );
if ( count > 0 && FT_REALLOC( table->maps,
num_glyphs * sizeof ( PS_UniMap ),
count * sizeof ( PS_UniMap ) ) )
2000-06-22 02:27:15 +02:00
count = 0;
2000-06-25 08:47:11 +02:00
if ( count == 0 )
2000-06-22 02:27:15 +02:00
{
FT_FREE( table->maps );
2000-06-25 08:47:11 +02:00
if ( !error )
Complete redesign of error codes. Please check ftmoderr.h for more details. * include/freetype/internal/cfferrs.h, include/freetype/internal/tterrors.h, include/freetype/internal/t1errors.h: Removed. Replaced with files local to the module. All extra error codes have been moved to `fterrors.h'. * src/sfnt/ttpost.h: Move error codes to `fterrors.h'. * src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h, src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h, src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h, src/smooth/ftsmerrs.h, src/truetype/tterrors.h, src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the error names for the module it belongs to. * include/freetype/ftmoderr.h: New file, defining the module error offsets. Its structure is similar to `fterrors.h'. * include/freetype/fterrors.h (FT_NOERRORDEF): New macro. (FT_ERRORDEF): Redefined to use module error offsets. All internal error codes are now public; unused error codes have been removed, some are new. * include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New macro. * include/freetype/config/ftoption.h (FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro. All other source files have been updated to use the new error codes; some already existing (internal) error codes local to a module have been renamed to give them the same name as in the base module. All make files have been updated to include the local error files. * src/cid/cidtokens.h: Replaced with... * src/cid/cidtoken.h: This file for 8+3 consistency. * src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
error = PSnames_Err_Invalid_Argument; /* no unicode chars here! */
2000-06-22 02:27:15 +02:00
}
else
/* sort the table in increasing order of unicode values */
ft_qsort( table->maps, count, sizeof ( PS_UniMap ), compare_uni_maps );
2000-06-22 02:27:15 +02:00
table->num_maps = count;
}
2000-06-25 08:47:11 +02:00
2000-06-22 02:27:15 +02:00
return error;
}
2000-06-25 08:47:11 +02:00
2001-06-28 01:25:46 +02:00
static FT_UInt
ps_unicodes_char_index( PS_Unicodes* table,
FT_ULong unicode )
2000-06-22 02:27:15 +02:00
{
PS_UniMap *min, *max, *mid;
2000-06-25 08:47:11 +02:00
2000-06-22 02:27:15 +02:00
/* perform a binary search on the table */
2000-06-22 02:27:15 +02:00
min = table->maps;
max = min + table->num_maps - 1;
2000-06-25 08:47:11 +02:00
while ( min <= max )
2000-06-22 02:27:15 +02:00
{
2000-06-25 08:47:11 +02:00
mid = min + ( max - min ) / 2;
2000-06-22 02:27:15 +02:00
if ( mid->unicode == unicode )
return mid->glyph_index;
2000-06-25 08:47:11 +02:00
if ( min == max )
2000-06-22 02:27:15 +02:00
break;
2000-06-25 08:47:11 +02:00
if ( mid->unicode < unicode )
min = mid + 1;
else
max = mid - 1;
2000-06-22 02:27:15 +02:00
}
return 0xFFFFU;
2000-06-22 02:27:15 +02:00
}
static FT_ULong
ps_unicodes_char_next( PS_Unicodes* table,
FT_ULong unicode )
{
PS_UniMap *min, *max, *mid;
unicode++;
/* perform a binary search on the table */
min = table->maps;
max = min + table->num_maps - 1;
while ( min <= max )
{
mid = min + ( max - min ) / 2;
if ( mid->unicode == unicode )
return unicode;
if ( min == max )
break;
if ( mid->unicode < unicode )
min = mid + 1;
else
max = mid - 1;
}
if ( max < table->maps )
max = table->maps;
while ( max < table->maps + table->num_maps )
{
if ( unicode < max->unicode )
return max->unicode;
max++;
}
return 0;
}
2000-06-25 08:47:11 +02:00
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
2000-06-22 02:27:15 +02:00
2001-06-28 01:25:46 +02:00
static const char*
ps_get_macintosh_name( FT_UInt name_index )
2000-06-22 02:27:15 +02:00
{
2000-06-25 08:47:11 +02:00
if ( name_index >= 258 )
2000-06-22 02:27:15 +02:00
name_index = 0;
return ps_glyph_names[mac_standard_names[name_index]];
2000-06-22 02:27:15 +02:00
}
2001-06-28 01:25:46 +02:00
static const char*
ps_get_standard_strings( FT_UInt sid )
2000-06-22 02:27:15 +02:00
{
return ( sid < NUM_SID_GLYPHS ? sid_standard_names[sid] : 0 );
2000-06-22 02:27:15 +02:00
}
static
const FT_Service_PsNamesRec psnames_interface =
2000-06-22 02:27:15 +02:00
{
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
2000-06-25 08:47:11 +02:00
(PS_Unicode_ValueFunc) ps_unicode_value,
(PS_Unicodes_InitFunc) ps_unicodes_init,
(PS_Unicodes_CharIndexFunc)ps_unicodes_char_index,
(PS_Unicodes_CharNextFunc) ps_unicodes_char_next,
2000-06-25 08:47:11 +02:00
2000-06-22 02:27:15 +02:00
#else
2000-06-25 08:47:11 +02:00
2000-06-22 02:27:15 +02:00
0,
0,
0,
0,
2000-06-22 02:27:15 +02:00
2000-06-25 08:47:11 +02:00
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
(PS_Macintosh_Name_Func) ps_get_macintosh_name,
(PS_Adobe_Std_Strings_Func)ps_get_standard_strings,
2000-06-22 02:27:15 +02:00
t1_standard_encoding,
t1_expert_encoding
};
static const FT_ServiceDescRec psnames_services[] =
{
{ FT_SERVICE_ID_POSTSCRIPT_NAMES, &psnames_interface },
{ NULL, NULL }
2000-06-22 02:27:15 +02:00
};
static FT_Pointer
psnames_get_service( FT_Module module,
const char* service_id )
{
FT_UNUSED( module );
return ft_service_list_lookup( psnames_services, service_id );
}
2000-06-22 02:27:15 +02:00
2000-06-25 08:47:11 +02:00
#endif /* !FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES */
2000-06-22 02:27:15 +02:00
FT_CALLBACK_TABLE_DEF
const FT_Module_Class psnames_module_class =
2000-06-22 02:27:15 +02:00
{
0, /* this is not a font driver, nor a renderer */
sizeof ( FT_ModuleRec ),
2000-06-22 02:27:15 +02:00
"psnames", /* driver name */
0x10000L, /* driver version */
0x20000L, /* driver requires FreeType 2 or above */
2000-06-22 02:27:15 +02:00
#ifdef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
0,
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
2000-06-22 02:27:15 +02:00
#else
(void*)&psnames_interface, /* module specific interface */
2000-06-25 08:47:11 +02:00
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) psnames_get_service
#endif
2000-06-22 02:27:15 +02:00
};
2000-06-25 08:47:11 +02:00
/* END */