* 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'.
* 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.
* 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.
* 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.
* include/freetype/internal/autohint.h
(FT_DECLARE_AUTOHINTER_INTERFACE): New macro.
* src/autofit/afmodule.h: Use it to declare
`af_autofitter_interface'.
* include/freetype/internal/ftobjs.h (FT_DECLARE_GLYPH): New macro.
* src/base/ftbase.h: Use it to declare `ft_bitmap_glyph_class' and
`ft_outline_glyph_class'.
* src/base/ftglyph.c: Include `ftbase.h'.
* src/cff/cffparse.c (cff_parser_run): Fix type of `t2_size'.
* src/pcf/pcfdrivr.c (pcf_cmap_char_next): Fix type of `result'.
* src/psaux/psauxmod.c (psaux_module_class): Use `FT_DEFINE_MODULE'.
* src/psaux/psauxmod.h: Declare `afm_parser_funcs',
`t1_cmap_classes', `cff_decoder_funcs', and `psaux_module_class'.
* src/pshinter/pshmod.c: Include `pshmod.h'.
* src/sfnt/sfwoff2.c (ROUND4, WRITE_SHORT): Fix implicit sign
conversion.
(compute_ULong_sum): Fix return type.
Fix implicit sign conversion.
(store_points): Fix type of `last_flag', `repeat_count', and `flag'.
Use casts to avoid warnings.
(reconstruct_glyf): Fix implicit sign conversion.
Use cast to avoid warning.
(get_x_mins): Fix implicit sign conversion.
* src/sfnt/ttcmap.c: Undef `TTCMAPCITEM'.
* src/sfnt/ttcmap.h: Define `TTCMAPCITEM' and include `ttcmapc.h' to
declare cmap classes.
* src/smooth/ftsmooth.c (ft_smooth_overlap_spans): Use cast.
* src/truetype/ttinterp.c (Ins_MIAP): Fix typo.
The following builds were still failing due to previous changes:
make multi
make multi CC="c++"
make CC="c++"
This patch fixes the issues, which were missing includes to get the
right macro definitions in multi-build mode.
Also, `FT_UNUSED' is actually used by third-party code, so move it
back to `public-macros.h' to avoid breaking it.
* include/freetype/config/public-macros.h (FT_EXPORT): Remove
special definition for C++.
(FT_UNUSED): Define here instead of...
* include/freetype/config/compiler-macros.h: ... here.
(FT_FUNCTION_DECLARATION): Remove special definition for C++.
(FT_LOCAL_ARRAY_DEF): Fix definition.
* src/cache/ftccback.h, src/lzw/ftzopen.h, src/gxvalid/gxvmort.h,
src/gxvalid/gxvmorx.h: Add `FT_BEGIN_HEADER' and `FT_END_HEADER'.
The following builds were failing due to previous changes:
make multi
make multi CC="c++"
* include/freetype/config/ftconfig.h: Remove `FT_END_HEADER'.
* include/freetype/config/ftheader.h (FT_BEGIN_HEADER,
FT_END_HEADER): Protect against redefinition.
* src/cache/ftccache.h, src/cache/ftcmru.h, src/pcf/pcfutil.h,
src/psaux/pserror.h, src/psaux/psft.h, src/psaux/psstack.h,
src/sfnt/woff2tags.h: Include `compiler-macros.h'.
* src/sfnt/woff2tags.c: Include `woff2tags.h'.
* src/psaux/t1decode.c (t1_decoder_parse_metrics): Copy
corresponding code from old engine's `t1_decoder_parse_charstrings'
function to handle `op_callsubr' and `op_return'.
* builds/unix/ftconfig.h.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h: Split off macro definitions
required by the FreeType API headers to...
* include/freetype/config/public-macros.h: ...this new file.
* builds/unix/ftconfig.h.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h: Split off macro definitions used
by the library but not to be exposed to clients to...
* include/freetype/config/compiler-macros.h: ...this new file.
* include/freetype/internal/*.h, src/raster/ftraster.h: Include
`compiler-macros.h' where needed.
This implements oversampling to metigate artifacts in pixels partially
covered by overlapping contours. It turns out that the 4x4
oversampling is sufficient but, at least, quadruples the rendering
time. The outline has to set FT_OUTLINE_OVERLAP to use this method.
* include/freetype/ftimage.h (FT_OUTLINE_OVERLAP): New flag.
* src/smooth/ftsmooth.c (ft_smooth_render): Check it to...
(ft_smooth_raster_overlap): ... inflate outline and set up direct
rendering for oversampling with...
(ft_smooth_overlap_spans): ... new span function that integrates them.
Instead of rendering 3 bitmaps side by side and reshuffling, we use
direct rendering to deliver the bitmaps on each third byte.
* src/smooth/ftsmooth.c (ft_smooth_raster_lcd)
[!FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Set up direct mode with...
(ft_smooth_lcd_spans): ... new span function.
This makes `ft_smooth_render' a lot smaller and easier to follow. It
also cleanly separates Harmony and ClearType-style LCD rendering
algorithms. Now I only wish to move LCD filtering and geometry from
FT_Library to FT_Renderer.
* src/smooth/ftsmooth.c (ft_smooth_render): Move LCD code from here...
(ft_smooth_raster_lcd, ft_smooth_raster_lcdv): ... to here.
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Reorganize #ifdef's.
* src/cff/cffobjs.c (cff_face_init): If a call to `cff_strcpy' fails
by returning NULL in `cff_face_init', `remove_style' is still
called. This means that the NULL pointer is dereferenced, causing a
crash.
* src/cff/cffobjs.c (cff_size_init): If a call to `funcs->create'
fails to allocate one of the `internal->subfont' variables, make
sure to free `internal->topfont' and any successfully allocated
subfonts.
* src/base/ftobjs.c (FT_New_Size): Avoid trying to free
`size->internal`, unless `size' has been allocated. This
mistake appeared in the fix for 58611.