Found the time to do a new revision :)
It comes with FT_Face_Option(...) and puts the stem darkening flag into
the internal structure of FT_Face.
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index a81eb72..a9659a2 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -3566,6 +3566,22 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Function> */
+ /* FT_Face_Option */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Face_Option( FT_Face face,
+ FT_UInt num_params,
+ FT_Parameter* parameters);
+
+#define FT_PARAM_TAG_ENABLE_STEM_DARKENING FT_MAKE_TAG( 'd', 'a', 'r', 'k' )
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
/* FT_Get_Name_Index */
/* */
/* <Description> */
diff --git a/include/freetype/ftmodapi.h b/include/freetype/ftmodapi.h
index b4d2758..dce17b8 100644
--- a/include/freetype/ftmodapi.h
+++ b/include/freetype/ftmodapi.h
@@ -119,6 +119,8 @@ FT_BEGIN_HEADER
/* own hinter */
#define FT_MODULE_DRIVER_HINTS_LIGHTLY 0x800 /* the driver's hinter */
/* produces LIGHT hints */
+#define FT_MODULE_DRIVER_DARKENS_STEMS 0x1000 /* the driver can darken */
+ /* stems. */
/* deprecated values */
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 0eb8eaa..2f0bad7 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -362,6 +362,8 @@ FT_BEGIN_HEADER
FT_Int refcount;
+ FT_Bool no_stem_darkening;
+
} FT_Face_InternalRec;
@@ -503,6 +505,9 @@ FT_BEGIN_HEADER
#define FT_DRIVER_HINTS_LIGHTLY( x ) ( FT_MODULE_CLASS( x )->module_flags & \
FT_MODULE_DRIVER_HINTS_LIGHTLY )
+#define FT_DRIVER_DARKENS_STEMS( x ) ( FT_MODULE_CLASS( x )->module_flags & \
+ FT_MODULE_DRIVER_DARKENS_STEMS )
+
/*************************************************************************/
/* */
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index 26bba06..d7ad0db 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -98,8 +98,6 @@
FT_UInt glyph_index,
FT_Int32 load_flags )
{
- AF_Module module = loader->globals->module;
-
FT_Error error;
FT_Face face = loader->face;
AF_StyleMetrics metrics = loader->metrics;
@@ -135,7 +133,7 @@
* must therefore be recomputed for each size and
* `standard_{vertical,horizontal}_width' change.
*/
- if ( !module->no_stem_darkening )
+ if ( !face->internal->no_stem_darkening )
{
AF_FaceGlobals globals = loader->globals;
AF_WritingSystemClass writing_system_class;
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 9006b59..b5d91f5 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -627,8 +627,21 @@
library = driver->root.library;
hinter = library->auto_hinter;
- /* resolve load flags dependencies */
+ /* If the face has the stem darkening property set, we currently need to
+ * force the autohinter unless we're dealing with CFFs, since stem
+ * darkening is currently only implemented in the CFF driver (with and
+ * without hinting) and the autohinter. */
+ if ( !face->internal->no_stem_darkening &&
+ !( load_flags & FT_RENDER_MODE_LIGHT ) )
+ {
+ load_flags &= ~FT_LOAD_TARGET_MODE( load_flags );
+ load_flags |= FT_LOAD_TARGET_LIGHT;
+
+ if ( !FT_DRIVER_DARKENS_STEMS( driver ) )
+ autohint = TRUE;
+ }
+ /* resolve load flags dependencies */
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE |
FT_LOAD_IGNORE_TRANSFORM;
@@ -2349,8 +2362,11 @@
internal->transform_delta.y = 0;
internal->refcount = 1;
+
+ internal->no_stem_darkening = TRUE;
}
+
if ( aface )
*aface = face;
else
@@ -3501,6 +3517,41 @@
}
+ FT_EXPORT_DEF( FT_Error )
+ FT_Face_Option( FT_Face face,
+ FT_UInt num_params,
+ FT_Parameter* parameters)
+ {
+ FT_Error error = FT_Err_Ok;
+
+
+ if ( num_params > 0 && !parameters )
+ {
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
+ for ( ; num_params > 0; num_params-- )
+ {
+ if ( parameters->tag == FT_PARAM_TAG_ENABLE_STEM_DARKENING )
+ {
+ if ( parameters->data == 0)
+ face->internal->no_stem_darkening = 1;
+ else
+ face->internal->no_stem_darkening = 0;
+ }
+
+ if ( error )
+ break;
+
+ parameters++;
+ }
+
+Exit:
+ return error;
+ }
+
+
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt )
@@ -4145,7 +4196,7 @@
parameters++;
}
- Exit:
+ Exit:
return error;
}
diff --git a/src/cff/cf2ft.c b/src/cff/cf2ft.c
index edbe6a7..5569b6a 100644
--- a/src/cff/cf2ft.c
+++ b/src/cff/cf2ft.c
@@ -369,7 +369,7 @@
font->renderingFlags = 0;
if ( hinted )
font->renderingFlags |= CF2_FlagsHinted;
- if ( scaled && !driver->no_stem_darkening )
+ if ( scaled && !(builder->face->root.internal->no_stem_darkening) )
font->renderingFlags |= CF2_FlagsDarkened;
font->darkenParams[0] = driver->darken_params[0];
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 1d8d12e..f2127f5 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -955,7 +955,8 @@
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER |
- FT_MODULE_DRIVER_HINTS_LIGHTLY,
+ FT_MODULE_DRIVER_HINTS_LIGHTLY |
+ FT_MODULE_DRIVER_DARKENS_STEMS,
sizeof ( CFF_DriverRec ),
"cff",
_______________________________________________
Freetype-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype-devel