[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.
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
diff --git a/ChangeLog b/ChangeLog
index 4b4071b..c88ec45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,30 @@
2013-08-02 Werner Lemberg <wl@gnu.org>
+ [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 <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
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index ad6c9ba..f8ea150 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 8077afd..e2f3e84 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 3b993b1..56cb077 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 36ff9ad..09f8258 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 0000000..e3170ae
--- /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 3599f84..b47aa4e 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 b76bb79..c8b733d 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)