[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] ewaldhew-wip a3edd07 38/47: add type 1 hinting engine switch
From: |
Hew Yih Shiuan Ewald |
Subject: |
[freetype2] ewaldhew-wip a3edd07 38/47: add type 1 hinting engine switch |
Date: |
Thu, 6 Jul 2017 04:49:38 -0400 (EDT) |
branch: ewaldhew-wip
commit a3edd071047399d69a0767c76a812d1a101f4471
Author: Ewald Hew <address@hidden>
Commit: Ewald Hew <address@hidden>
add type 1 hinting engine switch
---
devel/ftoption.h | 10 ++++
include/freetype/config/ftheader.h | 13 +++++
include/freetype/config/ftoption.h | 10 ++++
include/freetype/ftt1drv.h | 116 +++++++++++++++++++++++++++++++++++++
src/type1/t1driver.c | 2 +-
src/type1/t1objs.c | 38 +++++++++++-
6 files changed, 186 insertions(+), 3 deletions(-)
diff --git a/devel/ftoption.h b/devel/ftoption.h
index a690ea2..1dd36a2 100644
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -790,6 +790,16 @@ FT_BEGIN_HEADER
/*************************************************************************/
+ /* */
+ /* T1_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe Type 1 */
+ /* engine gets compiled into FreeType. If defined, it is possible to */
+ /* switch between the two engines using the `hinting-engine' property of */
+ /* the type1 driver module. */
+ /* */
+#define T1_CONFIG_OPTION_OLD_ENGINE
+
+
+ /*************************************************************************/
/*************************************************************************/
/**** ****/
/**** C F F D R I V E R C O N F I G U R A T I O N ****/
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/config/ftoption.h
b/include/freetype/config/ftoption.h
index 935e20d..3ff149e 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -799,6 +799,16 @@ FT_BEGIN_HEADER
/*************************************************************************/
+ /* */
+ /* T1_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe Type 1 */
+ /* engine gets compiled into FreeType. If defined, it is possible to */
+ /* switch between the two engines using the `hinting-engine' property of */
+ /* the type1 driver module. */
+ /* */
+/* #define T1_CONFIG_OPTION_OLD_ENGINE */
+
+
+ /*************************************************************************/
/*************************************************************************/
/**** ****/
/**** C F F D R I V E R C O N F I G U R A T I O N ****/
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..1f1f409 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 ( CFF_DriverRec ),
"type1",
0x10000L,
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 5ac1292..7804367 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,42 @@
/* 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 );
+ CFF_Driver driver = (CFF_Driver)module;
+
+ FT_UInt32 seed;
+
+
+ /* set default property values, cf. `ftcffdrv.h' */
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+ driver->hinting_engine = FT_T1_HINTING_FREETYPE;
+#else
+ driver->hinting_engine = FT_T1_HINTING_ADOBE;
+#endif
+
+ 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;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] ewaldhew-wip a3edd07 38/47: add type 1 hinting engine switch,
Hew Yih Shiuan Ewald <=