2020-06-27 Anuj Verma [sdf] Added function to resolve corners in case of ambiguity. * src/sdf/ftsdf.c (resolve_corner): Added function to determine the correct sign in case there are two sign for the same shortest distance (happens around corners). * src/sdf/ftsdf.c: Typo neartest_point -> nearest_point. 2020-06-27 Anuj Verma [sdf] The module can now generate signed distance fields for outline with only lines. * src/sdf/ftsdf.c (get_min_distance_line): Calculation mistake. * src/sdf/ftsdf.c (square_root): Added function to calculate square root of a 16.16 fixed point integer. * src/sdf/ftsdf.c (sdf_generate): Assign values to the output bitmap, currently the output is 6.10 fixed point which can contain values from [-32, 32]. Also fixed a bug which was causing upside down images. * src/sdf/ftsdfrend.c (ft_sdf_render): Fixed alignment issues. 2020-06-27 Anuj Verma [sdf] Added function to find shortest distance from a point to a line. * src/sdf/ftsdf.c (get_min_distance_line): The function calculate the shortest signed distance from a point to a line segment. * src/sdf/ftsdf.c (sdf_contour_get_min_distance): Typo. * src/sdf/ftsdf.c (SDF_Signed_Distance): Use squared distance instead of actual distance for performance. 2020-06-27 Anuj Verma * src/sdf/ftsdf.c (SDF_Iterator_IO): Removed. * src/sdf/ftsdf.c (sdf_edge_iterator_func => sdf_edge_get_min_distance sdf_contour_iterator_func => sdf_contour_get_min_distance): Renamed. Manually iterate through the lists instead of `FT_List_Iterate' to avoid io structs and looks a bit cleaner. 2020-06-27 Anuj Verma [sdf] Added basic outline of the functions required to generate sdf. * src/sdf/ftsdf.c (SDF_Signed_Distance): Added struct which represent a complete signed distance and can be used to get cross, dot, sign etc. * src/sdf/ftsdf.c (SDF_Iterator_IO): This struct will be used while `FT_List_Iterate'. * src/sdf/ftsdf.c (sdf_generate): Added function which genearte SDF from `SDF_Shape'. * src/sdf/ftsdf.c (sdf_edge_iterator_func, sdf_contour_iterator_func): Added funcions which iterate through contours and edges and return the shortest distance. 2020-06-26 Anuj Verma [sdf] Added `SDF_Raster_Params' struct which extends `FT_Raster_Params' and has a few extra fields. This is done to pass extra data to the sdf rasterzier which is required while rastersizing. * src/sdf/ftsdf.h (SDF_Raster_Params): Added a struct which extends `FT_Raster_Params' and has the `spread' parameter. Also moved the max, min and default spread values to this header file. * src/sdf/ftsdf.c (sdf_raster_render): Added parameter and attribute checking in order to pick errors and return early. * 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 * include/freetype/ftimage.h (FT_RASTER_FLAG_): Added a new raster flag `FT_RASTER_FLAG_SDF'. The `ftsdf' rasterizer will only render if this flag is set. * src/sdf/ftsdfrend.c (ft_sdf_render): Set the `flags' field of `FT_Raster_Params' to `FT_RASTER_FLAG_SDF'. 2020-06-26 Anuj Verma * src/sdf/ftsdf.c (sdf_shape_dump): Use `FT_TRACEX' instead of `printf'. 2020-06-26 Anuj Verma * src/sdf/ftsdf.c (sdf_shape_dump): Added function to dump the `SDF_Shape' on the console for debugging. 2020-06-26 Anuj Verma [sdf] Added functions to de-allocate `SDF_' structs. * src/sdf/ftsdf.c (SDF_Contour, SDF_Shape): Use `FT_ListRec' instead of `FT_List' to avoid a few extra allocations. * src/sdf/ftsdf.c (SDF_Edge, SDF_Contour, SDF_Shape): Added functions to de-allocate these structs and their members. * src/sdf/ftsdfrenc.c: Typo. 2020-06-25 Anuj Verma [sdf] Decompose outline and store it in a temporary `SDF_Shape' object for easy iteration and pre-computing some variables. * src/sdf/ftsdf.c (sdf_outline_decompose): Added function to decompost outline and store it in a `SDF_Shape' object. This allows us to pre-compute some variable. 2020-06-25 Anuj Verma [sdf] Added essential enums and structs required. * src/freetype/internal/fttrace.h: Remove tabs. * src/sdf/ftsdfrend.c (ft_sdf_render): Calculate padding using the `spread'. * src/sdf/ftsdf.c (SDF_Edge_Type, SDF_Edge, SDF_Contour, SDF_Shape): Added structures and their initializer functions. 2020-06-23 Anuj Verma [sdf] Added functionality to set and get module properties. Also added a `spread' property. * src/freetype/internal/fttrace.h: Added sdf module trace define. * src/sdf/ftsdf.c (sdf_TRaster => SDF_TRaster): Use capital character for structs. * src/sdf/ftsdfrend.h (SDF_Renderer_Module): Added a struct which extends the `FT_RendererRec' and added the `spread' property. * src/sdf/ftsdfrend.c: Synchronized the code to use the new `SDF_Renderer_Module' and added functions to get/set the properties. 2020-06-20 Anuj Verma [sdf] Implemented a few functions required by a renderer module. * src/sdf/ftsdf.c (sdf_TRaster_): Added new structure to hold the memory allocator `FT_Memory'. * src/sdf/ftsdf.c (ft_sdf_raster): Implemented a few essential functions required by `FT_Raster'. * src/sdf/ftsdfrend.c (ft_sdf_renderer_class): Implemented a few essential functions required by `FT_Renderer'. * src/sdf/ftsdfrend.c (ft_sdf_render): Added functionality to compute shift and padding before rendering the outline. 2020-06-19 Anuj Verma * include/freetype/ftimage.h (FT_Render_Mode_): Added new pixel mode `FT_PIXEL_MODE_GRAY16' which will be used to represent signed values while rendering to SDF bitmap. 2020-06-19 Anuj Verma * include/freetype/freetype.h (FT_Render_Mode_): Added new rendermode `FT_RENDER_MODE_SDF' which will be used by the `sdf' module to generate signed distance fields from glyph's outline. * src/sdf/ftsdfrend.h, src/sdf/module.mk, src/sdf/rules.mk: Add a new line at the end of files. 2020-06-18 Anuj Verma [sdf] Added the structure of a new module to render signed distance fields. * src/sdf/sdf.c, src/sdf/ftsdfrend.c, src/sdf/ftsdf.c, src/sdf/ftsdfrend.h, src/sdf/ftsdf.h, src/sdf/ftsdferrs.h: Added files required by the `sdf' renderer module and added the basic structure and functions required. * src/sdf/rules.mk, src/sdf/module.mk: Added files required to build the `sdf' module using the default build system. * CMakeLists.txt (BASE_SRCS): Add `src/sdf/sdf.c' to the variable. * include/freetype/config/ftmodule.h: Added `sdf' module declaration so that the module can be compiled when not compiling with GNU make. * modules.cfg (RASTER_MODULES): Include `sdf' module to the default rasterizer module list. * include/freetype/ftmoderr.h: sdf module error define