[type1] Minor. * src/type1/t1load.c (T1_Set_MM_Blend, T1_Set_MM_Design): Use FT_THROW. (T1_Set_Var_Design): Use T1_MAX_MM_AXIS and FT_THROW.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
diff --git a/ChangeLog b/ChangeLog
index 7d58921..4bb3ca0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2015-03-27 Werner Lemberg <wl@gnu.org>
+ [type1] Minor.
+
+ * src/type1/t1load.c (T1_Set_MM_Blend, T1_Set_MM_Design): Use
+ FT_THROW.
+ (T1_Set_Var_Design): Use T1_MAX_MM_AXIS and FT_THROW.
+
+2015-03-27 Werner Lemberg <wl@gnu.org>
+
[cff] Trace charstring nesting levels.
* src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdCALLGSUBR,
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 66ed9cb..acfa486 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -368,44 +368,39 @@
FT_Fixed* coords )
{
PS_Blend blend = face->blend;
- FT_Error error;
FT_UInt n, m;
- error = FT_ERR( Invalid_Argument );
+ if ( !blend || blend->num_axis != num_coords )
+ return FT_THROW( Invalid_Argument );
- if ( blend && blend->num_axis == num_coords )
+ /* recompute the weight vector from the blend coordinates */
+ for ( n = 0; n < blend->num_designs; n++ )
{
- /* recompute the weight vector from the blend coordinates */
- for ( n = 0; n < blend->num_designs; n++ )
- {
- FT_Fixed result = 0x10000L; /* 1.0 fixed */
+ FT_Fixed result = 0x10000L; /* 1.0 fixed */
- for ( m = 0; m < blend->num_axis; m++ )
- {
- FT_Fixed factor;
+ for ( m = 0; m < blend->num_axis; m++ )
+ {
+ FT_Fixed factor;
- /* get current blend axis position */
- factor = coords[m];
- if ( factor < 0 )
- factor = 0;
- if ( factor > 0x10000L )
- factor = 0x10000L;
+ /* get current blend axis position */
+ factor = coords[m];
+ if ( factor < 0 )
+ factor = 0;
+ if ( factor > 0x10000L )
+ factor = 0x10000L;
- if ( ( n & ( 1 << m ) ) == 0 )
- factor = 0x10000L - factor;
+ if ( ( n & ( 1 << m ) ) == 0 )
+ factor = 0x10000L - factor;
- result = FT_MulFix( result, factor );
- }
- blend->weight_vector[n] = result;
+ result = FT_MulFix( result, factor );
}
-
- error = FT_Err_Ok;
+ blend->weight_vector[n] = result;
}
- return error;
+ return FT_Err_Ok;
}
@@ -415,68 +410,63 @@
FT_Long* coords )
{
PS_Blend blend = face->blend;
- FT_Error error;
FT_UInt n, p;
+ FT_Fixed final_blends[T1_MAX_MM_DESIGNS];
+
+ if ( !blend || blend->num_axis != num_coords )
+ return FT_THROW( Invalid_Argument );
- error = FT_ERR( Invalid_Argument );
- if ( blend && blend->num_axis == num_coords )
+ /* compute the blend coordinates through the blend design map */
+
+ for ( n = 0; n < blend->num_axis; n++ )
{
- /* compute the blend coordinates through the blend design map */
- FT_Fixed final_blends[T1_MAX_MM_DESIGNS];
+ FT_Long design = coords[n];
+ FT_Fixed the_blend;
+ PS_DesignMap map = blend->design_map + n;
+ FT_Long* designs = map->design_points;
+ FT_Fixed* blends = map->blend_points;
+ FT_Int before = -1, after = -1;
- for ( n = 0; n < blend->num_axis; n++ )
+ for ( p = 0; p < (FT_UInt)map->num_points; p++ )
{
- FT_Long design = coords[n];
- FT_Fixed the_blend;
- PS_DesignMap map = blend->design_map + n;
- FT_Long* designs = map->design_points;
- FT_Fixed* blends = map->blend_points;
- FT_Int before = -1, after = -1;
+ FT_Long p_design = designs[p];
- for ( p = 0; p < (FT_UInt)map->num_points; p++ )
+ /* exact match? */
+ if ( design == p_design )
{
- FT_Long p_design = designs[p];
-
-
- /* exact match? */
- if ( design == p_design )
- {
- the_blend = blends[p];
- goto Found;
- }
-
- if ( design < p_design )
- {
- after = (FT_Int)p;
- break;
- }
+ the_blend = blends[p];
+ goto Found;
+ }
- before = (FT_Int)p;
+ if ( design < p_design )
+ {
+ after = (FT_Int)p;
+ break;
}
- /* now interpolate if necessary */
- if ( before < 0 )
- the_blend = blends[0];
+ before = (FT_Int)p;
+ }
- else if ( after < 0 )
- the_blend = blends[map->num_points - 1];
+ /* now interpolate if necessary */
+ if ( before < 0 )
+ the_blend = blends[0];
- else
- the_blend = FT_MulDiv( design - designs[before],
- blends [after] - blends [before],
- designs[after] - designs[before] );
+ else if ( after < 0 )
+ the_blend = blends[map->num_points - 1];
- Found:
- final_blends[n] = the_blend;
- }
+ else
+ the_blend = FT_MulDiv( design - designs[before],
+ blends [after] - blends [before],
+ designs[after] - designs[before] );
- error = T1_Set_MM_Blend( face, num_coords, final_blends );
+ Found:
+ final_blends[n] = the_blend;
}
- return error;
+ return T1_Set_MM_Blend( face, num_coords, final_blends );
}
@@ -490,20 +480,17 @@
FT_UInt num_coords,
FT_Fixed* coords )
{
- FT_Long lcoords[4]; /* maximum axis count is 4 */
- FT_UInt i;
- FT_Error error;
+ FT_Long lcoords[T1_MAX_MM_AXIS];
+ FT_UInt i;
+
+ if ( num_coords > T1_MAX_MM_AXIS || num_coords == 0 )
+ return FT_THROW( Invalid_Argument );
- error = FT_ERR( Invalid_Argument );
- if ( num_coords <= 4 && num_coords > 0 )
- {
- for ( i = 0; i < num_coords; ++i )
- lcoords[i] = FIXED_TO_INT( coords[i] );
- error = T1_Set_MM_Design( face, num_coords, lcoords );
- }
+ for ( i = 0; i < num_coords; ++i )
+ lcoords[i] = FIXED_TO_INT( coords[i] );
- return error;
+ return T1_Set_MM_Design( face, num_coords, lcoords );
}