ref: 773601da120d49c2e95066fcc2ad41d16cf45429
parent: 74a9b670e9020b1fdd01102dcccd4d6891f2e536
author: Werner Lemberg <[email protected]>
date: Fri Aug 2 15:51:17 EDT 2013
[autofit] Move declaration of writing systems into separate file. This has the benefit that we don't need to duplicate the data at different places. * src/autofit/afwrtsys.h: New file. * src/autofit/aftypes.h (AF_WritingSystem): Include `afwrtsys.h' to define the enumeration values. * src/autofit/afglobal.c: Include `afwrtsys.h' to get the writing system specific header files. Include `afpic.h'. (af_writing_system_classes): Include `afwrtsys.h' to fill this array. * src/autofit/afpic.c: Include `afwrtsys.h' to get the writing system specific header files. (autofit_module_class_pic_init): Include `afwrtsys.h' for initialization. * src/autofit/afpic.h (AF_WRITING_SYSTEM_CLASSES_COUNT, AF_WRITING_SYSTEM_CLASSES_REC_COUNT): Removed. Use `AF_WRITING_SYSTEM_MAX' instead.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
2013-08-02 Werner Lemberg <[email protected]>
+ [autofit] Move declaration of writing systems into separate file.
+
+ This has the benefit that we don't need to duplicate the data at
+ different places.
+
+ * src/autofit/afwrtsys.h: New file.
+
+ * src/autofit/aftypes.h (AF_WritingSystem): Include `afwrtsys.h' to
+ define the enumeration values.
+
+ * src/autofit/afglobal.c: Include `afwrtsys.h' to get the writing
+ system specific header files.
+ Include `afpic.h'.
+ (af_writing_system_classes): Include `afwrtsys.h' to fill this
+ array.
+
+ * src/autofit/afpic.c: Include `afwrtsys.h' to get the writing
+ system specific header files.
+ (autofit_module_class_pic_init): Include `afwrtsys.h' for
+ initialization.
+ * src/autofit/afpic.h (AF_WRITING_SYSTEM_CLASSES_COUNT,
+ AF_WRITING_SYSTEM_CLASSES_REC_COUNT): Removed. Use
+ `AF_WRITING_SYSTEM_MAX' instead.
+
+2013-08-02 Werner Lemberg <[email protected]>
+
[sfnt] Fix compilation with g++.
* src/sfnt/pngshim.c (error_callback, read_data_from_FT_stream): Use
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -17,12 +17,12 @@
#include "afglobal.h"
-#include "afdummy.h"
-#include "aflatin.h"
-#include "afcjk.h"
-#include "afindic.h"
-#include "afpic.h"
+ /* get writing system specific header files */
+#undef WRITING_SYSTEM
+#define WRITING_SYSTEM( ws, WS ) /* empty */
+#include "afwrtsys.h"
+
#include "aferrors.h"
#ifdef FT_OPTION_AUTOFIT2
@@ -29,22 +29,23 @@
#include "aflatin2.h"
#endif
+#include "afpic.h"
+
#ifndef FT_CONFIG_OPTION_PIC
/* 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 */
+#undef WRITING_SYSTEM
+#define WRITING_SYSTEM( ws, WS ) \
+ &af_ ## ws ## _writing_system_class,
+
FT_LOCAL_ARRAY_DEF( AF_WritingSystemClass )
af_writing_system_classes[] =
{
- &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
+
+#include "afwrtsys.h"
+
NULL /* do not remove */
};
--- a/src/autofit/afpic.c
+++ b/src/autofit/afpic.c
@@ -43,15 +43,12 @@
/* forward declaration of PIC init functions from script classes */
-#include "aflatin.h"
-#ifdef FT_OPTION_AUTOFIT2
-#include "aflatin2.h"
-#endif
-#include "afcjk.h"
-#include "afdummy.h"
-#include "afindic.h"
+#undef WRITING_SYSTEM
+#define WRITING_SYSTEM( ws, WS ) /* empty */
+#include "afwrtsys.h"
+
void
autofit_module_class_pic_free( FT_Library library )
{
@@ -100,11 +97,11 @@
FT_Init_Class_af_service_properties( &container->af_service_properties );
- for ( ss = 0; ss < AF_WRITING_SYSTEM_CLASSES_REC_COUNT; ss++ )
+ 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_CLASSES_COUNT - 1] = NULL;
+ [AF_WRITING_SYSTEM_MAX - 1] = NULL;
for ( ss = 0; ss < AF_SCRIPT_CLASSES_REC_COUNT; ss++ )
container->af_script_classes[ss] =
@@ -112,21 +109,14 @@
container->af_script_classes
[AF_SCRIPT_CLASSES_COUNT - 1] = NULL;
- /* add call to initialization function when you add new scripts */
- /* or writing systems */
+#undef WRITING_SYSTEM
+#define WRITING_SYSTEM( ws, WS ) \
+ FT_Init_Class_af_ ## ws ## _writing_system_class( \
+ &container->af_writing_system_classes_rec[ss++] );
+
ss = 0;
- FT_Init_Class_af_dummy_writing_system_class(
- &container->af_writing_system_classes_rec[ss++] );
- FT_Init_Class_af_latin_writing_system_class(
- &container->af_writing_system_classes_rec[ss++] );
- FT_Init_Class_af_cjk_writing_system_class(
- &container->af_writing_system_classes_rec[ss++] );
- FT_Init_Class_af_indic_writing_system_class(
- &container->af_writing_system_classes_rec[ss++] );
-#ifdef FT_OPTION_AUTOFIT2
- FT_Init_Class_af_latin2_writing_system_class(
- &container->af_writing_system_classes_rec[ss++] );
-#endif
+
+#include "afwrtsys.h"
ss = 0;
FT_Init_Class_af_dflt_script_class(
--- a/src/autofit/afpic.h
+++ b/src/autofit/afpic.h
@@ -41,20 +41,14 @@
#include "aftypes.h"
- /* increase these when you add new scripts or writing systems, */
- /* and update autofit_module_class_pic_init */
#ifdef FT_OPTION_AUTOFIT2
-#define AF_WRITING_SYSTEM_CLASSES_COUNT 6
#define AF_SCRIPT_CLASSES_COUNT 6
#else
-#define AF_WRITING_SYSTEM_CLASSES_COUNT 5
#define AF_SCRIPT_CLASSES_COUNT 5
#endif
#define AF_SCRIPT_CLASSES_REC_COUNT \
( AF_SCRIPT_CLASSES_COUNT - 1 )
-#define AF_WRITING_SYSTEM_CLASSES_REC_COUNT \
- ( AF_WRITING_SYSTEM_CLASSES_COUNT - 1 )
typedef struct AFModulePIC_
@@ -63,9 +57,9 @@
FT_Service_PropertiesRec af_service_properties;
AF_WritingSystemClass af_writing_system_classes
- [AF_WRITING_SYSTEM_CLASSES_COUNT];
+ [AF_WRITING_SYSTEM_MAX];
AF_WritingSystemClassRec af_writing_system_classes_rec
- [AF_WRITING_SYSTEM_CLASSES_REC_COUNT];
+ [AF_WRITING_SYSTEM_MAX - 1];
AF_ScriptClass af_script_classes
[AF_SCRIPT_CLASSES_COUNT];
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -273,23 +273,22 @@
* outline according to the results of the glyph analyzer.
*/
+#define __AFWRTSYS_H__ /* don't load header files */
+#undef WRITING_SYSTEM
+#define WRITING_SYSTEM( ws, WS ) \
+ AF_WRITING_SYSTEM_ ## WS,
+
/* The list of known writing systems. */
typedef enum AF_WritingSystem_
{
- AF_WRITING_SYSTEM_DUMMY = 0,
- AF_WRITING_SYSTEM_LATIN = 1,
- AF_WRITING_SYSTEM_CJK = 2,
- AF_WRITING_SYSTEM_INDIC = 3,
-#ifdef FT_OPTION_AUTOFIT2
- AF_WRITING_SYSTEM_LATIN2 = 4,
-#endif
- /* Add new writing systems here. Don't forget to update */
- /* the list in `afglobal.c'. */
+#include "afwrtsys.h"
AF_WRITING_SYSTEM_MAX /* do not remove */
} AF_WritingSystem;
+
+#undef __AFWRTSYS_H__
typedef struct AF_WritingSystemClassRec_
--- /dev/null
+++ b/src/autofit/afwrtsys.h
@@ -1,0 +1,51 @@
+/***************************************************************************/
+/* */
+/* afwrtsys.h */
+/* */
+/* Auto-fitter writing systems (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. */
+/* */
+/***************************************************************************/
+
+
+#ifndef __AFWRTSYS_H__
+#define __AFWRTSYS_H__
+
+ /* Since preprocessor directives can't create other preprocessor */
+ /* directives, we have to include the header files manually. */
+
+#include "afdummy.h"
+#include "aflatin.h"
+#include "afcjk.h"
+#include "afindic.h"
+#ifdef FT_OPTION_AUTOFIT2
+#include "aflatin2.h"
+#endif
+
+#endif /* __AFWRTSYS_H__ */
+
+
+ /* The following part can be included multiple times. */
+ /* Define `WRITING_SYSTEM' as needed. */
+
+
+ /* Add new writing systems here. */
+
+ WRITING_SYSTEM( dummy, DUMMY )
+ WRITING_SYSTEM( latin, LATIN )
+ WRITING_SYSTEM( cjk, CJK )
+ WRITING_SYSTEM( indic, INDIC )
+#ifdef FT_OPTION_AUTOFIT2
+ WRITING_SYSTEM( latin2, LATIN2 )
+#endif
+
+
+/* END */