diff options
author | Werner Lemberg <wl@gnu.org> | 2015-02-22 15:54:31 +0100 |
---|---|---|
committer | Werner Lemberg <wl@gnu.org> | 2015-02-22 15:54:31 +0100 |
commit | 25c2f8820fe9585e14463d83dd394facbefafc35 (patch) | |
tree | 6de6a25d188fc7edada9e82eb9d3611c5b1faa16 /src/pshinter | |
parent | 01f0842eb0d690e313c9bfefb1fc0d6a359b35df (diff) | |
download | freetype2-25c2f8820fe9585e14463d83dd394facbefafc35.tar.gz |
* src/pshinter/pshrec.c: Simplify.
(ps_hints_open, ps_hints_stem): Remove switch statement.
Diffstat (limited to 'src/pshinter')
-rw-r--r-- | src/pshinter/pshrec.c | 87 |
1 files changed, 33 insertions, 54 deletions
diff --git a/src/pshinter/pshrec.c b/src/pshinter/pshrec.c index eb7987ce4..05ba981e5 100644 --- a/src/pshinter/pshrec.c +++ b/src/pshinter/pshrec.c @@ -811,24 +811,11 @@ 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; - - ps_dimension_init( &hints->dimension[0] ); - ps_dimension_init( &hints->dimension[1] ); - break; + hints->error = FT_Err_Ok; + hints->hint_type = hint_type; - 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] ); } @@ -839,50 +826,42 @@ FT_Int count, FT_Long* stems ) { - if ( !hints->error ) - { - /* limit "dimension" to 0..1 */ - if ( 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; } } } |