From 456cc440cadead759578c7e71aa04d74b387a066 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 2 Aug 2013 20:25:21 +0200 Subject: [PATCH] [autofit] Move declaration of scripts into separate file. This has the benefit that we don't need to duplicate the data at different places. * src/autofit/afscript.h: New file. * src/autofit/aftypes.h (AF_Script): Include `afscript.h' to define the enumeration values. * src/autofit/afglobal.c: Include `afscript.h' to get the script specific header files. (af_script_classes): Include `afscript.h' to fill this array. * src/autofit/afpic.c: Include `afscript.h' to get the script specific header files. (autofit_module_class_pic_init): Include `afscript.h' for initialization. * src/autofit/afpic.h (AF_SCRIPT_CLASSES_COUNT, AF_SCRIPT_CLASSES_REC_COUNT): Removed. Use `AF_SCRIPT_MAX' instead. * src/autofit/rules.mk (AUTOF_DRV_H): Updated. --- ChangeLog | 25 +++++++++++++++++++++++++ src/autofit/afglobal.c | 16 ++++++---------- src/autofit/afglobal.h | 4 ++-- src/autofit/afpic.c | 27 +++++++++------------------ src/autofit/afpic.h | 13 ++----------- src/autofit/afscript.h | 34 ++++++++++++++++++++++++++++++++++ src/autofit/aftypes.h | 14 +++++--------- src/autofit/rules.mk | 6 ++++-- 8 files changed, 87 insertions(+), 52 deletions(-) create mode 100644 src/autofit/afscript.h diff --git a/ChangeLog b/ChangeLog index 4b4071b85..c88ec457d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2013-08-02 Werner Lemberg + + [autofit] Move declaration of scripts into separate file. + + This has the benefit that we don't need to duplicate the data at + different places. + + * src/autofit/afscript.h: New file. + + * src/autofit/aftypes.h (AF_Script): Include `afscript.h' to define + the enumeration values. + + * src/autofit/afglobal.c: Include `afscript.h' to get the script + specific header files. + (af_script_classes): Include `afscript.h' to fill this array. + + * src/autofit/afpic.c: Include `afscript.h' to get the script + specific header files. + (autofit_module_class_pic_init): Include `afscript.h' for + initialization. + * src/autofit/afpic.h (AF_SCRIPT_CLASSES_COUNT, + AF_SCRIPT_CLASSES_REC_COUNT): Removed. Use `AF_SCRIPT_MAX' instead. + + * src/autofit/rules.mk (AUTOF_DRV_H): Updated. + 2013-08-02 Werner Lemberg [autofit] Move declaration of writing systems into separate file. diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c index ad6c9ba18..f8ea1509c 100644 --- a/src/autofit/afglobal.c +++ b/src/autofit/afglobal.c @@ -50,20 +50,16 @@ }; - /* when updating this table, don't forget to update */ - /* AF_SCRIPT_CLASSES_COUNT and autofit_module_class_pic_init */ +#undef SCRIPT +#define SCRIPT( s, S ) \ + &af_ ## s ## _script_class, - /* populate this list when you add new scripts */ FT_LOCAL_ARRAY_DEF( AF_ScriptClass ) af_script_classes[] = { - &af_dflt_script_class, /* XXX */ - &af_latn_script_class, - &af_hani_script_class, - &af_deva_script_class, -#ifdef FT_OPTION_AUTOFIT2 - &af_ltn2_script_class, -#endif + +#include "afscript.h" + NULL /* do not remove */ }; diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h index 8077afda0..e2f3e8435 100644 --- a/src/autofit/afglobal.h +++ b/src/autofit/afglobal.h @@ -42,9 +42,9 @@ FT_BEGIN_HEADER /* index of fallback script in `af_script_classes' */ #ifdef AF_CONFIG_OPTION_CJK -#define AF_SCRIPT_FALLBACK 2 /* hani */ +#define AF_SCRIPT_FALLBACK AF_SCRIPT_HANI #else -#define AF_SCRIPT_FALLBACK 0 /* dflt */ +#define AF_SCRIPT_FALLBACK AF_SCRIPT_DFLT #endif /* a bit mask indicating an uncovered glyph */ #define AF_SCRIPT_NONE 0x7F diff --git a/src/autofit/afpic.c b/src/autofit/afpic.c index 3b993b1fe..56cb07738 100644 --- a/src/autofit/afpic.c +++ b/src/autofit/afpic.c @@ -100,14 +100,12 @@ for ( ss = 0; ss < AF_WRITING_SYSTEM_MAX - 1; ss++ ) container->af_writing_system_classes[ss] = &container->af_writing_system_classes_rec[ss]; - container->af_writing_system_classes - [AF_WRITING_SYSTEM_MAX - 1] = NULL; + container->af_writing_system_classes[AF_WRITING_SYSTEM_MAX - 1] = NULL; - for ( ss = 0; ss < AF_SCRIPT_CLASSES_REC_COUNT; ss++ ) + for ( ss = 0; ss < AF_SCRIPT_MAX - 1; ss++ ) container->af_script_classes[ss] = &container->af_script_classes_rec[ss]; - container->af_script_classes - [AF_SCRIPT_CLASSES_COUNT - 1] = NULL; + container->af_script_classes[AF_SCRIPT_MAX - 1] = NULL; #undef WRITING_SYSTEM #define WRITING_SYSTEM( ws, WS ) \ @@ -115,22 +113,15 @@ &container->af_writing_system_classes_rec[ss++] ); ss = 0; - #include "afwrtsys.h" +#undef SCRIPT +#define SCRIPT( s, S ) \ + FT_Init_Class_af_ ## s ## _script_class( \ + &container->af_script_classes_rec[ss++] ); + ss = 0; - FT_Init_Class_af_dflt_script_class( - &container->af_script_classes_rec[ss++] ); - FT_Init_Class_af_latn_script_class( - &container->af_script_classes_rec[ss++] ); - FT_Init_Class_af_hani_script_class( - &container->af_script_classes_rec[ss++] ); - FT_Init_Class_af_deva_script_class( - &container->af_script_classes_rec[ss++] ); -#ifdef FT_OPTION_AUTOFIT2 - FT_Init_Class_af_ltn2_script_class( - &container->af_script_classes_rec[ss++] ); -#endif +#include "afscript.h" FT_Init_Class_af_autofitter_interface( library, &container->af_autofitter_interface ); diff --git a/src/autofit/afpic.h b/src/autofit/afpic.h index 36ff9ad19..09f8258a2 100644 --- a/src/autofit/afpic.h +++ b/src/autofit/afpic.h @@ -41,15 +41,6 @@ FT_BEGIN_HEADER #include "aftypes.h" -#ifdef FT_OPTION_AUTOFIT2 -#define AF_SCRIPT_CLASSES_COUNT 6 -#else -#define AF_SCRIPT_CLASSES_COUNT 5 -#endif - -#define AF_SCRIPT_CLASSES_REC_COUNT \ - ( AF_SCRIPT_CLASSES_COUNT - 1 ) - typedef struct AFModulePIC_ { @@ -62,9 +53,9 @@ FT_BEGIN_HEADER [AF_WRITING_SYSTEM_MAX - 1]; AF_ScriptClass af_script_classes - [AF_SCRIPT_CLASSES_COUNT]; + [AF_SCRIPT_MAX]; AF_ScriptClassRec af_script_classes_rec - [AF_SCRIPT_CLASSES_REC_COUNT]; + [AF_SCRIPT_MAX - 1]; FT_AutoHinter_InterfaceRec af_autofitter_interface; diff --git a/src/autofit/afscript.h b/src/autofit/afscript.h new file mode 100644 index 000000000..e3170ae32 --- /dev/null +++ b/src/autofit/afscript.h @@ -0,0 +1,34 @@ +/***************************************************************************/ +/* */ +/* afscript.h */ +/* */ +/* Auto-fitter scripts (specification only). */ +/* */ +/* Copyright 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. */ +/* */ +/***************************************************************************/ + + + /* The following part can be included multiple times. */ + /* Define `SCRIPT' as needed. */ + + + /* Add new scripts here. */ + + SCRIPT( dflt, DFLT ) + SCRIPT( latn, LATN ) + SCRIPT( hani, HANI ) + SCRIPT( deva, DEVA ) +#ifdef FT_OPTION_AUTOFIT2 + SCRIPT( ltn2, LTN2 ) +#endif + + +/* END */ diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h index 3599f843a..b47aa4ecd 100644 --- a/src/autofit/aftypes.h +++ b/src/autofit/aftypes.h @@ -322,19 +322,15 @@ extern void* _af_debug_hints; * We use four-letter script tags from the OpenType specification. */ +#undef SCRIPT +#define SCRIPT(s, S ) \ + AF_SCRIPT_ ## S, + /* The list of known scripts. */ typedef enum AF_Script_ { - AF_SCRIPT_DFLT = 0, - AF_SCRIPT_LATN = 1, - AF_SCRIPT_HANI = 2, - AF_SCRIPT_DEVA = 3, -#ifdef FT_OPTION_AUTOFIT2 - AF_SCRIPT_LTN2 = 4, -#endif - /* Add new scripts here. Don't forget to update */ - /* the list in `afglobal.c'. */ +#include "afscript.h" AF_SCRIPT_MAX /* do not remove */ diff --git a/src/autofit/rules.mk b/src/autofit/rules.mk index b76bb79ab..c8b733d6c 100644 --- a/src/autofit/rules.mk +++ b/src/autofit/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2003, 2004, 2005, 2006, 2007, 2011 by +# Copyright 2003-2007, 2011, 2013 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -41,7 +41,9 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \ # AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h) \ $(AUTOF_DIR)/aferrors.h \ - $(AUTOF_DIR)/aftypes.h + $(AUTOF_DIR)/afscript.h \ + $(AUTOF_DIR)/aftypes.h \ + $(AUTOF_DIR)/afwrtsys.h # AUTOF driver object(s)