Commit Graph

4 Commits

Author SHA1 Message Date
Nikhil Ramakrishnan f5a1a74c8d [woff2] Reconstruct transformed `glyf' table.
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'.
2019-07-13 03:14:17 +05:30
Nikhil Ramakrishnan 7bf104e759 [woff2] Copy un-transformed tables to sfnt stream.
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.
2019-07-06 18:05:18 +05:30
Nikhil Ramakrishnan 045c6b1162 [woff2] Get known tags from function.
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.
2019-06-30 20:01:20 +05:30
Nikhil Ramakrishnan f1083eae5e [sfnt] Add WOFF2 constants.
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.
2019-06-16 19:09:08 +05:30