< prev index next >
src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c
Print this page
*** 70,81 ****
/* some macros we need */
#define FT_fdot14ToFixed( x ) \
( (FT_Fixed)( (FT_ULong)(x) << 2 ) )
#define FT_intToFixed( i ) \
( (FT_Fixed)( (FT_ULong)(i) << 16 ) )
#define FT_fixedToInt( x ) \
! ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) )
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
--- 70,85 ----
/* some macros we need */
#define FT_fdot14ToFixed( x ) \
( (FT_Fixed)( (FT_ULong)(x) << 2 ) )
#define FT_intToFixed( i ) \
( (FT_Fixed)( (FT_ULong)(i) << 16 ) )
+ #define FT_fdot6ToFixed( i ) \
+ ( (FT_Fixed)( (FT_ULong)(i) << 10 ) )
#define FT_fixedToInt( x ) \
! ( (FT_Short)( ( (x) + 0x8000U ) >> 16 ) )
! #define FT_fixedToFdot6( x ) \
! ( (FT_Pos)( ( (x) + 0x200 ) >> 10 ) )
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
*** 395,407 ****
goto Exit;
}
for ( j = 0; j < segment->pairCount; j++ )
{
! /* convert to Fixed */
! segment->correspondence[j].fromCoord = FT_GET_SHORT() * 4;
! segment->correspondence[j].toCoord = FT_GET_SHORT() * 4;
FT_TRACE5(( " mapping %.5f to %.5f\n",
segment->correspondence[j].fromCoord / 65536.0,
segment->correspondence[j].toCoord / 65536.0 ));
}
--- 399,412 ----
goto Exit;
}
for ( j = 0; j < segment->pairCount; j++ )
{
! segment->correspondence[j].fromCoord =
! FT_fdot14ToFixed( FT_GET_SHORT() );
! segment->correspondence[j].toCoord =
! FT_fdot14ToFixed( FT_GET_SHORT() );
FT_TRACE5(( " mapping %.5f to %.5f\n",
segment->correspondence[j].fromCoord / 65536.0,
segment->correspondence[j].toCoord / 65536.0 ));
}
*** 1614,1624 ****
{
FT_TRACE5(( " [ " ));
for ( j = 0; j < (FT_UInt)gvar_head.axisCount; j++ )
{
blend->tuplecoords[i * gvar_head.axisCount + j] =
! FT_GET_SHORT() * 4; /* convert to FT_Fixed */
FT_TRACE5(( "%.5f ",
blend->tuplecoords[i * gvar_head.axisCount + j] / 65536.0 ));
}
FT_TRACE5(( "]\n" ));
}
--- 1619,1629 ----
{
FT_TRACE5(( " [ " ));
for ( j = 0; j < (FT_UInt)gvar_head.axisCount; j++ )
{
blend->tuplecoords[i * gvar_head.axisCount + j] =
! FT_fdot14ToFixed( FT_GET_SHORT() );
FT_TRACE5(( "%.5f ",
blend->tuplecoords[i * gvar_head.axisCount + j] / 65536.0 ));
}
FT_TRACE5(( "]\n" ));
}
*** 3052,3062 ****
/* `instance_index' starts with value 1, thus `>' */
if ( instance_index > num_instances )
goto Exit;
! if ( instance_index > 0 && mmvar->namedstyle )
{
FT_Memory memory = face->root.memory;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
FT_Var_Named_Style* named_style;
--- 3057,3067 ----
/* `instance_index' starts with value 1, thus `>' */
if ( instance_index > num_instances )
goto Exit;
! if ( instance_index > 0 )
{
FT_Memory memory = face->root.memory;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
FT_Var_Named_Style* named_style;
*** 3078,3089 ****
--- 3083,3099 ----
/* finally, select the named instance */
error = TT_Set_Var_Design( face,
mmvar->num_axis,
named_style->coords );
if ( error )
+ {
+ /* internal error code -1 means `no change' */
+ if ( error == -1 )
+ error = FT_Err_Ok;
goto Exit;
}
+ }
else
error = TT_Set_Var_Design( face, 0, NULL );
face->root.face_index = ( instance_index << 16 ) |
( face->root.face_index & 0xFFFFL );
*** 3101,3110 ****
--- 3111,3135 ----
/***** *****/
/*************************************************************************/
/*************************************************************************/
+ static FT_Error
+ tt_cvt_ready_iterator( FT_ListNode node,
+ void* user )
+ {
+ TT_Size size = (TT_Size)node->data;
+
+ FT_UNUSED( user );
+
+
+ size->cvt_ready = -1;
+
+ return FT_Err_Ok;
+ }
+
+
/**************************************************************************
*
* @Function:
* tt_face_vary_cvt
*
*** 3131,3140 ****
--- 3156,3167 ----
FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
+ FT_Face root = &face->root;
+
FT_ULong table_start;
FT_ULong table_len;
FT_UInt tupleCount;
FT_ULong offsetToData;
*** 3259,3270 ****
tupleIndex = FT_GET_USHORT();
if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
{
for ( j = 0; j < blend->num_axis; j++ )
! tuple_coords[j] = FT_GET_SHORT() * 4; /* convert from */
! /* short frac to fixed */
}
else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
FT_TRACE2(( "tt_face_vary_cvt:"
" invalid tuple index\n" ));
--- 3286,3296 ----
tupleIndex = FT_GET_USHORT();
if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
{
for ( j = 0; j < blend->num_axis; j++ )
! tuple_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
}
else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
FT_TRACE2(( "tt_face_vary_cvt:"
" invalid tuple index\n" ));
*** 3291,3303 ****
}
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
{
for ( j = 0; j < blend->num_axis; j++ )
! im_start_coords[j] = FT_GET_SHORT() * 4;
for ( j = 0; j < blend->num_axis; j++ )
! im_end_coords[j] = FT_GET_SHORT() * 4;
}
apply = ft_var_apply_tuple( blend,
(FT_UShort)tupleIndex,
tuple_coords,
--- 3317,3329 ----
}
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
{
for ( j = 0; j < blend->num_axis; j++ )
! im_start_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
for ( j = 0; j < blend->num_axis; j++ )
! im_end_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
}
apply = ft_var_apply_tuple( blend,
(FT_UShort)tupleIndex,
tuple_coords,
*** 3358,3370 ****
#ifdef FT_DEBUG_LEVEL_TRACE
if ( old_cvt_delta != cvt_deltas[j] )
{
FT_TRACE7(( " %d: %f -> %f\n",
j,
! ( FT_intToFixed( face->cvt[j] ) +
old_cvt_delta ) / 65536.0,
! ( FT_intToFixed( face->cvt[j] ) +
cvt_deltas[j] ) / 65536.0 ));
count++;
}
#endif
}
--- 3384,3396 ----
#ifdef FT_DEBUG_LEVEL_TRACE
if ( old_cvt_delta != cvt_deltas[j] )
{
FT_TRACE7(( " %d: %f -> %f\n",
j,
! ( FT_fdot6ToFixed( face->cvt[j] ) +
old_cvt_delta ) / 65536.0,
! ( FT_fdot6ToFixed( face->cvt[j] ) +
cvt_deltas[j] ) / 65536.0 ));
count++;
}
#endif
}
*** 3400,3412 ****
#ifdef FT_DEBUG_LEVEL_TRACE
if ( old_cvt_delta != cvt_deltas[pindex] )
{
FT_TRACE7(( " %d: %f -> %f\n",
pindex,
! ( FT_intToFixed( face->cvt[pindex] ) +
old_cvt_delta ) / 65536.0,
! ( FT_intToFixed( face->cvt[pindex] ) +
cvt_deltas[pindex] ) / 65536.0 ));
count++;
}
#endif
}
--- 3426,3438 ----
#ifdef FT_DEBUG_LEVEL_TRACE
if ( old_cvt_delta != cvt_deltas[pindex] )
{
FT_TRACE7(( " %d: %f -> %f\n",
pindex,
! ( FT_fdot6ToFixed( face->cvt[pindex] ) +
old_cvt_delta ) / 65536.0,
! ( FT_fdot6ToFixed( face->cvt[pindex] ) +
cvt_deltas[pindex] ) / 65536.0 ));
count++;
}
#endif
}
*** 3427,3437 ****
}
FT_TRACE5(( "\n" ));
for ( i = 0; i < face->cvt_size; i++ )
! face->cvt[i] += FT_fixedToInt( cvt_deltas[i] );
FExit:
FT_FRAME_EXIT();
Exit:
--- 3453,3463 ----
}
FT_TRACE5(( "\n" ));
for ( i = 0; i < face->cvt_size; i++ )
! face->cvt[i] += FT_fixedToFdot6( cvt_deltas[i] );
FExit:
FT_FRAME_EXIT();
Exit:
*** 3440,3449 ****
--- 3466,3481 ----
FT_FREE( tuple_coords );
FT_FREE( im_start_coords );
FT_FREE( im_end_coords );
FT_FREE( cvt_deltas );
+ /* iterate over all FT_Size objects and set `cvt_ready' to -1 */
+ /* to trigger rescaling of all CVT values */
+ FT_List_Iterate( &root->sizes_list,
+ tt_cvt_ready_iterator,
+ NULL );
+
return error;
}
/* Shift the original coordinates of all points between indices `p1' */
*** 3667,3683 ****
--- 3699,3721 ----
*
* @InOut:
* outline ::
* The outline to change.
*
+ * @Output:
+ * unrounded ::
+ * An array with `n_points' elements that is filled with unrounded
+ * point coordinates (in 26.6 format).
+ *
* @Return:
* FreeType error code. 0 means success.
*/
FT_LOCAL_DEF( FT_Error )
TT_Vary_Apply_Glyph_Deltas( TT_Face face,
FT_UInt glyph_index,
FT_Outline* outline,
+ FT_Vector* unrounded,
FT_UInt n_points )
{
FT_Error error;
FT_Stream stream = face->root.stream;
FT_Memory memory = stream->memory;
*** 3715,3724 ****
--- 3753,3768 ----
if ( !face->doblend || !blend )
return FT_THROW( Invalid_Argument );
+ for ( i = 0; i < n_points; i++ )
+ {
+ unrounded[i].x = INT_TO_F26DOT6( outline->points[i].x );
+ unrounded[i].y = INT_TO_F26DOT6( outline->points[i].y );
+ }
+
if ( glyph_index >= blend->gv_glyphcnt ||
blend->glyphoffsets[glyph_index] ==
blend->glyphoffsets[glyph_index + 1] )
{
FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
*** 3805,3816 ****
tupleIndex = FT_GET_USHORT();
if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
{
for ( j = 0; j < blend->num_axis; j++ )
! tuple_coords[j] = FT_GET_SHORT() * 4; /* convert from */
! /* short frac to fixed */
}
else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
" invalid tuple index\n" ));
--- 3849,3859 ----
tupleIndex = FT_GET_USHORT();
if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
{
for ( j = 0; j < blend->num_axis; j++ )
! tuple_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
}
else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
" invalid tuple index\n" ));
*** 3826,3838 ****
blend->num_axis * sizeof ( FT_Fixed ) );
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
{
for ( j = 0; j < blend->num_axis; j++ )
! im_start_coords[j] = FT_GET_SHORT() * 4;
for ( j = 0; j < blend->num_axis; j++ )
! im_end_coords[j] = FT_GET_SHORT() * 4;
}
apply = ft_var_apply_tuple( blend,
(FT_UShort)tupleIndex,
tuple_coords,
--- 3869,3881 ----
blend->num_axis * sizeof ( FT_Fixed ) );
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
{
for ( j = 0; j < blend->num_axis; j++ )
! im_start_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
for ( j = 0; j < blend->num_axis; j++ )
! im_end_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() );
}
apply = ft_var_apply_tuple( blend,
(FT_UShort)tupleIndex,
tuple_coords,
*** 4062,4071 ****
--- 4105,4117 ----
FT_TRACE5(( "\n" ));
for ( i = 0; i < n_points; i++ )
{
+ unrounded[i].x += FT_fixedToFdot6( point_deltas_x[i] );
+ unrounded[i].y += FT_fixedToFdot6( point_deltas_y[i] );
+
outline->points[i].x += FT_fixedToInt( point_deltas_x[i] );
outline->points[i].y += FT_fixedToInt( point_deltas_y[i] );
}
Fail3:
< prev index next >