* src/base/fthash.c (hash_num_lookup, hash_num_compare): New
functions.
(ft_hash_init): Add argument to select between number and string
hashing.
(ft_hash_num_insert, ft_hash_num_lookup): New functions.
* include/freetype/internal/fthash.h: Updated.
* src/bdf/bdflib.c (_bdf_parse_start): Updated.
* include/freetype/internal/fthash.c (FT_Hash_LookupFunc,
FT_Hash_CompareFunc, FT_Hash_FreeFunc): New typedefs.
(FT_HashRec): Add `lookup', `compare', and `free' fields.
* src/base/fthash.c (hash_str_lookup, hash_str_compare,
hash_str_free): New functions.
(ft_hash_init): Set function pointers.
(hash_bucket, ft_hash_free): Use them.
We want to support both an integer and a string key later on.
* include/freetype/internal/fthash.h (FT_Hashkey): New union.
(FT_HashnodeRec): Updated.
(ft_hash_insert, ft_hash_lookup): Renamed to ...
(ft_hash_str_insert, ft_hash_str_lookup): ... this.
* src/base/fthash.c (hash_bucket): Updated.
(ft_hash_insert, ft_hash_lookup): Renamed to ...
(hash_insert, hash_lookup): ... this.
(ft_hash_str_insert, ft_hash_str_lookup): New wrapper functions.
* src/bdf/bdflib.c: Updated.
* src/base/ftobjs.c (open_face_PS_from_sfnt_stream):
`ft_lookup_PS_in_sfnt_stream' returns offset and and length from
user supplied data. Use of this these values must be checked.
This does the same as `FT_LCD_FILTER_LEGACY'.
See
https://bugs.freedesktop.org/show_bug.cgi?id=92981
for the reasoning.
* include/freetype/ftlcdfil.h (FT_LcdFilter): New value
`FT_LCD_FILTER_LEGACY1'.
* src/base/ftlcdfil.c (FT_Library_SetLcdFilter): Use it.
Both the native CFF hinter and the auto-hinter now have a very
similar rendering style.
* include/freetype/freetype.h: Mention that FT_LOAD_TARGET_LIGHT no
longer implies FT_LOAD_FORCE_AUTOHINT.
* include/freetype/ftmodapi.h (FT_MODULE_DRIVER_HINTS_LIGHTLY): New
macro.
* include/freetype/internal/ftobjs.h (FT_DRIVER_HINTS_LIGHTLY): New
macro.
* src/cff/cffdrivr.c (cff_driver_class): Use it.
* src/base/ftobjs.c (FT_Load_Glyph): Update auto-hinter selection
logic.
open_face_from_buffer() frees passed buffer if valid font
is not found. But if copying to the buffer is failed,
the allocated buffer should be freed within the caller.
* src/base/ftobjs.c (open_face_PS_from_sfnt_stream): Free
the buffer `sfnt_ps' if an error caused before calling
open_face_from_buffer().
(Mac_Read_sfnt_Resource): Free the buffer `sfnt_data' if
an error caused before calling open_face_from_buffer();
* src/base/ftobjs.c (FT_Get_Char_Index): Don't return out-of-bounds
glyph indices.
(FT_Get_First_Char): Updated.
* src/sfnt/ttcmap.c (tt_cmap6_char_next): Don't return character
codes greater than 0xFFFF.
(tt_cmap8_char_index): Avoid integer overflow in computation of
glyph index.
(tt_cmap8_char_next): Avoid integer overflows in computation of
both next character code and glyph index.
(tt_cmap10_char_index): Fix unsigned integer logic.
(tt_cmap10_char_next): Avoid integer overflow in computation of
next character code.
(tt_cmap12_next): Avoid integer overflows in computation of both
next character code and glyph index.
(tt_cmap12_char_map_binary): Ditto.
(tt_cmap12_char_next): Simplify.
(tt_cmap13_char_map_binary): Avoid integer overflow in computation
of next character code.
(tt_cmap13_char_next): Simplify.
* src/base/ftbase.h (FT_MAC_RFORK_MAX_LEN): Maximum length
of the resource fork for Mac OS. The resource fork larger
than 16 MB can be written but could not be handled
correctly, at least in Carbon routine.
See https://support.microsoft.com/en-us/kb/130437
* src/base/ftobjs.c (Mac_Read_POST_Resource): No need `0x'
for `%p' formatter.
* src/base/ftbase.c (Mac_Read_POST_Resource): Check the
fragment and total size of the concatenated POST resource
before buffer allocation.
(Mac_Read_sfnt_Resource): Check the declared size of
sfnt resource before buffer allocation.
* src/base/ftmac.c (read_lwfn, FT_New_Face_From_SFNT):
Check the total resource size before buffer allocation.
For functions querying a face, bits 16-30 of the face index can hold
the named instance index if we have a GX font. The indices start
with value 1; value 0 indicates font access without GX variation
data.
* include/freetype/freetype.h (FT_FaceRec): Update documentation.
* include/freetype/internal/sfnt.h: Ditto.
* src/sfnt/sfobjs.c (sfnt_init_face)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Get number of named instances and
do argument checks.
(sfnt_load_face): Updated.
* src/truetype/ttobjs.c (tt_face_init)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Use named instance, overwriting
the style name.
* src/base/ftobjs.c (open_face_from_buffer,
open_face_PS_from_sfnt_stream): Updated.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Updated.
* src/cff/cffload.c (cff_font_load): Updated.
* src/cff/cffobjs.c (cff_face_init): Make function exit early for
pure CFF fonts if `font_index < 0'.
Updated.
* src/cid/cidobjs.c (cid_face_init): Updated.
* src/pcf/pcfdrivr.c (PCF_Face_Init): Updated.
* src/pfr/pfrobjs.c (pfr_face_init): Updated.
* src/type1/t1objs.c (T1_Face_Init): Updated.
* src/type42/t42objs.c (T42_Face_Init): Updated.
* src/winfonts/winfnt.c (fnt_face_get_dll_font, FNT_Face_Init):
Updated.
* docs/CHANGES: Updated.
Remove casting from `FT_Long' to `FT_Int' that might change the sign
of the return value and make it faster too.
* src/base/ftcalc.c (ft_corner_orientation): On 32-bit systems, stay
with 32-bit arithmetic when safe. Use plain math on 64-bit systems.
* src/pshinter/pshalgo.c: Remove old unused code.
* src/base/ftrfork.c (FT_Raccess_Get_HeaderInfo): Only accept
positive values from header.
Check overflow.
* src/base/ftoutln.c (SCALED): Correctly handle left-shift of
negative values.
* src/bdf/bdf.h (_bdf_glyph_modified, _bdf_set_glyph_modified,
_bdf_clear_glyph_modified): Use unsigned long constant.
* src/bdf/bdfdrivr.c (BDF_Size_Select, BDF_Glyph_Load): Don't
left-shift values that can be negative.
* src/pcf/pcfdrivr.c (PCF_Size_Select, PCF_Glyph_Load): Don't
left-shift values that can be negative.
* src/raster/ftraster.c (SCALED): Correctly handle left-shift of
negative values.
* src/sfnt/ttsbit.c (tt_face_load_strike_metrics): Don't left-shift
values that can be negative.
* src/truetype/ttgload.c (TT_Load_Composite_Glyph,
compute_glyph_metrics, load_sbit_image): Don't left-shift values
that can be negative.
See
http://lists.nongnu.org/archive/html/freetype-devel/2015-07/msg00008.html
for a rationale.
* src/autofit/afpic.h, src/base/basepic.h, src/cff/cffpic.h,
src/pshinter/pshpic.h, src/psnames/pspic.h, src/raster/rastpic.h,
src/sfnt/sfntpic.h, src/smooth/ftspic.h, src/truetype/ttpic.h
(FT_BEGIN_HEADER, FT_END_HEADER): Move macro calls to not enclose
header files that contain FT_{BEGIN,END}_HEADER macros by
themselves.
* src/autofit/aftypes.h [FT_DEBUG_AUTOFIT]: Include
FT_CONFIG_STANDARD_LIBRARY_H earlier.
* src/truetype/ttpic.h: Include FT_INTERNL_PIC_H.
The function uses Newton's iterations instead of dividing vector
components by its length, which needs a square root. This is,
literally, a bit less accurate but a lot faster.
* src/base/ftcalc.c (FT_Vector_NormLen): New function.