summaryrefslogtreecommitdiffstats
path: root/src/pshinter
diff options
context:
space:
mode:
Diffstat (limited to 'src/pshinter')
-rw-r--r--src/pshinter/pshalgo.c17
-rw-r--r--src/pshinter/pshalgo.h11
-rw-r--r--src/pshinter/pshglob.c51
-rw-r--r--src/pshinter/pshmod.c17
-rw-r--r--src/pshinter/pshpic.c17
-rw-r--r--src/pshinter/pshpic.h16
-rw-r--r--src/pshinter/pshrec.c53
7 files changed, 113 insertions, 69 deletions
diff --git a/src/pshinter/pshalgo.c b/src/pshinter/pshalgo.c
index d798978..343472d 100644
--- a/src/pshinter/pshalgo.c
+++ b/src/pshinter/pshalgo.c
@@ -4,8 +4,7 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
-/* by */
+/* Copyright 2001-2010, 2012, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -402,13 +401,13 @@
FT_Fixed delta,
FT_Int dimension )
{
- PSH_Hint hint;
- FT_UInt count;
+ FT_UInt count;
for ( count = 0; count < table->max_hints; count++ )
{
- hint = table->hints + count;
+ PSH_Hint hint = table->hints + count;
+
hint->cur_pos = FT_MulFix( hint->org_pos, scale ) + delta;
hint->cur_len = FT_MulFix( hint->org_len, scale );
@@ -563,7 +562,7 @@
else if ( len > 0 )
{
/* This is a very small stem; we simply align it to the
- * pixel grid, trying to find the minimal displacement.
+ * pixel grid, trying to find the minimum displacement.
*
* left = pos
* right = pos + len
@@ -1162,8 +1161,8 @@
int result = PSH_DIR_NONE;
- ax = ( dx >= 0 ) ? dx : -dx;
- ay = ( dy >= 0 ) ? dy : -dy;
+ ax = FT_ABS( dx );
+ ay = FT_ABS( dy );
if ( ay * 12 < ax )
{
@@ -2194,7 +2193,7 @@
/* something to do? */
if ( outline->n_points == 0 || outline->n_contours == 0 )
- return PSH_Err_Ok;
+ return FT_Err_Ok;
#ifdef DEBUG_HINTER
diff --git a/src/pshinter/pshalgo.h b/src/pshinter/pshalgo.h
index 1a248a7..c70f31e 100644
--- a/src/pshinter/pshalgo.h
+++ b/src/pshinter/pshalgo.h
@@ -4,7 +4,7 @@
/* */
/* PostScript hinting algorithm (specification). */
/* */
-/* Copyright 2001, 2002, 2003, 2008 by */
+/* Copyright 2001-2003, 2008, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,7 +22,6 @@
#include "pshrec.h"
#include "pshglob.h"
-#include FT_TRIGONOMETRY_H
FT_BEGIN_HEADER
@@ -168,8 +167,6 @@ FT_BEGIN_HEADER
FT_UInt flags2;
FT_Char dir_in;
FT_Char dir_out;
- FT_Angle angle_in;
- FT_Angle angle_out;
PSH_Hint hint;
FT_Pos org_u;
FT_Pos org_v;
@@ -186,12 +183,6 @@ FT_BEGIN_HEADER
} PSH_PointRec;
-#define PSH_POINT_EQUAL_ORG( a, b ) ( (a)->org_u == (b)->org_u && \
- (a)->org_v == (b)->org_v )
-
-#define PSH_POINT_ANGLE( a, b ) FT_Atan2( (b)->org_u - (a)->org_u, \
- (b)->org_v - (a)->org_v )
-
typedef struct PSH_ContourRec_
{
PSH_Point start;
diff --git a/src/pshinter/pshglob.c b/src/pshinter/pshglob.c
index 31231ad..9285efc 100644
--- a/src/pshinter/pshglob.c
+++ b/src/pshinter/pshglob.c
@@ -5,7 +5,7 @@
/* PostScript hinter global hinting management (body). */
/* Inspired by the new auto-hinter module. */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2006, 2010 by */
+/* Copyright 2001-2004, 2006, 2010, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -522,6 +522,28 @@
}
+ /* calculate the maximum height of given blue zones */
+ static FT_Short
+ psh_calc_max_height( FT_UInt num,
+ const FT_Short* values,
+ FT_Short cur_max )
+ {
+ FT_UInt count;
+
+
+ for ( count = 0; count < num; count += 2 )
+ {
+ FT_Short cur_height = values[count + 1] - values[count];
+
+
+ if ( cur_height > cur_max )
+ cur_max = cur_height;
+ }
+
+ return cur_max;
+ }
+
+
FT_LOCAL_DEF( void )
psh_blues_snap_stem( PSH_Blues blues,
FT_Int stem_top,
@@ -684,7 +706,32 @@
priv->family_blues, priv->num_family_other_blues,
priv->family_other_blues, priv->blue_fuzz, 1 );
- globals->blues.blue_scale = priv->blue_scale;
+ /* limit the BlueScale value to `1 / max_of_blue_zone_heights' */
+ {
+ FT_Fixed max_scale;
+ FT_Short max_height = 1;
+
+
+ max_height = psh_calc_max_height( priv->num_blue_values,
+ priv->blue_values,
+ max_height );
+ max_height = psh_calc_max_height( priv->num_other_blues,
+ priv->other_blues,
+ max_height );
+ max_height = psh_calc_max_height( priv->num_family_blues,
+ priv->family_blues,
+ max_height );
+ max_height = psh_calc_max_height( priv->num_family_other_blues,
+ priv->family_other_blues,
+ max_height );
+
+ /* BlueScale is scaled 1000 times */
+ max_scale = FT_DivFix( 1000, max_height );
+ globals->blues.blue_scale = priv->blue_scale < max_scale
+ ? priv->blue_scale
+ : max_scale;
+ }
+
globals->blues.blue_shift = priv->blue_shift;
globals->blues.blue_fuzz = priv->blue_fuzz;
diff --git a/src/pshinter/pshmod.c b/src/pshinter/pshmod.c
index 91da5d7..cdeaca1 100644
--- a/src/pshinter/pshmod.c
+++ b/src/pshinter/pshmod.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PostScript hinter module implementation (body). */
/* */
-/* Copyright 2001, 2002, 2007 by */
+/* Copyright 2001, 2002, 2007, 2009, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -93,14 +93,15 @@
}
- FT_DEFINE_PSHINTER_INTERFACE(pshinter_interface,
+ FT_DEFINE_PSHINTER_INTERFACE(
+ pshinter_interface,
pshinter_get_globals_funcs,
pshinter_get_t1_funcs,
- pshinter_get_t2_funcs
- )
+ pshinter_get_t2_funcs )
- FT_DEFINE_MODULE(pshinter_module_class,
+ FT_DEFINE_MODULE(
+ pshinter_module_class,
0,
sizeof ( PS_Hinter_ModuleRec ),
@@ -108,11 +109,11 @@
0x10000L,
0x20000L,
- &FTPSHINTER_INTERFACE_GET, /* module-specific interface */
+ &PSHINTER_INTERFACE_GET, /* module-specific interface */
(FT_Module_Constructor)ps_hinter_init,
(FT_Module_Destructor) ps_hinter_done,
- (FT_Module_Requester) 0 /* no additional interface for now */
- )
+ (FT_Module_Requester) NULL ) /* no additional interface for now */
+
/* END */
diff --git a/src/pshinter/pshpic.c b/src/pshinter/pshpic.c
index 1e0f9a9..568f4ac 100644
--- a/src/pshinter/pshpic.c
+++ b/src/pshinter/pshpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for pshinter module. */
/* */
-/* Copyright 2009, 2010 by */
+/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,6 +22,7 @@
#include "pshpic.h"
#include "pshnterr.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from pshmod.c */
@@ -33,7 +34,7 @@
pshinter_module_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_Memory memory = library->memory;
if ( pic_container->pshinter )
@@ -48,13 +49,13 @@
pshinter_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = PSH_Err_Ok;
- PSHinterPIC* container;
+ FT_Error error = FT_Err_Ok;
+ PSHinterPIC* container = NULL;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->pshinter = container;
@@ -63,13 +64,13 @@
FT_Init_Class_pshinter_interface(
library, &container->pshinter_interface );
-/*Exit:*/
- if( error )
+ if ( error )
pshinter_module_class_pic_free( library );
+
return error;
}
-
#endif /* FT_CONFIG_OPTION_PIC */
+
/* END */
diff --git a/src/pshinter/pshpic.h b/src/pshinter/pshpic.h
index c10bdd9..b46f853 100644
--- a/src/pshinter/pshpic.h
+++ b/src/pshinter/pshpic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for pshinter module. */
/* */
-/* Copyright 2009 by */
+/* Copyright 2009, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -24,21 +24,25 @@ FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
+
#ifndef FT_CONFIG_OPTION_PIC
-#define FTPSHINTER_INTERFACE_GET pshinter_interface
+#define PSHINTER_INTERFACE_GET pshinter_interface
#else /* FT_CONFIG_OPTION_PIC */
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
- typedef struct PSHinterPIC_
+ typedef struct PSHinterPIC_
{
- PSHinter_Interface pshinter_interface;
+ PSHinter_Interface pshinter_interface;
+
} PSHinterPIC;
-#define GET_PIC(lib) ((PSHinterPIC*)((lib)->pic_container.autofit))
-#define FTPSHINTER_INTERFACE_GET (GET_PIC(library)->pshinter_interface)
+
+#define GET_PIC( lib ) ( (PSHinterPIC*)( (lib)->pic_container.pshinter ) )
+
+#define PSHINTER_INTERFACE_GET ( GET_PIC( library )->pshinter_interface )
/* see pshpic.c for the implementation */
void
diff --git a/src/pshinter/pshrec.c b/src/pshinter/pshrec.c
index 0910cc5..cd66ea8 100644
--- a/src/pshinter/pshrec.c
+++ b/src/pshinter/pshrec.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PostScript hints recorder (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2007, 2009 by */
+/* Copyright 2001-2004, 2007, 2009, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -64,7 +64,7 @@
{
FT_UInt old_max = table->max_hints;
FT_UInt new_max = count;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( new_max > old_max )
@@ -83,7 +83,7 @@
FT_Memory memory,
PS_Hint *ahint )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UInt count;
PS_Hint hint = 0;
@@ -139,7 +139,7 @@
{
FT_UInt old_max = ( mask->max_bits + 7 ) >> 3;
FT_UInt new_max = ( count + 7 ) >> 3;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( new_max > old_max )
@@ -186,7 +186,7 @@
FT_Int idx,
FT_Memory memory )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Byte* p;
@@ -236,7 +236,7 @@
{
FT_UInt old_max = table->max_masks;
FT_UInt new_max = count;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( new_max > old_max )
@@ -256,7 +256,7 @@
PS_Mask *amask )
{
FT_UInt count;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
PS_Mask mask = 0;
@@ -287,7 +287,7 @@
FT_Memory memory,
PS_Mask *amask )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UInt count;
PS_Mask mask;
@@ -316,7 +316,7 @@
FT_UInt bit_count,
FT_Memory memory )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error;
PS_Mask mask;
@@ -384,7 +384,7 @@
FT_UInt count;
- count = ( count1 <= count2 ) ? count1 : count2;
+ count = FT_MIN( count1, count2 );
for ( ; count >= 8; count -= 8 )
{
if ( p1[0] & p2[0] )
@@ -409,7 +409,7 @@
FT_Memory memory )
{
FT_UInt temp;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
/* swap index1 and index2 so that index1 < index2 */
@@ -499,7 +499,7 @@
FT_Memory memory )
{
FT_Int index1, index2;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
for ( index1 = table->num_masks - 1; index1 > 0; index1-- )
@@ -561,7 +561,7 @@
FT_Memory memory )
{
PS_Mask mask;
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
/* get last hint mask */
@@ -583,12 +583,13 @@
FT_UInt end_point )
{
FT_UInt count = dim->masks.num_masks;
- PS_Mask mask;
if ( count > 0 )
{
- mask = dim->masks.masks + count - 1;
+ PS_Mask mask = dim->masks.masks + count - 1;
+
+
mask->end_point = end_point;
}
}
@@ -621,7 +622,7 @@
FT_UInt end_point,
FT_Memory memory )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error;
/* reset current mask, if any */
@@ -646,7 +647,7 @@
FT_Memory memory,
FT_Int *aindex )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UInt flags = 0;
@@ -717,7 +718,7 @@
FT_Int hint3,
FT_Memory memory )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_UInt count = dim->counters.num_masks;
PS_Mask counter = dim->counters.masks;
@@ -791,7 +792,7 @@
ps_dimension_done( &hints->dimension[0], memory );
ps_dimension_done( &hints->dimension[1], memory );
- hints->error = PSH_Err_Ok;
+ hints->error = FT_Err_Ok;
hints->memory = 0;
}
@@ -802,7 +803,7 @@
{
FT_MEM_ZERO( hints, sizeof ( *hints ) );
hints->memory = memory;
- return PSH_Err_Ok;
+ return FT_Err_Ok;
}
@@ -815,7 +816,7 @@
{
case PS_HINT_TYPE_1:
case PS_HINT_TYPE_2:
- hints->error = PSH_Err_Ok;
+ hints->error = FT_Err_Ok;
hints->hint_type = hint_type;
ps_dimension_init( &hints->dimension[0] );
@@ -823,7 +824,7 @@
break;
default:
- hints->error = PSH_Err_Invalid_Argument;
+ hints->error = FT_THROW( Invalid_Argument );
hints->hint_type = hint_type;
FT_TRACE0(( "ps_hints_open: invalid charstring type\n" ));
@@ -894,7 +895,7 @@
FT_Int dimension,
FT_Fixed* stems )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( !hints->error )
@@ -938,7 +939,7 @@
else
{
FT_ERROR(( "ps_hints_t1stem3: called with invalid hint type\n" ));
- error = PSH_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Fail;
}
}
@@ -956,7 +957,7 @@
ps_hints_t1reset( PS_Hints hints,
FT_UInt end_point )
{
- FT_Error error = PSH_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( !hints->error )
@@ -979,7 +980,7 @@
else
{
/* invalid hint type */
- error = PSH_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Fail;
}
}