freetype2/src/autofit/afglobal.c

333 lines
9.3 KiB
C
Raw Normal View History

/***************************************************************************/
/* */
/* afglobal.c */
/* */
/* Auto-fitter routines to compute global hinting values (body). */
/* */
/* Copyright 2003-2013 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. */
/* */
/***************************************************************************/
2003-11-23 22:39:51 +01:00
#include "afglobal.h"
#include "afdummy.h"
2003-11-23 22:39:51 +01:00
#include "aflatin.h"
#include "afcjk.h"
#include "afindic.h"
Position Independent Code (PIC) support in autofit module. * include/freetype/internal/autohint.h add macros to init instances of FT_AutoHinter_ServiceRec. * src/autofit/afmodule.h declare autofit_module_class using macros from ftmodapi.h, when FT_CONFIG_OPTION_PIC is defined create and destroy functions will be declared. * src/autofit/afmodule.c when FT_CONFIG_OPTION_PIC is defined af_autofitter_service and autofit_module_class structs will have functions to init or create and destroy them instead of being allocated in the global scope. And macros will be used from afpic.h in order to access them. * src/autofit/aftypes.h add macros to init and declare instances of AF_ScriptClassRec. * src/autofit/afcjk.h declare af_cjk_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afcjk.c when FT_CONFIG_OPTION_PIC is defined af_cjk_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/afdummy.h declare af_dummy_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afdummy.c when FT_CONFIG_OPTION_PIC is defined af_dummy_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/afindic.h declare af_indic_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afindic.c when FT_CONFIG_OPTION_PIC is defined af_indic_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/aflatin.h declare af_latin_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/aflatin.c when FT_CONFIG_OPTION_PIC is defined af_latin_script_class struct will have function to init it instead of being allocated in the global scope. Change af_latin_blue_chars to be PIC-compatible by being a two dimentional array rather than array of pointers. * src/autofit/aflatin2.h declare af_latin2_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/aflatin2.c when FT_CONFIG_OPTION_PIC is defined af_latin2_script_class struct will have function to init it instead of being allocated in the global scope. Change af_latin2_blue_chars to be PIC-compatible by being a two dimentional array rather than array of pointers. * src/autofit/afglobal.c when FT_CONFIG_OPTION_PIC is defined af_script_classes array initialization was moved to afpic.c and is later refered using macros defeined in afpic.h. New Files: * src/autofit/afpic.h declare struct to hold PIC globals for autofit module and macros to access them. * src/autofit/afpic.c implement functions to allocate, destroy and initialize PIC globals for autofit module. * src/autofit/autofit.c add new file to build: afpic.c. * src/autofit/jamfile add new files to FT2_MULTI build: afpic.c.
2009-04-05 17:23:38 +02:00
#include "afpic.h"
#include "aferrors.h"
2003-11-23 22:39:51 +01:00
#ifdef FT_OPTION_AUTOFIT2
#include "aflatin2.h"
#endif
Position Independent Code (PIC) support in autofit module. * include/freetype/internal/autohint.h add macros to init instances of FT_AutoHinter_ServiceRec. * src/autofit/afmodule.h declare autofit_module_class using macros from ftmodapi.h, when FT_CONFIG_OPTION_PIC is defined create and destroy functions will be declared. * src/autofit/afmodule.c when FT_CONFIG_OPTION_PIC is defined af_autofitter_service and autofit_module_class structs will have functions to init or create and destroy them instead of being allocated in the global scope. And macros will be used from afpic.h in order to access them. * src/autofit/aftypes.h add macros to init and declare instances of AF_ScriptClassRec. * src/autofit/afcjk.h declare af_cjk_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afcjk.c when FT_CONFIG_OPTION_PIC is defined af_cjk_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/afdummy.h declare af_dummy_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afdummy.c when FT_CONFIG_OPTION_PIC is defined af_dummy_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/afindic.h declare af_indic_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afindic.c when FT_CONFIG_OPTION_PIC is defined af_indic_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/aflatin.h declare af_latin_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/aflatin.c when FT_CONFIG_OPTION_PIC is defined af_latin_script_class struct will have function to init it instead of being allocated in the global scope. Change af_latin_blue_chars to be PIC-compatible by being a two dimentional array rather than array of pointers. * src/autofit/aflatin2.h declare af_latin2_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/aflatin2.c when FT_CONFIG_OPTION_PIC is defined af_latin2_script_class struct will have function to init it instead of being allocated in the global scope. Change af_latin2_blue_chars to be PIC-compatible by being a two dimentional array rather than array of pointers. * src/autofit/afglobal.c when FT_CONFIG_OPTION_PIC is defined af_script_classes array initialization was moved to afpic.c and is later refered using macros defeined in afpic.h. New Files: * src/autofit/afpic.h declare struct to hold PIC globals for autofit module and macros to access them. * src/autofit/afpic.c implement functions to allocate, destroy and initialize PIC globals for autofit module. * src/autofit/autofit.c add new file to build: afpic.c. * src/autofit/jamfile add new files to FT2_MULTI build: afpic.c.
2009-04-05 17:23:38 +02:00
#ifndef FT_CONFIG_OPTION_PIC
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
/* when updating this table, don't forget to update */
/* AF_WRITING_SYSTEM_CLASSES_COUNT and autofit_module_class_pic_init */
/* populate this list when you add new writing systems */
FT_LOCAL_ARRAY_DEF( AF_WritingSystemClass )
af_writing_system_classes[] =
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
{
&af_dummy_writing_system_class,
&af_latin_writing_system_class,
&af_cjk_writing_system_class,
&af_indic_writing_system_class,
#ifdef FT_OPTION_AUTOFIT2
&af_latin2_writing_system_class,
#endif
NULL /* do not remove */
};
/* when updating this table, don't forget to update */
/* AF_SCRIPT_CLASSES_COUNT and autofit_module_class_pic_init */
Position Independent Code (PIC) support in autofit module. * include/freetype/internal/autohint.h add macros to init instances of FT_AutoHinter_ServiceRec. * src/autofit/afmodule.h declare autofit_module_class using macros from ftmodapi.h, when FT_CONFIG_OPTION_PIC is defined create and destroy functions will be declared. * src/autofit/afmodule.c when FT_CONFIG_OPTION_PIC is defined af_autofitter_service and autofit_module_class structs will have functions to init or create and destroy them instead of being allocated in the global scope. And macros will be used from afpic.h in order to access them. * src/autofit/aftypes.h add macros to init and declare instances of AF_ScriptClassRec. * src/autofit/afcjk.h declare af_cjk_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afcjk.c when FT_CONFIG_OPTION_PIC is defined af_cjk_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/afdummy.h declare af_dummy_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afdummy.c when FT_CONFIG_OPTION_PIC is defined af_dummy_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/afindic.h declare af_indic_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afindic.c when FT_CONFIG_OPTION_PIC is defined af_indic_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/aflatin.h declare af_latin_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/aflatin.c when FT_CONFIG_OPTION_PIC is defined af_latin_script_class struct will have function to init it instead of being allocated in the global scope. Change af_latin_blue_chars to be PIC-compatible by being a two dimentional array rather than array of pointers. * src/autofit/aflatin2.h declare af_latin2_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/aflatin2.c when FT_CONFIG_OPTION_PIC is defined af_latin2_script_class struct will have function to init it instead of being allocated in the global scope. Change af_latin2_blue_chars to be PIC-compatible by being a two dimentional array rather than array of pointers. * src/autofit/afglobal.c when FT_CONFIG_OPTION_PIC is defined af_script_classes array initialization was moved to afpic.c and is later refered using macros defeined in afpic.h. New Files: * src/autofit/afpic.h declare struct to hold PIC globals for autofit module and macros to access them. * src/autofit/afpic.c implement functions to allocate, destroy and initialize PIC globals for autofit module. * src/autofit/autofit.c add new file to build: afpic.c. * src/autofit/jamfile add new files to FT2_MULTI build: afpic.c.
2009-04-05 17:23:38 +02:00
/* populate this list when you add new scripts */
FT_LOCAL_ARRAY_DEF( AF_ScriptClass )
af_script_classes[] =
2003-11-23 22:39:51 +01:00
{
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
&af_dflt_script_class, /* XXX */
&af_latn_script_class,
&af_hani_script_class,
&af_deva_script_class,
#ifdef FT_OPTION_AUTOFIT2
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
&af_ltn2_script_class,
#endif
2003-11-23 22:39:51 +01:00
NULL /* do not remove */
};
#endif /* !FT_CONFIG_OPTION_PIC */
Position Independent Code (PIC) support in autofit module. * include/freetype/internal/autohint.h add macros to init instances of FT_AutoHinter_ServiceRec. * src/autofit/afmodule.h declare autofit_module_class using macros from ftmodapi.h, when FT_CONFIG_OPTION_PIC is defined create and destroy functions will be declared. * src/autofit/afmodule.c when FT_CONFIG_OPTION_PIC is defined af_autofitter_service and autofit_module_class structs will have functions to init or create and destroy them instead of being allocated in the global scope. And macros will be used from afpic.h in order to access them. * src/autofit/aftypes.h add macros to init and declare instances of AF_ScriptClassRec. * src/autofit/afcjk.h declare af_cjk_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afcjk.c when FT_CONFIG_OPTION_PIC is defined af_cjk_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/afdummy.h declare af_dummy_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afdummy.c when FT_CONFIG_OPTION_PIC is defined af_dummy_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/afindic.h declare af_indic_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afindic.c when FT_CONFIG_OPTION_PIC is defined af_indic_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/aflatin.h declare af_latin_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/aflatin.c when FT_CONFIG_OPTION_PIC is defined af_latin_script_class struct will have function to init it instead of being allocated in the global scope. Change af_latin_blue_chars to be PIC-compatible by being a two dimentional array rather than array of pointers. * src/autofit/aflatin2.h declare af_latin2_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/aflatin2.c when FT_CONFIG_OPTION_PIC is defined af_latin2_script_class struct will have function to init it instead of being allocated in the global scope. Change af_latin2_blue_chars to be PIC-compatible by being a two dimentional array rather than array of pointers. * src/autofit/afglobal.c when FT_CONFIG_OPTION_PIC is defined af_script_classes array initialization was moved to afpic.c and is later refered using macros defeined in afpic.h. New Files: * src/autofit/afpic.h declare struct to hold PIC globals for autofit module and macros to access them. * src/autofit/afpic.c implement functions to allocate, destroy and initialize PIC globals for autofit module. * src/autofit/autofit.c add new file to build: afpic.c. * src/autofit/jamfile add new files to FT2_MULTI build: afpic.c.
2009-04-05 17:23:38 +02:00
/* Compute the script index of each glyph within a given face. */
2003-11-23 22:39:51 +01:00
static FT_Error
af_face_globals_compute_script_coverage( AF_FaceGlobals globals )
2003-11-23 22:39:51 +01:00
{
FT_Error error;
2003-11-23 22:39:51 +01:00
FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap;
FT_Byte* gscripts = globals->glyph_scripts;
FT_UInt ss;
FT_UInt i;
2003-11-23 22:39:51 +01:00
/* the value AF_SCRIPT_NONE means `uncovered glyph' */
2003-11-23 22:39:51 +01:00
FT_MEM_SET( globals->glyph_scripts,
AF_SCRIPT_NONE,
2003-11-23 22:39:51 +01:00
globals->glyph_count );
error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
if ( error )
{
/*
* Ignore this error; we simply use the fallback script.
* XXX: Shouldn't we rather disable hinting?
2003-11-23 22:39:51 +01:00
*/
error = FT_Err_Ok;
2003-11-23 22:39:51 +01:00
goto Exit;
}
/* scan each script in a Unicode charmap */
Position Independent Code (PIC) support in autofit module. * include/freetype/internal/autohint.h add macros to init instances of FT_AutoHinter_ServiceRec. * src/autofit/afmodule.h declare autofit_module_class using macros from ftmodapi.h, when FT_CONFIG_OPTION_PIC is defined create and destroy functions will be declared. * src/autofit/afmodule.c when FT_CONFIG_OPTION_PIC is defined af_autofitter_service and autofit_module_class structs will have functions to init or create and destroy them instead of being allocated in the global scope. And macros will be used from afpic.h in order to access them. * src/autofit/aftypes.h add macros to init and declare instances of AF_ScriptClassRec. * src/autofit/afcjk.h declare af_cjk_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afcjk.c when FT_CONFIG_OPTION_PIC is defined af_cjk_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/afdummy.h declare af_dummy_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afdummy.c when FT_CONFIG_OPTION_PIC is defined af_dummy_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/afindic.h declare af_indic_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/afindic.c when FT_CONFIG_OPTION_PIC is defined af_indic_script_class struct will have function to init it instead of being allocated in the global scope. * src/autofit/aflatin.h declare af_latin_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/aflatin.c when FT_CONFIG_OPTION_PIC is defined af_latin_script_class struct will have function to init it instead of being allocated in the global scope. Change af_latin_blue_chars to be PIC-compatible by being a two dimentional array rather than array of pointers. * src/autofit/aflatin2.h declare af_latin2_script_class using macros from aftypes.h, when FT_CONFIG_OPTION_PIC is defined init function will be declared. * src/autofit/aflatin2.c when FT_CONFIG_OPTION_PIC is defined af_latin2_script_class struct will have function to init it instead of being allocated in the global scope. Change af_latin2_blue_chars to be PIC-compatible by being a two dimentional array rather than array of pointers. * src/autofit/afglobal.c when FT_CONFIG_OPTION_PIC is defined af_script_classes array initialization was moved to afpic.c and is later refered using macros defeined in afpic.h. New Files: * src/autofit/afpic.h declare struct to hold PIC globals for autofit module and macros to access them. * src/autofit/afpic.c implement functions to allocate, destroy and initialize PIC globals for autofit module. * src/autofit/autofit.c add new file to build: afpic.c. * src/autofit/jamfile add new files to FT2_MULTI build: afpic.c.
2009-04-05 17:23:38 +02:00
for ( ss = 0; AF_SCRIPT_CLASSES_GET[ss]; ss++ )
2003-11-23 22:39:51 +01:00
{
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET[ss];
2003-11-23 22:39:51 +01:00
AF_Script_UniRange range;
if ( script_class->script_uni_ranges == NULL )
continue;
/*
* Scan all Unicode points in the range and set the corresponding
* glyph script index.
*/
for ( range = script_class->script_uni_ranges;
range->first != 0;
range++ )
2003-11-23 22:39:51 +01:00
{
FT_ULong charcode = range->first;
FT_UInt gindex;
2003-11-23 22:39:51 +01:00
gindex = FT_Get_Char_Index( face, charcode );
if ( gindex != 0 &&
gindex < (FT_ULong)globals->glyph_count &&
gscripts[gindex] == AF_SCRIPT_NONE )
gscripts[gindex] = (FT_Byte)ss;
2003-11-23 22:39:51 +01:00
for (;;)
{
charcode = FT_Get_Next_Char( face, charcode, &gindex );
if ( gindex == 0 || charcode > range->last )
break;
if ( gindex < (FT_ULong)globals->glyph_count &&
gscripts[gindex] == AF_SCRIPT_NONE )
gscripts[gindex] = (FT_Byte)ss;
2003-11-23 22:39:51 +01:00
}
}
}
/* mark ASCII digits */
for ( i = 0x30; i <= 0x39; i++ )
{
FT_UInt gindex = FT_Get_Char_Index( face, i );
if ( gindex != 0 && gindex < (FT_ULong)globals->glyph_count )
gscripts[gindex] |= AF_DIGIT;
}
2003-11-23 22:39:51 +01:00
Exit:
/*
* By default, all uncovered glyphs are set to the fallback script.
2007-01-31 00:08:50 +01:00
* XXX: Shouldn't we disable hinting or do something similar?
*/
if ( globals->module->fallback_script != AF_SCRIPT_NONE )
2003-11-23 22:39:51 +01:00
{
FT_Long nn;
2003-11-23 22:39:51 +01:00
2003-11-23 22:39:51 +01:00
for ( nn = 0; nn < globals->glyph_count; nn++ )
{
if ( ( gscripts[nn] & ~AF_DIGIT ) == AF_SCRIPT_NONE )
{
gscripts[nn] &= ~AF_SCRIPT_NONE;
gscripts[nn] |= globals->module->fallback_script;
}
2003-11-23 22:39:51 +01:00
}
}
FT_Set_Charmap( face, old_charmap );
return error;
}
FT_LOCAL_DEF( FT_Error )
af_face_globals_new( FT_Face face,
AF_FaceGlobals *aglobals,
AF_Module module )
2003-11-23 22:39:51 +01:00
{
FT_Error error;
FT_Memory memory;
AF_FaceGlobals globals = NULL;
2003-11-23 22:39:51 +01:00
2003-11-23 22:39:51 +01:00
memory = face->memory;
if ( FT_ALLOC( globals, sizeof ( *globals ) +
face->num_glyphs * sizeof ( FT_Byte ) ) )
goto Exit;
2003-11-23 22:39:51 +01:00
globals->face = face;
globals->glyph_count = face->num_glyphs;
globals->glyph_scripts = (FT_Byte*)( globals + 1 );
globals->module = module;
error = af_face_globals_compute_script_coverage( globals );
if ( error )
{
af_face_globals_free( globals );
globals = NULL;
2003-11-23 22:39:51 +01:00
}
globals->increase_x_height = AF_PROP_INCREASE_X_HEIGHT_MAX;
Exit:
2003-11-23 22:39:51 +01:00
*aglobals = globals;
return error;
}
FT_LOCAL_DEF( void )
af_face_globals_free( AF_FaceGlobals globals )
{
if ( globals )
{
FT_Memory memory = globals->face->memory;
FT_UInt nn;
2003-11-23 22:39:51 +01:00
for ( nn = 0; nn < AF_SCRIPT_MAX; nn++ )
{
if ( globals->metrics[nn] )
{
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
AF_ScriptClass script_class =
AF_SCRIPT_CLASSES_GET[nn];
AF_WritingSystemClass writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[script_class->writing_system];
2003-11-23 22:39:51 +01:00
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
if ( writing_system_class->script_metrics_done )
writing_system_class->script_metrics_done( globals->metrics[nn] );
2003-11-23 22:39:51 +01:00
FT_FREE( globals->metrics[nn] );
}
}
globals->glyph_count = 0;
globals->glyph_scripts = NULL; /* no need to free this one! */
2003-11-23 22:39:51 +01:00
globals->face = NULL;
2003-11-23 22:39:51 +01:00
FT_FREE( globals );
}
}
FT_LOCAL_DEF( FT_Error )
af_face_globals_get_metrics( AF_FaceGlobals globals,
FT_UInt gindex,
FT_UInt options,
2003-11-23 22:39:51 +01:00
AF_ScriptMetrics *ametrics )
{
AF_ScriptMetrics metrics = NULL;
FT_UInt gidx;
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
AF_WritingSystemClass writing_system_class;
AF_ScriptClass script_class;
FT_UInt script = options & 15;
const FT_Offset script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) /
sizeof ( AF_SCRIPT_CLASSES_GET[0] );
FT_Error error = FT_Err_Ok;
2003-11-23 22:39:51 +01:00
if ( gindex >= (FT_ULong)globals->glyph_count )
2003-11-23 22:39:51 +01:00
{
error = FT_THROW( Invalid_Argument );
2003-11-23 22:39:51 +01:00
goto Exit;
}
gidx = script;
2007-06-11 23:15:09 +02:00
if ( gidx == 0 || gidx + 1 >= script_max )
gidx = globals->glyph_scripts[gindex] & AF_SCRIPT_NONE;
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
script_class = AF_SCRIPT_CLASSES_GET[gidx];
writing_system_class = AF_WRITING_SYSTEM_CLASSES_GET
[script_class->writing_system];
2007-06-11 23:15:09 +02:00
if ( script == 0 )
script = script_class->script;
metrics = globals->metrics[script_class->script];
2003-11-23 22:39:51 +01:00
if ( metrics == NULL )
{
/* create the global metrics object if necessary */
2004-01-16 10:51:00 +01:00
FT_Memory memory = globals->face->memory;
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
if ( FT_ALLOC( metrics, writing_system_class->script_metrics_size ) )
2003-11-23 22:39:51 +01:00
goto Exit;
metrics->script_class = script_class;
metrics->globals = globals;
2003-11-23 22:39:51 +01:00
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
if ( writing_system_class->script_metrics_init )
2003-11-23 22:39:51 +01:00
{
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
error = writing_system_class->script_metrics_init( metrics,
globals->face );
2003-11-23 22:39:51 +01:00
if ( error )
{
[autofit] Introduce `writing systems'. This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
2013-07-31 22:49:29 +02:00
if ( writing_system_class->script_metrics_done )
writing_system_class->script_metrics_done( metrics );
2003-11-23 22:39:51 +01:00
FT_FREE( metrics );
goto Exit;
}
}
globals->metrics[script_class->script] = metrics;
2003-11-23 22:39:51 +01:00
}
Exit:
*ametrics = metrics;
2003-11-23 22:39:51 +01:00
return error;
}
FT_LOCAL_DEF( FT_Bool )
af_face_globals_is_digit( AF_FaceGlobals globals,
FT_UInt gindex )
{
if ( gindex < (FT_ULong)globals->glyph_count )
return (FT_Bool)( globals->glyph_scripts[gindex] & AF_DIGIT );
return (FT_Bool)0;
}
/* END */