summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/pshinter/pshrec.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/pshinter/pshrec.c')
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshrec.c190
1 files changed, 93 insertions, 97 deletions
diff --git a/src/3rdparty/freetype/src/pshinter/pshrec.c b/src/3rdparty/freetype/src/pshinter/pshrec.c
index 73a18ffd64..f8895fc8d6 100644
--- a/src/3rdparty/freetype/src/pshinter/pshrec.c
+++ b/src/3rdparty/freetype/src/pshinter/pshrec.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PostScript hints recorder (body). */
/* */
-/* Copyright 2001-2004, 2007, 2009, 2013, 2014 by */
+/* Copyright 2001-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -31,7 +31,7 @@
#define FT_COMPONENT trace_pshrec
#ifdef DEBUG_HINTER
- PS_Hints ps_debug_hints = 0;
+ PS_Hints ps_debug_hints = NULL;
int ps_debug_no_horz_hints = 0;
int ps_debug_no_vert_hints = 0;
#endif
@@ -85,7 +85,7 @@
{
FT_Error error = FT_Err_Ok;
FT_UInt count;
- PS_Hint hint = 0;
+ PS_Hint hint = NULL;
count = table->num_hints;
@@ -167,12 +167,12 @@
/* clear a given bit */
static void
ps_mask_clear_bit( PS_Mask mask,
- FT_Int idx )
+ FT_UInt idx )
{
FT_Byte* p;
- if ( (FT_UInt)idx >= mask->num_bits )
+ if ( idx >= mask->num_bits )
return;
p = mask->bytes + ( idx >> 3 );
@@ -183,17 +183,14 @@
/* set a given bit, possibly grow the mask */
static FT_Error
ps_mask_set_bit( PS_Mask mask,
- FT_Int idx,
+ FT_UInt idx,
FT_Memory memory )
{
FT_Error error = FT_Err_Ok;
FT_Byte* p;
- if ( idx < 0 )
- goto Exit;
-
- if ( (FT_UInt)idx >= mask->num_bits )
+ if ( idx >= mask->num_bits )
{
error = ps_mask_ensure( mask, idx + 1, memory );
if ( error )
@@ -257,7 +254,7 @@
{
FT_UInt count;
FT_Error error = FT_Err_Ok;
- PS_Mask mask = 0;
+ PS_Mask mask = NULL;
count = table->num_masks;
@@ -372,8 +369,8 @@
/* test whether two masks in a table intersect */
static FT_Int
ps_mask_table_test_intersect( PS_Mask_Table table,
- FT_Int index1,
- FT_Int index2 )
+ FT_UInt index1,
+ FT_UInt index2 )
{
PS_Mask mask1 = table->masks + index1;
PS_Mask mask2 = table->masks + index2;
@@ -404,23 +401,25 @@
/* merge two masks, used by ps_mask_table_merge_all */
static FT_Error
ps_mask_table_merge( PS_Mask_Table table,
- FT_Int index1,
- FT_Int index2,
+ FT_UInt index1,
+ FT_UInt index2,
FT_Memory memory )
{
- FT_UInt temp;
FT_Error error = FT_Err_Ok;
/* swap index1 and index2 so that index1 < index2 */
if ( index1 > index2 )
{
+ FT_UInt temp;
+
+
temp = index1;
index1 = index2;
index2 = temp;
}
- if ( index1 < index2 && index1 >= 0 && index2 < (FT_Int)table->num_masks )
+ if ( index1 < index2 && index2 < table->num_masks )
{
/* we need to merge the bitsets of index1 and index2 with a */
/* simple union */
@@ -453,7 +452,7 @@
/* merge (unite) the bitsets */
read = mask2->bytes;
write = mask1->bytes;
- pos = (FT_UInt)( ( count2 + 7 ) >> 3 );
+ pos = ( count2 + 7 ) >> 3;
for ( ; pos > 0; pos-- )
{
@@ -468,14 +467,17 @@
mask2->num_bits = 0;
mask2->end_point = 0;
- delta = table->num_masks - 1 - index2; /* number of masks to move */
+ /* number of masks to move */
+ delta = (FT_Int)( table->num_masks - 1 - index2 );
if ( delta > 0 )
{
/* move to end of table for reuse */
PS_MaskRec dummy = *mask2;
- ft_memmove( mask2, mask2 + 1, delta * sizeof ( PS_MaskRec ) );
+ ft_memmove( mask2,
+ mask2 + 1,
+ (FT_UInt)delta * sizeof ( PS_MaskRec ) );
mask2[delta] = dummy;
}
@@ -502,13 +504,19 @@
FT_Error error = FT_Err_Ok;
- for ( index1 = table->num_masks - 1; index1 > 0; index1-- )
+ /* both loops go down to 0, thus FT_Int for index1 and index2 */
+ for ( index1 = (FT_Int)table->num_masks - 1; index1 > 0; index1-- )
{
for ( index2 = index1 - 1; index2 >= 0; index2-- )
{
- if ( ps_mask_table_test_intersect( table, index1, index2 ) )
+ if ( ps_mask_table_test_intersect( table,
+ (FT_UInt)index1,
+ (FT_UInt)index2 ) )
{
- error = ps_mask_table_merge( table, index2, index1, memory );
+ error = ps_mask_table_merge( table,
+ (FT_UInt)index2,
+ (FT_UInt)index1,
+ memory );
if ( error )
goto Exit;
@@ -670,8 +678,8 @@
{
PS_Mask mask;
FT_UInt idx;
- FT_UInt max = dim->hints.num_hints;
- PS_Hint hint = dim->hints.hints;
+ FT_UInt max = dim->hints.num_hints;
+ PS_Hint hint = dim->hints.hints;
for ( idx = 0; idx < max; idx++, hint++ )
@@ -742,17 +750,26 @@
}
/* now, set the bits for our hints in the counter mask */
- error = ps_mask_set_bit( counter, hint1, memory );
- if ( error )
- goto Exit;
+ if ( hint1 >= 0 )
+ {
+ error = ps_mask_set_bit( counter, (FT_UInt)hint1, memory );
+ if ( error )
+ goto Exit;
+ }
- error = ps_mask_set_bit( counter, hint2, memory );
- if ( error )
- goto Exit;
+ if ( hint2 >= 0 )
+ {
+ error = ps_mask_set_bit( counter, (FT_UInt)hint2, memory );
+ if ( error )
+ goto Exit;
+ }
- error = ps_mask_set_bit( counter, hint3, memory );
- if ( error )
- goto Exit;
+ if ( hint3 >= 0 )
+ {
+ error = ps_mask_set_bit( counter, (FT_UInt)hint3, memory );
+ if ( error )
+ goto Exit;
+ }
Exit:
return error;
@@ -793,7 +810,7 @@
ps_dimension_done( &hints->dimension[1], memory );
hints->error = FT_Err_Ok;
- hints->memory = 0;
+ hints->memory = NULL;
}
@@ -811,78 +828,57 @@
ps_hints_open( PS_Hints hints,
PS_Hint_Type hint_type )
{
- switch ( hint_type )
- {
- case PS_HINT_TYPE_1:
- case PS_HINT_TYPE_2:
- hints->error = FT_Err_Ok;
- hints->hint_type = hint_type;
+ hints->error = FT_Err_Ok;
+ hints->hint_type = hint_type;
- ps_dimension_init( &hints->dimension[0] );
- ps_dimension_init( &hints->dimension[1] );
- break;
-
- default:
- hints->error = FT_THROW( Invalid_Argument );
- hints->hint_type = hint_type;
-
- FT_TRACE0(( "ps_hints_open: invalid charstring type\n" ));
- break;
- }
+ ps_dimension_init( &hints->dimension[0] );
+ ps_dimension_init( &hints->dimension[1] );
}
/* add one or more stems to the current hints table */
static void
ps_hints_stem( PS_Hints hints,
- FT_Int dimension,
- FT_UInt count,
+ FT_UInt dimension,
+ FT_Int count,
FT_Long* stems )
{
- if ( !hints->error )
- {
- /* limit "dimension" to 0..1 */
- if ( dimension < 0 || dimension > 1 )
- {
- FT_TRACE0(( "ps_hints_stem: invalid dimension (%d) used\n",
- dimension ));
- dimension = ( dimension != 0 );
- }
+ PS_Dimension dim;
- /* record the stems in the current hints/masks table */
- switch ( hints->hint_type )
- {
- case PS_HINT_TYPE_1: /* Type 1 "hstem" or "vstem" operator */
- case PS_HINT_TYPE_2: /* Type 2 "hstem" or "vstem" operator */
- {
- PS_Dimension dim = &hints->dimension[dimension];
+ if ( hints->error )
+ return;
- for ( ; count > 0; count--, stems += 2 )
- {
- FT_Error error;
- FT_Memory memory = hints->memory;
+ /* limit "dimension" to 0..1 */
+ if ( dimension > 1 )
+ {
+ FT_TRACE0(( "ps_hints_stem: invalid dimension (%d) used\n",
+ dimension ));
+ dimension = ( dimension != 0 );
+ }
+ /* record the stems in the current hints/masks table */
+ /* (Type 1 & 2's `hstem' or `vstem' operators) */
+ dim = &hints->dimension[dimension];
- error = ps_dimension_add_t1stem(
- dim, (FT_Int)stems[0], (FT_Int)stems[1],
- memory, NULL );
- if ( error )
- {
- FT_ERROR(( "ps_hints_stem: could not add stem"
- " (%d,%d) to hints table\n", stems[0], stems[1] ));
+ for ( ; count > 0; count--, stems += 2 )
+ {
+ FT_Error error;
+ FT_Memory memory = hints->memory;
- hints->error = error;
- return;
- }
- }
- break;
- }
- default:
- FT_TRACE0(( "ps_hints_stem: called with invalid hint type (%d)\n",
- hints->hint_type ));
- break;
+ error = ps_dimension_add_t1stem( dim,
+ (FT_Int)stems[0],
+ (FT_Int)stems[1],
+ memory,
+ NULL );
+ if ( error )
+ {
+ FT_ERROR(( "ps_hints_stem: could not add stem"
+ " (%d,%d) to hints table\n", stems[0], stems[1] ));
+
+ hints->error = error;
+ return;
}
}
}
@@ -891,7 +887,7 @@
/* add one Type1 counter stem to the current hints table */
static void
ps_hints_t1stem3( PS_Hints hints,
- FT_Int dimension,
+ FT_UInt dimension,
FT_Fixed* stems )
{
FT_Error error = FT_Err_Ok;
@@ -906,7 +902,7 @@
/* limit "dimension" to 0..1 */
- if ( dimension < 0 || dimension > 1 )
+ if ( dimension > 1 )
{
FT_TRACE0(( "ps_hints_t1stem3: invalid dimension (%d) used\n",
dimension ));
@@ -1128,7 +1124,7 @@
static void
t1_hints_stem( T1_Hints hints,
- FT_Int dimension,
+ FT_UInt dimension,
FT_Fixed* coords )
{
FT_Pos stems[2];
@@ -1172,12 +1168,12 @@
static void
t2_hints_stems( T2_Hints hints,
- FT_Int dimension,
+ FT_UInt dimension,
FT_Int count,
FT_Fixed* coords )
{
- FT_Pos stems[32], y, n;
- FT_Int total = count;
+ FT_Pos stems[32], y;
+ FT_Int total = count, n;
y = 0;