Reconstruct `glyf' table if it is transformed in the uncompressed table
stream. Also add necessary structures, macros and functions.
* include/freetype/internal/wofftypes.h (WOFF2_InfoRec,
WOFF2_SubstreamRec, WOFF2_PointRec): New structures.
* src/sfnt/sfwoff2.c (READ_255USHORT, READ_BASE128): Use `FT_SET_ERROR'
to set implicit `error' variable.
(WRITE_SHORT): New macro.
(N_CONTOUR_STREAM, N_POINTS_STREAM, FLAG_STREAM, GLYPH_STREAM,
COMPOSITE_STREAM, BBOX_STREAM, INSTRUCTION_STREAM): New macros to refer
to substreams of the transformed `glyf' tables.
(Read255UShort, ReadBase128): Return errors set by `FT_READ_XXX' macros.
(with_sign, safe_int_addition): New functions to add sign to values
based on a flag and perform safe addition respectively.
(triplet_decode): Decode variable-length (flag, xCoordinate, yCoordinate)
triplet for a simple glyph. See
https://www.w3.org/TR/WOFF2/#triplet_decoding
(store_points): Store decoded points in the glyph buffer.
(compute_bbox): Derive bounding box for a glyph by computing the minimum
and maximum x and y coordinates in the outline.
(reconstruct_glyf): Main routine to reconstruct transformed `glyf' table.
(reconstruct_font): Call `reconstruct_glyf'.
* src/sfnt/sfwoff2.h: Add required constants.
* src/sfnt/woff2tags.h: Move out constants to `sfwoff2.h'.
Copy un-transformed tables to the sfnt stream.
* src/sfnt/sfwoff2.c: (WRITE_SFNT_BUF): New macro.
(write_buf): New function. Extend memory of `dst' buffer and copy bytes
from `src'.
(compute_ULong_sum): New function. Calculate checksum of table.
(woff2_uncompress): Change `FT_Byte* sfnt' to `FT_Byte** sfnt_bytes'.
This has been done because we reallocate memory to `sfnt' multiple
times, which may change the pointer value of `sfnt'. This new pointer
must be propogated back to the caller. Same reason for using a double
pointer in `write_buf'.
* src/sfnt/woff2tags.h: Define default max size to prevent overflow.
Change `KnownTags' to a function (`woff2_known_tags'). This avoids
introducing a global constant array. This function returns the specified
index without *any* checks. The caller must ensure that `index' is
within array limits.
* src/sfnt/sfwoff2.c (woff2_open_font): Change `KnownTags[...]' notation
to `woff2_known_tags( ... )'.
* src/sfnt/woff2tags.c: Perform changes.
* src/sfnt/woff2tags.h: Update definitions.
Add constants required for WOFF2, and known table tags as defined in the
specification. See
https://www.w3.org/TR/WOFF2/#table_dir_format
for details.
* src/sfnt/woff2tags.c, src/sfnt/woff2tags.h: New files.