diff options
author | Nikhil Ramakrishnan <ramakrishnan.nikhil@gmail.com> | 2019-07-13 03:14:17 +0530 |
---|---|---|
committer | Werner Lemberg <wl@gnu.org> | 2019-08-27 09:39:18 +0200 |
commit | e3953e5410eaeec7ae49dbda26be6e4b1ca5d26c (patch) | |
tree | 1ac228293c2e369407ac25d5c3a57b74b6eb2bca /include | |
parent | 81cf5326d59282265ccc0911050005a4b5d20a99 (diff) | |
download | freetype2-e3953e5410eaeec7ae49dbda26be6e4b1ca5d26c.tar.gz |
[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.
(WOFF2_TableRec): s/OrigLength/dst_length/.
* 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, compute_bbox, composteGlyph_size, reconstruct_glyf):
New functions.
(reconstruct_font): Call `reconstruct_glyf'.
* src/sfnt/sfwoff2.h: Add required constants.
* src/sfnt/woff2tags.h: Move out constants to `sfwoff2.h'.
Diffstat (limited to 'include')
-rw-r--r-- | include/freetype/internal/wofftypes.h | 84 |
1 files changed, 83 insertions, 1 deletions
diff --git a/include/freetype/internal/wofftypes.h b/include/freetype/internal/wofftypes.h index 205e64d7d..2035a251d 100644 --- a/include/freetype/internal/wofftypes.h +++ b/include/freetype/internal/wofftypes.h @@ -185,6 +185,34 @@ FT_BEGIN_HEADER /************************************************************************** * * @struct: + * WOFF2_InfoRec + * + * @description: + * Metadata for WOFF2 font that may be required for reconstruction of + * sfnt tables. + * + * @fields: + * num_glyphs :: + * Number of glyphs in the font. + * + * num_hmetrics :: + * `numberOfHMetrics' field in the `hhea' table. + * + * x_mins :: + * `xMin' values of glyph bounding box. + */ + typedef struct WOFF2_InfoRec_ + { + FT_UShort num_glyphs; + FT_UShort num_hmetrics; + FT_Short* x_mins; + + } WOFF2_InfoRec, *WOFF2_Info; + + + /************************************************************************** + * + * @struct: * WOFF2_TableRec * * @description: @@ -199,7 +227,7 @@ FT_BEGIN_HEADER { FT_Byte FlagByte; /* table type and flags */ FT_ULong Tag; /* table file offset */ - FT_ULong OrigLength; /* uncompressed table length */ + FT_ULong dst_length; /* uncompressed table length */ FT_ULong TransformLength; /* transformed length */ FT_ULong flags; /* calculated flags */ @@ -211,6 +239,60 @@ FT_BEGIN_HEADER } WOFF2_TableRec, *WOFF2_Table; + /************************************************************************** + * + * @struct: + * WOFF2_SubstreamRec + * + * @description: + * This structure stores information about a substream in the transformed + * `glyf' table in a WOFF2 stream. + * + * @fields: + * start :: + * Beginning of the substream relative to uncompressed table stream. + * + * offset :: + * Offset of the substream relative to uncompressed table stream. + * + * size :: + * Size of the substream. + */ + typedef struct WOFF2_SubstreamRec_ + { + FT_ULong start; + FT_ULong offset; + FT_ULong size; + } WOFF2_SubstreamRec, *WOFF2_Substream; + + + /************************************************************************** + * + * @struct: + * WOFF2_PointRec + * + * @description: + * This structure stores information about a point in the transformed + * `glyf' table in a WOFF2 stream. + * + * @fields: + * x :: + * x-coordinate. + * + * y :: + * y-coordinate. + * + * on_curve :: + * on-curve. + */ + typedef struct WOFF2_PointRec_ + { + FT_Int x; + FT_Int y; + FT_Bool on_curve; + } WOFF2_PointRec, *WOFF2_Point; + + FT_END_HEADER #endif /* WOFFTYPES_H_ */ |