Commit a5c02f49b567d9a32da2a6cc072eedad156519d3

Ewald Hew 2017-09-25T08:11:32

Add Adobe engine configuration. This is similar to what was done in the `type1' module. * src/cid/cidriver.c (t1cid_driver_class): Update declaration. * src/cid/cidobjs.c: Include FT_TYPE1_DRIVER_H. (cid_driver_init): Update code.

diff --git a/ChangeLog b/ChangeLog
index 09cd993..668161d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2017-09-25  Ewald Hew  <ewaldhew@gmail.com>
 
+	[cid] Add Adobe engine configuration.
+
+	This is similar to what was done in the `type1' module.
+
+	* src/cid/cidriver.c (t1cid_driver_class): Update declaration.
+	* src/cid/cidobjs.c: Include FT_TYPE1_DRIVER_H.
+	(cid_driver_init): Update code.
+
+2017-09-25  Ewald Hew  <ewaldhew@gmail.com>
+
 	[psaux] Change subfont synthesis for CID fonts.
 
 	Change `t1_make_subfont' to take in the Private dict record as an
diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c
index ceda8ff..52c6438 100644
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -26,6 +26,7 @@
 #include FT_SERVICE_POSTSCRIPT_CMAPS_H
 #include FT_INTERNAL_POSTSCRIPT_AUX_H
 #include FT_INTERNAL_POSTSCRIPT_HINTS_H
+#include FT_TYPE1_DRIVER_H
 
 #include "ciderrs.h"
 
@@ -463,9 +464,38 @@
   /*    FreeType error code.  0 means success.                             */
   /*                                                                       */
   FT_LOCAL_DEF( FT_Error )
-  cid_driver_init( FT_Module  driver )
+  cid_driver_init( FT_Module  module )
   {
-    FT_UNUSED( driver );
+    PS_Driver  driver = (PS_Driver)module;
+
+    FT_UInt32  seed;
+
+
+    /* set default property values, cf. `ftcffdrv.h' */
+    driver->hinting_engine = FT_T1_HINTING_ADOBE;
+
+    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;
   }
diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c
index bb611a9..c7d42f9 100644
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -200,7 +200,7 @@
       FT_MODULE_FONT_DRIVER       |
       FT_MODULE_DRIVER_SCALABLE   |
       FT_MODULE_DRIVER_HAS_HINTER,
-      sizeof ( FT_DriverRec ),
+      sizeof ( PS_DriverRec ),
 
       "t1cid",   /* module name           */
       0x10000L,  /* version 1.0 of driver */