The old code used to divide the darkening amount by em_ratio twice,
leading to unnecessarily bold stems on certain fonts with higher
units per em (e.g. Inter). This patch fixes it.
The return value of af_loader_compute_darkening was also changed to
use 16.16 fixed point to get rid of a redundant truncation operation.
This should slightly improve the precision, although it's still
bottlenecked by the emboldening function, which uses 26.6 fixed point.
* src/autofit/afloader.[ch]
(af_loader_compute_darkening): Return FT_Fixed.
(af_loader_embolden_glyph_in_slot): Revise calculations.
This monster commit was created by applying Nikhil's scripts
`docconverter.py' and `markify.py' to all C header and source files,
followed up by minor manual clean-up.
No change in functionality, of course.
I used commit f7419907bc6044b9b7057f9789866426c804ba82 from
https://github.com/nikramakrishnan/freetype-docs.git.
This is a crude adaption of the original `cf2_computeDarkening'
function.
* src/autofit/afloader.c (af_intToFixed, af_fixedToInt,
af_floatToFixed): New macros, taken from `cf2fixed.h'.
(af_loader_compute_darkening): New function.
* src/autofit/afloader.h: Updated.
This avoids one malloc per load.
* src/autofit/afloader.h (AF_LoaderRec): Change type of `hints' to
`AF_GlyphHints'.
Update prototype.
* src/autofit/afloader.c (af_loader_init): Use `AF_GlyphHints'
parameter instead of `FT_Memory'.
(af_loader_done): Directly reset `load_hints'.
(af_loader_load_g): Updated.
* src/autofit/afmodule.c (af_autofitter_load_glyph): Use local
`hints' object.
No need to create a new glyph loader; we can reuse the one from
`slot->internal->loader'. It's hard to tell why it was written that
way originally, but new code looks sound and correct to me, and
avoids lots of allocations.
* src/autofit/afloader.c (af_loader_init): Change return type to
`void'.
Don't call `FT_GlyphLoader_New'.
(af_loader_reset): Don't call `FT_GlyphLoader_Rewind'.
(af_loader_load_g): Update code to use `internal->loader', which
doesn't need copying of data.
* src/autofit/afloader.h (AF_LoaderRec): Remove `gloader' member.
Update prototype.
* src/autofit/afmodule.c (af_autofitter_load_glyph): Updated.
Stop sharing a global `AF_Loader'. Allocate one on the stack during
glyph load.
Right now this results in about 25% slowdown, to be fixed in a
following commit.
With this patch loading glyphs from different faces from different
threads doesn't immediately crash in the autohinting loader code.
Bugs:
https://bugzilla.redhat.com/show_bug.cgi?id=1164941
* src/autofit/afloader.c (af_loader_init): Pass
`AF_Loader' and `FT_Memory' instead of `AF_Module' as arguments.
(af_loader_reset, af_loader_load_glyph): Also pass `loader' as
argument.
(af_loader_done): Use `AF_Loader' instead of `AF_Module' as
argument.
* src/autofit/afmodule.c (af_autofitter_init): Don't call
`af_loader_init'.
(af_autofitter_done): Don't call `af_loader_done'.
(af_autofitter_load_glyph): Use a local `AF_Loader' object.
* src/autofit/afloader.h: Include `afmodule.h'.
Update prototypes.
Move typedef for `AF_Module' to...
* src/autofit/afmodule.h: ... this place.
No longer include `afloader.h'.
We want to access the (not yet existing) module's global data later
on.
* src/autofit/afloader.c: Include `afmodule.h'.
(af_loader_init, af_loader_reset, af_loader_done,
af_loader_load_glyph): Change accordingly.
* src/autofit/afmodule.c (AF_ModuleRec): Move to `afmodule.h'.
Updated.
* src/autofit/afmodule.h: Include `afloader.h'.
(AF_ModuleRec): Define here.
* src/autofit/afloader.h (AF_Module): Define here.
Updated.
* src/autofit/*: Add copyright messages.
Formatting.
* src/autofit/afhints.c (af_glyph_hints_done): Don't use
`AF_Dimension' but `int' for loop counter.
* src/autofit/aflatin.c (af_latin_metrics_init_widths): Don't use
`AF_Dimension' but `int' for loop counter.
Use proper enumeration value for `render_mode'.
(af_latin_metrics_scale_dim): Don't shadow variables.
(af_latin_hints_compute_segments): Use proper cast for `major_dir'
and `segment_dir'.
(af_latin_align_linked_edge, af_latin_hint_edges): Fix arguments of call to
`af_latin_compute_stem_width'.
(af_latin_hints_apply): Don't use `AF_Dimension' but `int' for loop
counter.
* src/base/ftdbgmem.c (ft_mem_table_get_source, FT_DumpMemory): Use
proper cast for memory allocation.
* src/cff/cffdrivr.c (cff_get_kerning): Use proper cast for
initialization of `sfnt'.
* src/sfnt/sfdriver.c: Include `ttkern.h'.
* src/sfnt/ttkern.c (tt_face_get_kerning): Don't shadow variables.
* src/truetype/ttgload.c: Include `ttpload.h'.
* src/truetype/ttpload.c (tt_face_load_loca) [FT_OPTIMIZE_MEMORY]:
Remove redundant variable.
* include/freetype/internal/tttypes.h (TT_LoaderRec): Add
`top_bearing', `vadvance', `pp3, and `pp4'.
* src/autofit/afloader.c (af_loader_load_g): Handle two more points.
* src/autohint/ahhint.c (ah_hinter_load): Handle two more points.
* src/truetype/ttgload.c (Get_VMetrics): New function.
(TT_Load_Simple_Glyph, TT_Process_Simple_Glyph): Handle two more
points.
(load_truetype_glyph): Use Get_VMetrics.
Handle two more points.
(compute_glyph_metrics): Thanks to vertical phantom points we now
can always compute `advance_height' and `top_bearing'.
* src/truetype/ttobjs.h (TT_SubglyphRec): Add vertical phantom
points.
* src/autohint/ahglyph.c (ah_outline_load): Fix allocation of
`news'.
Converting some files to Unix end-of-line convention.
outside of /Subrs or /CharStrings. This can happen if there is
additional code manipulating those two arrays so that FreeType
doesn't recognize them properly.
(T1_Open_Face): Improve an error message.
Remove CR/LF on many files.
* src/cache/*, include/freetype/cache/*: fixing a bug after heavy
testing. The current sources are now "release candidates" for the
final version of the cache sub-system
* Jamfile: updating "refdoc" target, and adding "autohint" to the
list of modules to build. Both the autohinter and autofitter will be
built by default. But which one will be used is determined by
the content of "ftmodule.h"
* src/autofit/*: much updates, but the code is still buggy as hell.
Aargh..