[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
diff --git a/ChangeLog b/ChangeLog
index 28008f1..4b4071b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
2013-08-02 Werner Lemberg <wl@gnu.org>
+ [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 <wl@gnu.org>
+
[sfnt] Fix compilation with g++.
* src/sfnt/pngshim.c (error_callback, read_data_from_FT_stream): Use
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 4e9138a..ad6c9ba 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -17,11 +17,11 @@
#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"
@@ -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 */
};
diff --git a/src/autofit/afpic.c b/src/autofit/afpic.c
index f19dfd2..3b993b1 100644
--- a/src/autofit/afpic.c
+++ b/src/autofit/afpic.c
@@ -43,13 +43,10 @@
/* 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
@@ -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(
diff --git a/src/autofit/afpic.h b/src/autofit/afpic.h
index 22b0abe..36ff9ad 100644
--- a/src/autofit/afpic.h
+++ b/src/autofit/afpic.h
@@ -41,20 +41,14 @@ FT_BEGIN_HEADER
#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_BEGIN_HEADER
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];
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index 85f0feb..3599f84 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -273,24 +273,23 @@ extern void* _af_debug_hints;
* 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_
{
diff --git a/src/autofit/afwrtsys.h b/src/autofit/afwrtsys.h
new file mode 100644
index 0000000..602c558
--- /dev/null
+++ b/src/autofit/afwrtsys.h
@@ -0,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 */