[cff] Introduce `random-seed' property (1/2).

We need this for support of the `random' operator.

* include/freetype/ftcffdrv.h (FT_PARAM_TAG_RANDOM_SEED): New macro.

* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): New
field `random_seed'.

* src/cff/cffobjs.h (CFF_DriverRec): New field `random_seed'.
This commit is contained in:
Werner Lemberg 2017-02-20 08:55:26 +01:00
parent d22f5ec563
commit ca1486c32a
5 changed files with 80 additions and 4 deletions

View File

@ -1,3 +1,16 @@
2017-02-20 Werner Lemberg <wl@gnu.org>
[cff] Introduce `random-seed' property (1/2).
We need this for support of the `random' operator.
* include/freetype/ftcffdrv.h (FT_PARAM_TAG_RANDOM_SEED): New macro.
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): New
field `random_seed'.
* src/cff/cffobjs.h (CFF_DriverRec): New field `random_seed'.
2017-02-17 Werner Lemberg <wl@gnu.org> 2017-02-17 Werner Lemberg <wl@gnu.org>
Remove clang warnings. Remove clang warnings.

View File

@ -3631,11 +3631,16 @@ FT_BEGIN_HEADER
* *
* * Stem darkening (@FT_PARAM_TAG_STEM_DARKENING, corresponding to the * * Stem darkening (@FT_PARAM_TAG_STEM_DARKENING, corresponding to the
* property `no-stem-darkening' provided by the `autofit' and `cff' * property `no-stem-darkening' provided by the `autofit' and `cff'
* modules; see @auto_hinter and @cff_driver). * modules; see @no-stem-darkening[autofit] and
* @no-stem-darkening[cff]).
* *
* * LCD filter weights (@FT_PARAM_TAG_LCD_FILTER_WEIGHTS, corresponding * * LCD filter weights (@FT_PARAM_TAG_LCD_FILTER_WEIGHTS, corresponding
* to function @FT_Library_SetLcdFilterWeights). * to function @FT_Library_SetLcdFilterWeights).
* *
* * Seed value for the CFF `random' operator
* (@FT_PARAM_TAG_RANDOM_SEED, corresponding to the `random-seed'
* property provided by the `cff' module; see @random-seed).
*
* Pass NULL as `data' in @FT_Parameter for a given tag to reset the * Pass NULL as `data' in @FT_Parameter for a given tag to reset the
* option and use the library or module default again. * option and use the library or module default again.
* *
@ -3653,7 +3658,7 @@ FT_BEGIN_HEADER
* FreeType error code. 0~means success. * FreeType error code. 0~means success.
* *
* @note: * @note:
* Here an example that sets two properties. You must define * Here an example that sets three properties. You must define
* FT_CONFIG_OPTION_SUBPIXEL_RENDERING to make the LCD filter examples * FT_CONFIG_OPTION_SUBPIXEL_RENDERING to make the LCD filter examples
* work. * work.
* *
@ -3665,7 +3670,12 @@ FT_BEGIN_HEADER
* FT_LcdFiveTapFilter custom_weight = * FT_LcdFiveTapFilter custom_weight =
* { 0x10, 0x40, 0x70, 0x40, 0x10 }; * { 0x10, 0x40, 0x70, 0x40, 0x10 };
* *
* FT_Parameter properties[2] = { property1, property2 }; * FT_Parameter property3;
* FT_Int32 random_seed = 314159265;
*
* FT_Parameter properties[3] = { property1,
* property2,
* property3 };
* *
* *
* property1.tag = FT_PARAM_TAG_STEM_DARKENING; * property1.tag = FT_PARAM_TAG_STEM_DARKENING;
@ -3674,7 +3684,10 @@ FT_BEGIN_HEADER
* property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
* property2.data = custom_weight; * property2.data = custom_weight;
* *
* FT_Face_Properties( face, 2, properties ); * property3.tag = FT_PARAM_TAG_RANDOM_SEED;
* property3.data = &random_seed;
*
* FT_Face_Properties( face, 3, properties );
* } * }
* *
* The next example resets a single property to its default value. * The next example resets a single property to its default value.

View File

@ -113,6 +113,7 @@ FT_BEGIN_HEADER
* hinting-engine[cff] * hinting-engine[cff]
* no-stem-darkening[cff] * no-stem-darkening[cff]
* darkening-parameters[cff] * darkening-parameters[cff]
* random-seed
* *
*/ */
@ -265,6 +266,48 @@ FT_BEGIN_HEADER
* } * }
*/ */
/**************************************************************************
*
* @property:
* random-seed
*
* @description:
* By default, the seed value for the CFF `random' operator is set to a
* random value. However, mainly for debugging purposes, it is often
* necessary to use a known value as a seed so that the pseudo-random
* number sequences generated by `random' are repeatable.
*
* The `random-seed' property does that. Its argument is a signed 32bit
* integer; if the value is zero or negative, the seed given by the
* `intitialRandomSeed' private DICT operator in a CFF file gets used
* (or a default value if there is no such operator). If the value is
* positive, use it instead of `initialRandomSeed', which is
* consequently ignored.
*
* @note:
* This property can be set via the `FREETYPE_PROPERTIES' environment
* variable. It can also be set per face using @FT_Face_Properties with
* @FT_PARAM_TAG_RANDOM_SEED.
*
*/
/*
* @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' )
/* */ /* */

View File

@ -347,6 +347,11 @@ FT_BEGIN_HEADER
/* for example. FALSE and TRUE toggle stem darkening on and off, */ /* for example. FALSE and TRUE toggle stem darkening on and off, */
/* respectively, value~-1 means to use the module/driver default. */ /* respectively, value~-1 means to use the module/driver default. */
/* */ /* */
/* random_seed :: */
/* If positive, override the seed value for the CFF `random' */
/* operator. Value~0 means to use the font's value. Value~-1 */
/* means to use the CFF driver's default. */
/* */
/* lcd_weights :: */ /* lcd_weights :: */
/* Overrides the library default with custom weights for the 5-tap */ /* Overrides the library default with custom weights for the 5-tap */
/* FIR filter. `{0, 0, 0, 0, 0}' means to use the library default. */ /* FIR filter. `{0, 0, 0, 0, 0}' means to use the library default. */
@ -370,6 +375,7 @@ FT_BEGIN_HEADER
#endif #endif
FT_Char no_stem_darkening; FT_Char no_stem_darkening;
FT_Int32 random_seed;
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
FT_LcdFiveTapFilter lcd_weights; /* preset or custom filter weights */ FT_LcdFiveTapFilter lcd_weights; /* preset or custom filter weights */
#endif #endif

View File

@ -121,6 +121,7 @@ FT_BEGIN_HEADER
FT_UInt hinting_engine; FT_UInt hinting_engine;
FT_Bool no_stem_darkening; FT_Bool no_stem_darkening;
FT_Int darken_params[8]; FT_Int darken_params[8];
FT_Int32 random_seed;
} CFF_DriverRec; } CFF_DriverRec;