diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog index e4f6e629a..60258aff6 100644 --- a/[GSoC]ChangeLog +++ b/[GSoC]ChangeLog @@ -1,4 +1,17 @@ -2020-06-27 Anuj Verma +2020-06-30 Anuj Verma + + [sdf] Fixed compilation under gnumake. + + * src/sdf/rules.mk (DRV_OBJ_ => DRV_OBJS_): Fixed varialbe + name so that the sdf can compile. + + * src/sdf/module.mk: Fixed spacing. + + * src/sdf/*.c: Fixed all compiler warnings. + + * [GSoC]ChangLog: Fixed dates. + +2020-06-29 Anuj Verma [sdf] Added function to resolve corners in case of ambiguity. @@ -10,7 +23,7 @@ * src/sdf/ftsdf.c: Typo neartest_point -> nearest_point. -2020-06-27 Anuj Verma +2020-06-29 Anuj Verma [sdf] The module can now generate signed distance fields for outline with only lines. @@ -28,7 +41,7 @@ * src/sdf/ftsdfrend.c (ft_sdf_render): Fixed alignment issues. -2020-06-27 Anuj Verma +2020-06-28 Anuj Verma [sdf] Added function to find shortest distance from a point to a line. @@ -42,7 +55,7 @@ * src/sdf/ftsdf.c (SDF_Signed_Distance): Use squared distance instead of actual distance for performance. -2020-06-27 Anuj Verma +2020-06-28 Anuj Verma * src/sdf/ftsdf.c (SDF_Iterator_IO): Removed. @@ -51,7 +64,7 @@ Manually iterate through the lists instead of `FT_List_Iterate' to avoid io structs and looks a bit cleaner. -2020-06-27 Anuj Verma +2020-06-28 Anuj Verma [sdf] Added basic outline of the functions required to generate sdf. @@ -72,7 +85,7 @@ distance. -2020-06-26 Anuj Verma +2020-06-27 Anuj Verma [sdf] Added `SDF_Raster_Params' struct which extends `FT_Raster_Params' and has a few extra fields. This is done @@ -91,7 +104,7 @@ * src//sdf/ftsdfrend.c (ft_sdf_render): Setup the `SDF_Raster_Params' and pass it to the rasterizer instead of `FT_Raster_Params'. -2020-06-26 Anuj Verma +2020-06-27 Anuj Verma * include/freetype/ftimage.h (FT_RASTER_FLAG_): Added a new raster flag `FT_RASTER_FLAG_SDF'. The `ftsdf' diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c index 2c96cbffe..2f676be6e 100644 --- a/src/sdf/ftsdf.c +++ b/src/sdf/ftsdf.c @@ -155,8 +155,7 @@ goto Exit; } - FT_QNEW( ptr ); - if ( error == FT_Err_Ok ) + if ( !FT_QNEW( ptr ) ) { *ptr = null_edge; *edge = ptr; @@ -205,8 +204,7 @@ goto Exit; } - FT_QNEW( ptr ); - if ( error == FT_Err_Ok ) + if ( !FT_QNEW( ptr ) ) { *ptr = null_contour; *contour = ptr; @@ -260,8 +258,7 @@ goto Exit; } - FT_QNEW( ptr ); - if ( error == FT_Err_Ok ) + if ( !FT_QNEW( ptr ) ) { *ptr = null_shape; ptr->memory = memory; @@ -320,8 +317,7 @@ if ( error != FT_Err_Ok ) goto Exit; - FT_QNEW( node ); - if ( error != FT_Err_Ok ) + if ( FT_QNEW( node ) ) goto Exit; contour->last_pos = *to; @@ -362,8 +358,7 @@ if ( error != FT_Err_Ok ) goto Exit; - FT_QNEW( node ); - if ( error != FT_Err_Ok ) + if ( FT_QNEW( node ) ) goto Exit; edge->edge_type = SDF_EDGE_LINE; @@ -405,8 +400,7 @@ if ( error != FT_Err_Ok ) goto Exit; - FT_QNEW( node ); - if ( error != FT_Err_Ok ) + if ( FT_QNEW( node ) ) goto Exit; edge->edge_type = SDF_EDGE_CONIC; @@ -450,8 +444,7 @@ if ( error != FT_Err_Ok ) goto Exit; - FT_QNEW( node ); - if ( error != FT_Err_Ok ) + if ( FT_QNEW( node ) ) goto Exit; edge->edge_type = SDF_EDGE_CUBIC; @@ -1007,7 +1000,7 @@ static FT_Error sdf_generate( const SDF_Shape* shape, FT_UInt spread, - FT_Bitmap* bitmap ) + const FT_Bitmap* bitmap ) { FT_Error error = FT_Err_Ok; FT_UInt width = 0; @@ -1030,8 +1023,8 @@ goto Exit; } - width = bitmap->width; - rows = bitmap->rows; + width = bitmap->width; + rows = bitmap->rows; buffer = (FT_Short*)bitmap->buffer; sp_sq = FT_INT_16D16( spread * spread ); @@ -1054,13 +1047,16 @@ /* `grid_point' is the current pixel position */ /* our task is to find the shortest distance */ /* from this point to the entire shape. */ - FT_26D6_Vec grid_point = { FT_INT_26D6( x ), - FT_INT_26D6( y ) }; - SDF_Signed_Distance min_dist = max_sdf; + FT_26D6_Vec grid_point = zero_vector; + SDF_Signed_Distance min_dist = max_sdf; FT_ListRec contour_list; FT_UInt index; FT_Short value; + + grid_point.x = FT_INT_26D6( x ); + grid_point.y = FT_INT_26D6( y ); + /* This `grid_point' is at the corner, but we */ /* use the center of the pixel. */ grid_point.x += FT_INT_26D6( 1 ) / 2; diff --git a/src/sdf/ftsdfrend.c b/src/sdf/ftsdfrend.c index 5df5d225f..6ae6a2219 100644 --- a/src/sdf/ftsdfrend.c +++ b/src/sdf/ftsdfrend.c @@ -37,12 +37,12 @@ const void* value, FT_Bool value_is_string ) { - FT_UNUSED( value_is_string ); - - FT_Error error = FT_Err_Ok; + FT_Error error = FT_Err_Ok; SDF_Renderer render = SDF_RENDERER( FT_RENDERER( module ) ); + FT_UNUSED( value_is_string ); + if ( ft_strcmp( property_name, "spread" ) == 0 ) { FT_Int val = *(const FT_Int*)value; @@ -95,7 +95,6 @@ error = FT_THROW( Missing_Property ); } - Exit: return error; } @@ -217,7 +216,7 @@ /* ignore the pitch, pixel mode and set custom */ bitmap->pixel_mode = FT_PIXEL_MODE_GRAY16; bitmap->pitch = bitmap->width * 2; - bitmap->num_grays = 65536; + bitmap->num_grays = 65535; /* allocate new buffer */ if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) ) diff --git a/src/sdf/module.mk b/src/sdf/module.mk index 00dd07817..d4253bd39 100644 --- a/src/sdf/module.mk +++ b/src/sdf/module.mk @@ -4,7 +4,7 @@ FTMODULE_H_COMMANDS += SDF_RENDERER define SDF_RENDERER $(OPEN_DRIVER) FT_Renderer_Class, ft_sdf_renderer_class $(CLOSE_DRIVER) -$(ECHO_DRIVER)sdf $(ECHO_DRIVER_DESC) signed distance field renderer $(ECHO_DRIVER_DONE) +$(ECHO_DRIVER)sdf $(ECHO_DRIVER_DESC)signed distance field renderer$(ECHO_DRIVER_DONE) endef #EOF diff --git a/src/sdf/rules.mk b/src/sdf/rules.mk index 88525a449..efc8ac53e 100644 --- a/src/sdf/rules.mk +++ b/src/sdf/rules.mk @@ -54,5 +54,5 @@ $(OBJ_DIR)/%.$O: $(SDF_DIR)/%.c $(FREETYPE_H) $(SDF_DRV_H) # update main driver list # -DRV_OBJ_S += $(SDF_DRV_OBJ_S) -DRV_OBJ_M += $(SDF_DRV_OBJ_M) +DRV_OBJS_S += $(SDF_DRV_OBJ_S) +DRV_OBJS_M += $(SDF_DRV_OBJ_M)