* src/sdf/ftsdf.c (get_control_box): Use goto instead of letting the next case statement
execute to avoid compiler warning [-Wimplicit-fallthrough=].
* src/sdf/ftsdf.c (sdf_generate_bounding_box): Fix compiler warning due to signed
unsigned mismatch.
* src/sdf/ftsdfrend.c (ft_sdf_done): The function must have a return type of `void'
to match the signature of `FT_Module_Destructor'.
* include/freetype/fttypes.h (FT_F6Dot10): Add a new data type which can be\
used to convert the output buffer appropriately.
* include/freetype/freetype.h (FT_Render_Mode): Add information about the
output while using `FT_RENDER_MODE_SDF'.
* include/freetype/ftimage.h (FT_Pixel_Mode): Add more information about the
`FT_PIXEL_MODE_GRAY16' pixel mode.
* src/sdf/ftsdf.c (*): Only track memory when `FT_DEBUG_MEMORY' is defined. Some
variables used internally by the freetype memory debugger are only defined when
we are tracking memory. If `FT_DEBUG_MEMORY' is not defined those variable
are not defined and we get undefined reference error.
* src/sdf/ftsdf.c (*): Added a technical overview of the working of the `sdf' rasterizer.
* src/sdf/ftbsdf,c (*) : Added a technical overview of the working of the `bsdf'
rasterizer.
* src/sdf/ftsdfrend.c (ft_bsdf_render): Added the `bsdf' renderer, render function
which is essentially what is called from the FreeType core to render a glyph.
* src/sdf/ftsdfrend.c (ft_bitmap_sdf_renderer_class): Added the `bsdf' renderer
definition.
* src/sdf/ftsdf.c (bsdf_raster_): Added interface functions which are called from the
FreeType core library to rasterize and do various other stuff with the rasterizer.
* src/sdf/ftbsdf.c (finalize_sdf): The function uses the final data present in the
distance map and copies is to the output bitmap. It also converts our data into the
desired format.
* src/sdf/ftbsdf.c (edt8): Added function to do the euclidean transform to the
distance map. The function basically does the 8SED algorithm on the distance map
to compute the distance transform of the bitmap.
* src/sdf/ftbsdf.c (first_pass, second_pass): The first and the second pass of the 8SED
algorithm.
* src/sdf/ftbsdf.c (compare_neighbor): Helper function to compare the neighbor of
a pixel which is required in the 8SED algorithm.
* src/sdf/ftbsdf.c (bsdf_init_distance_map): The function copies the source bitmap to
the intermediate distance map which is present within the `worker'.
* src/sdf/ftbsdf.c (compute_edge_distance): Added function to approximate edges
given only the array of alpha values representing pixel coverage. This function uses
the Gustavson's algorithm for approximating.
* src/sdf/ftbsdf.c (bsdf_approximate_edge): This function loops through the entire
bitmap and for edge pixel (found using `bsdf_is_edge') compute approximate edge
distances (using `compute_edge_distance').
* src/sdf/ftbsdf.c (bsdf_is_edge): The function find the edge pixel in a distance map
which is basically a 2D array of alpha values which represent coverage in the
original input bitmap.
* src/sdf/ftbsdf.c (*): Added all the essential structures required internally by the
`bsdf' rasterizer as well as the initializer for the `ED' struct.
* include/freetype/config/ftmodule.h (*): Add both the renderers to the list of
modules. This allows build systems other than GNU Make to use the renderers.
* CMakeLists.txt (BASE_SRCS): Add the `sdf' module single object to the list of source
files.
* src/sdf/ftsdf.c (sdf_generate_with_overlaps): Added another `sdf_generate_'
function which can generate SDF for glyphs with overlapping contour. Note that
it cannot generate proper SDF for glyphs with self intersecting contours.
* src/sdf/module.mk, src/sdf/rules.mk: Fix file names, they were reversed.
* include/freetype/ftmoderr.h (FT_MODERRDEF): Add error definition for the `sdf'
module.
* include/freetype/internal/fttrace.h (FT_TRACE_DEF): Add trace definition for the
`sdf' module.
* modules.cfg (RASTER_MODULES): Add the `sdf' module to the list of rasterizers.
* src/sdf/ftsdf.c (sdf_raster_): Added interface functions which are called from the
FreeType core library to rasterize and do various other stuff with the rasterizer.
* src/sdf/ftsdf.c (sdf_generate_bounding_box): Added function to generate SDF by
only checking grid point around the bounding box of any edge.
* src/sdf/ftsdf.c (sdf_generate_subdivision): Added function to generate SDF by
splitting the shape into a number of line segments and then only checking grid
points around the neighborhood of the lines.
* src/sdf/ftsdf.c (sdf_generate): Added function to generate SDF. This one doesn't use
any optimization, it simply check all grid point against all contours.
* src/sdf/ftsdf,c (sdf_edge_get_min_distance): Added function to get shortest distance
from any arbitary edge.
* src/sdf/ftsdf.c (sdf_contour_get_min_distance): Added function to get shortest
distance from a contour. It basically returns the shortest distance from the nearest
edge.
* src/sdf/ftsdf.c (get_min_distance_): Added function to find the closest distance
from a point to a curves of all three different types (i.e. line segment, conic
bezier and cubic bezier).
* src/sdf/ftsdf.c (cube_root, arc_cos): Added functions to compute cube root and
cosine inverse of a 16.16 fixed point number.
* src/sdf/ftsdf.c (solve_quadratic_equation, solve_cubic_equation): Added
functions to find roots of quadratic and cubic polynomial equations.
* src/sdf/ftsdf.c (get_control_box, get_contour_orientation): Added functions to
get control box and orientation of any `SDF_Contour'.
* src/sdf/ftsdf.c (split_sdf_shape): Added function to split a complete shape (i.e.
a collection of contours) into a number of small lines.
* src/sdf/ftsdf.c (sdf_outline_decompose): Added a function which decompose
a `FT_Outline' using `FT_Outline_Decompose' and adds the outline data to a
`SDF_Shape' for easier handling later on.
* src/sdf/ftsdf.c (SDF_): Added the essential structures and enums which will
be used internally by the `sdf' rasterizer. Also added allocator and deallocator
functions for the structs.
* src/sdf/ftsdf.c (SDF_MemoryUser): Added a custom memory allocator which
is used to track intermediate memory usage while generate SDF.
* src/sdf/ftsdf.c (definations): Added various definitions which can be used to
modify the `sdf' rasterizer and also added a few helper macros.
* src/sdf/ftsdf.h (SDF_Raster_Params): Added struct which is used to pass
params to both `sdf' and `bsdf' rasterizer.
* src/sdf/sdf.c (*): Include source files in order to make a single object of the
module.
* src/sdf/ftsdfrend.h (SDF_Renderer_Module): Add a '*' to make the comment
similar to the rest in the module.
* src/sdf/ftsdfrend.c (*): Added common renderer struct and
declaration of both the renderers.
* src/sdf/ftsdfcommon.h (*): Added common properties, typedefs,
macros etc.
* src/sdf/ftsdferrs.h (*): Error definitions for the module.
Added the necessary files required by the `sdf' module. These include files
for both the `sdf' and the `bsdf' renderers. Here is breakdown of what the
specific files will contain:
* src/sdf/ftsdfrend.*: Both the renderers.
* src/sdf/ftsdf.*: The rasterizer for the `sdf' renderer.
* src/sdf/ftbsdf.c: The rasterizer for the `bsdf' renderer.
* src/sdf/ftsdfcommon.h: Commmon properties and functions for both the
rasterizers.
* src/sdf/ftsdferrs.h: Common error define.
* src/sdf/sdf.c: For building a single object of the entire module.
* include/freetype/freetype.h (FT_Render_Mode): Added a new render mode
`FT_RENDER_MODE_SDF', which will be used to generate SDF.
* include/freetype/ftimage.h (FT_Pixel_Mode): Added a new pixel mode
`FT_PIXEL_MODE_GRAY16', which will be the output of the `sdf' module.
* include/freetype/ftimage.h (FT_RASTER_FLAG_SDF): Added a new raster flag
to be used internally by the `sdf' module.
* src/base/ftobjs.c (FT_Render_Glyph_Internal): Do not return if the glyph's slot
format is `FT_GLYPH_FORMAT_BITMAP'. The `bsdf' renderer will require bitmaps
for processing.
* src/base/ftobjs.c (ft_add_renderer, ft_remove_renderer): Remove renderer's glyph
format check before adding and removing them. The `bsdf' renderer will have a
format of `FT_GLYPH_FORMAT_BITMAP'. So, if we do not remove this check it will
not get initialized and will not work.
For glyphs with OVERLAP_SIMPLE or OVERLAP_COMPOUND, set
FT_OUTLINE_OVERLAP to render them with direct oversampling, which
mitigates artifacts (see 3bb512bc9f).
* include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): Redefine to rhyme
with OVERLAP_SIMPLE.
* src/base/ftgloadr.c (FT_GlyphLoader_Rewind): Reset outline flags.
* src/truetype/ttgload.c
(TT_Load_Simple_Glyph): Retain OVERLAP_SIMPLE.
(load_truetype_glyph): Retain OVERLAP_COMPOUND.
This file can be used to reformat FreeType sources and commits
using one of these methods:
- Direct formatting of a whole file:
clang-format -i path/to/file
For example, to reformat all sources at once:
echo builds/unix/ftconfig.h.in $(git ls-files *.[hc]) | xargs clang-format -i
- Only reformat the changed lines in the current work directoy:
git clang-format
The style settings in this file are very close to the FreeType
formatting style, with the following exceptions which are not supported
here:
- Mminimal 2-space margin on each non-empty line.
(no left margin instead).
- 2 empty lines between variable declarations and statements in C blocks.
(only 1 is kept).
{
int x = ...;
foo(x);
}
becomes
{
int x = ...;
foo(x);
}
- Aignment of declarations uses 2 spaces to separate types and variable
names (only 1 space is kept).
int x; => int x;
int y; int y;
- The start used for output parameters in function signature should be
near the variable name (always near the type).
void foo(int* input_ptr, int *output_ptr)
=> void foo(int* input_ptr, int* output_ptr)
In order to mention the limited accuracy of `FT_Matrix' coefficients
and encourage client code to perform the transform themselves with
floating point values instead.