Add Adobe engine configuration. Use the previously changed PS_Driver in type1 module to store hinting engine configuration. * include/freetype/ftt1drv.h: New file. Duplicate and rename config options from CFF. * include/freetype/config/ftheader.h (FT_TYPE1_DRIVER_H): New macro. * src/type1/t1driver.c (t1_driver_class): Update declaration. * src/type1/t1objs.c: Include FT_TYPE1_DRIVER_H. (T1_Driver_Init): Update code.
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
diff --git a/ChangeLog b/ChangeLog
index d6d0be1..bfe2237 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2017-09-25 Ewald Hew <ewaldhew@gmail.com>
+ [type1] Add Adobe engine configuration.
+
+ Use the previously changed PS_Driver in type1 module to store
+ hinting engine configuration.
+
+ * include/freetype/ftt1drv.h: New file.
+ Duplicate and rename config options from CFF.
+ * include/freetype/config/ftheader.h (FT_TYPE1_DRIVER_H): New macro.
+
+ * src/type1/t1driver.c (t1_driver_class): Update declaration.
+ * src/type1/t1objs.c: Include FT_TYPE1_DRIVER_H.
+ (T1_Driver_Init): Update code.
+
+2017-09-25 Ewald Hew <ewaldhew@gmail.com>
+
[cff] Move and rename `CFF_Driver'.
This is so that we can use the same hinting engine parameters for
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index d491af5..ce3b7ee 100644
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -370,6 +370,19 @@
/*************************************************************************
*
* @macro:
+ * FT_TYPE1_DRIVER_H
+ *
+ * @description:
+ * A macro used in #include statements to name the file containing
+ * structures and macros related to the Type~1 driver module.
+ *
+ */
+#define FT_TYPE1_DRIVER_H <freetype/ftt1drv.h>
+
+
+ /*************************************************************************
+ *
+ * @macro:
* FT_TYPE1_TABLES_H
*
* @description:
diff --git a/include/freetype/ftt1drv.h b/include/freetype/ftt1drv.h
new file mode 100644
index 0000000..116b33b
--- /dev/null
+++ b/include/freetype/ftt1drv.h
@@ -0,0 +1,116 @@
+/***************************************************************************/
+/* */
+/* ftt1drv.h */
+/* */
+/* FreeType API for controlling the Type 1 driver (specification only). */
+/* */
+/* Copyright 2013-2017 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 FTT1DRV_H_
+#define FTT1DRV_H_
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+#ifdef FREETYPE_H
+#error "freetype.h of FreeType 1 has been loaded!"
+#error "Please fix the directory search order for header files"
+#error "so that freetype.h of FreeType 2 is found first."
+#endif
+
+
+FT_BEGIN_HEADER
+
+
+
+ /**************************************************************************
+ *
+ * @property:
+ * hinting-engine[type1]
+ *
+ * @description:
+ * Thanks to Adobe, which contributed a new hinting (and parsing)
+ * engine, an application can select between `freetype' and `adobe' if
+ * compiled with T1_CONFIG_OPTION_OLD_ENGINE. If this configuration
+ * macro isn't defined, `hinting-engine' does nothing.
+ *
+ * The default engine is `freetype' if T1_CONFIG_OPTION_OLD_ENGINE is
+ * defined, and `adobe' otherwise.
+ *
+ * The following example code demonstrates how to select Adobe's hinting
+ * engine (omitting the error handling).
+ *
+ * {
+ * FT_Library library;
+ * FT_UInt hinting_engine = FT_T1_HINTING_ADOBE;
+ *
+ *
+ * FT_Init_FreeType( &library );
+ *
+ * FT_Property_Set( library, "type1",
+ * "hinting-engine", &hinting_engine );
+ * }
+ *
+ * @note:
+ * This property can be used with @FT_Property_Get also.
+ *
+ * This property can be set via the `FREETYPE_PROPERTIES' environment
+ * variable (using values `adobe' or `freetype').
+ */
+
+
+ /**************************************************************************
+ *
+ * @enum:
+ * FT_T1_HINTING_XXX
+ *
+ * @description:
+ * A list of constants used for the @hinting-engine[type1] property to
+ * select the hinting engine for Type 1 fonts.
+ *
+ * @values:
+ * FT_T1_HINTING_FREETYPE ::
+ * Use the old FreeType hinting engine.
+ *
+ * FT_T1_HINTING_ADOBE ::
+ * Use the hinting engine contributed by Adobe.
+ *
+ */
+#define FT_T1_HINTING_FREETYPE 0
+#define FT_T1_HINTING_ADOBE 1
+
+ /**************************************************************************
+ *
+ * @constant:
+ * FT_PARAM_TAG_RANDOM_SEED
+ *
+ * @description:
+ * An @FT_Parameter tag to be used with @FT_Face_Properties. The
+ * corresponding 32bit signed integer argument overrides the CFF
+ * module's random seed value with a face-specific one; see
+ * @random-seed.
+ *
+ */
+#define FT_PARAM_TAG_RANDOM_SEED \
+ FT_MAKE_TAG( 's', 'e', 'e', 'd' )
+
+ /* */
+
+
+FT_END_HEADER
+
+
+#endif /* FTT1DRV_H_ */
+
+
+/* END */
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index c208994..866a824 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -713,7 +713,7 @@
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
- sizeof ( FT_DriverRec ),
+ sizeof ( PS_DriverRec ),
"type1",
0x10000L,
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 5ac1292..dab556f 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -21,6 +21,7 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_IDS_H
+#include FT_TYPE1_DRIVER_H
#include "t1gload.h"
#include "t1load.h"
@@ -578,9 +579,38 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
- T1_Driver_Init( FT_Module driver )
+ T1_Driver_Init( FT_Module module )
{
- FT_UNUSED( driver );
+ PS_Driver driver = (PS_Driver)module;
+
+ FT_UInt32 seed;
+
+
+ /* set default property values, cf. `ftt1drv.h' */
+ driver->hinting_engine = FT_T1_HINTING_FREETYPE;
+
+ driver->no_stem_darkening = TRUE;
+
+ driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
+ driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
+ driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
+ driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
+ driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
+ driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
+ driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
+ driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
+
+ /* compute random seed from some memory addresses */
+ seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
+ (FT_Offset)(char*)&module ^
+ (FT_Offset)(char*)module->memory );
+ seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
+
+ driver->random_seed = (FT_Int32)seed;
+ if ( driver->random_seed < 0 )
+ driver->random_seed = -driver->random_seed;
+ else if ( driver->random_seed == 0 )
+ driver->random_seed = 123456789;
return FT_Err_Ok;
}