Check parameters of `FT_Outline_New'.
Problem reported by Robin Watts <robin.watts@artifex.com>.

* src/base/ftoutln.c (FT_Outline_New_Internal): Ensure that
`numContours' and `numPoints' fit into FT_Outline's `n_points' and
`n_contours', respectively.
* src/tools/cordic.py: Bring up to date with trigonometric core.
Formatting, minor internal documentation improvement.
[type1] Fix handling of /FontBBox in MM fonts.
Problem reported by Del Merritt <del@alum.mit.edu>

If we have

  /FontBBox { { 11 12 13 14 15 16 17 18 }
              { 21 22 23 24 25 26 27 28 }
              { 31 32 33 34 35 36 37 38 }
              { 41 42 43 44 45 46 47 48 } }

in the /Blend dictionary,  then the first BBox is { 11 21 31 41 },
the second { 12 22 32 42 }, etc.

* include/freetype/internal/psaux.h (T1_FieldType): Add
`T1_FIELD_TYPE_MM_BBOX' (for temporary use).

* src/psaux/psobjs.c (ps_parser_load_field) <T1_FIELD_TYPE_MM_BBOX>:
Implement it.
* src/truetype/ttgload.c (tt_loader_init): Add more tracing.
* src/pshinter/pshalgo.h: Remove unused code.
[base] Reduce trigonometric algorithms.

After we get within 45 degrees by means of true 90-degree rotations,
we can remove initial 45-degree CORDIC iteration and start from
atan(1/2) pseudorotation, reducing expansion factor thereby.

* src/base/fttrigon.c (FT_TRIG_SCALE, FT_TRIG_COSCALE): Update macros.
(ft_trig_pseudo_rotate, ft_trig_pseudo_polarize): Update.

* src/tools/cordic.py: Bring up to date with trigonometric core.

* docs/CHANGES: Old typo.
[base] Use rounding in CORDIC iterations.

* src/base/fttrigon.c (ft_trig_pseudo_rotate,
ft_trig_pseudo_polarize): Improve accuracy by rounding.
[base] Clean up trigonometric core.

* src/base/fttrigon.c: Document the algorithm in a large comment.
(FT_TRIG_COSCALE): Remove macro.
(FT_Tan: Use `FT_TRIG_SCALE' instead.
(FT_Cos, FT_Vector_Unit): Ditto and round the return values.
[base, pshinter] Use FT_ABS, FT_MIN, and FT_MAX for readability.

* src/base/ftbbox.c: Updated.
* src/base/ftobjs.c: Updated.
* src/base/fttrigon.c: Updated.
* src/pshinter/pshalgo.c: Updated.
* src/pshinter/pshrec.c: Updated.
Minor comment improvements.
[base] Update the overflow protection bit.

The recent optimizations of CORDIC iterations drastically reduce
the expansion factor. The vector components with MSB of 29 are now
safe from overflow.

* src/base/fttrigon.c (FT_TRIG_SAFE_MSB): New macro.
(ft_trig_prenorm): Use it and remove dead code.
Typos, whitespace.
Disable FT_CONFIG_OPTION_OLD_INTERNALS.

After the next release we are going to remove the code completely.

* devel/ftoption.h, include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_OLD_INTERNALS): Comment out.
* docs/CHANGES: Document it.
Call it fixed-point.
[truetype] Kill very old vector normalization hacks.

Back in the days, vector length calculations were not very accurate
and the vector normalization function, Normalize, had to meticulously
correct the errors for long vectors [commit b7ef2b096867]. It was no
longer necessary after accurate CORDIC algorithms were adopted, but
the code remained. It is time to kill it.

* src/truetype/ttinterp.c (Normalize): Remove error compensation.
(TT_VecLen): Remove any mention of old less accurate implementation.
[truetype] Improve accuracy of normalization of short vectors.

Unit vector components are stored as 2.14 fixed-point numbers. In
order to calculate all 14 bits accurately, a short vector to be
normalized has to be upscaled to at least 14 bits before its length
is calculated. This has been safe since accurate CORDIC algorithms
were adopted.

* src/truetype/ttinterp.c (Normalize): Scale short vectors by 0x4000.
[truetype] Improve sub-pixel code.

This patches fixes many issues with the ttsubpix implementation.

1. Data tables are defined, instead of declared, in the header, and
   thus copied into each source file that includes it.

2. These tables were defined as global, mutable, visible variables,
   and thus costing private RAM to every process that loads the
   library (> 50 KB / process, this is huge!).

   Additionally, this also made the library export the symbols
   completely needlessly.

3. Missing `sph_' and `SPH_' prefixes to some of the definitions.

Note that this doesn't try to fix the incredibly inefficient storage
format for the data tables used by the code.  This one will require
another pass in the future.

* src/truetype/ttinterp.h (MAX_NAME_SIZE, MAX_CLASS_MEMBERS):
Renamed to...
(SPH_MAX_NAME_SIZE, SPH_MAX_CLASS_MEMBERS): This.
Update all users.

(SPH_TweakRule, SPH_ScaleRule): Decorate with `const' where
appropriate.

(Font_Class): Rename to...
(SPH_Font_Class): This.  Decorate with `const' where appropriate.

* src/truetype/ttsubpix.h (scale_test_tweak, sph_test_tweak):
Decorate arguments with `const' where appropriate.

Move font tweaking tables to...

* src/truetype/ttsubpic.c: This file and decorate them with `static'
and `const' where appropriate.

(X_SCALING_Rules, X_SCALING_RULES_SIZE): Renamed to...
(spu_X_SCALING_Rules, SPH_X_SCALING_RULES_SIZE): This.
Update all users.
[sfnt] Fix optimized sbit loader.

It was not taking bit_depth into consideration when blitting!

* src/sfnt/ttsbit0.c (tt_sbit_decoder_load_byte_aligned,
* tt_sbit_decoder_load_bit_aligned): Handle bit
depth.
Minor.