2019-06-11 20:51:20 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* sfwoff2.h
|
|
|
|
*
|
|
|
|
* WOFFF2 format management (specification).
|
|
|
|
*
|
2021-01-17 07:18:48 +01:00
|
|
|
* Copyright (C) 2019-2021 by
|
2019-06-11 20:51:20 +02:00
|
|
|
* Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
|
|
|
|
*
|
|
|
|
* This file is part of the FreeType project, and may only be used,
|
|
|
|
* modified, and distributed under the terms of the FreeType project
|
|
|
|
* license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
|
|
* this file you indicate that you have read the license and
|
|
|
|
* understand and accept it fully.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SFWOFF2_H_
|
|
|
|
#define SFWOFF2_H_
|
|
|
|
|
|
|
|
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/internal/sfnt.h>
|
|
|
|
#include <freetype/internal/ftobjs.h>
|
2019-06-11 20:51:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
FT_BEGIN_HEADER
|
|
|
|
|
|
|
|
|
2019-08-27 10:08:01 +02:00
|
|
|
/* Leave the first byte open to store `flag_byte'. */
|
[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'.
2019-07-12 23:44:17 +02:00
|
|
|
#define WOFF2_FLAGS_TRANSFORM 1 << 8
|
|
|
|
|
|
|
|
#define WOFF2_SFNT_HEADER_SIZE 12
|
|
|
|
#define WOFF2_SFNT_ENTRY_SIZE 16
|
|
|
|
|
2019-08-27 10:08:01 +02:00
|
|
|
/* Suggested maximum size for output. */
|
[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'.
2019-07-12 23:44:17 +02:00
|
|
|
#define WOFF2_DEFAULT_MAX_SIZE 30 * 1024 * 1024
|
|
|
|
|
|
|
|
/* 98% of Google Fonts have no glyph above 5k bytes. */
|
|
|
|
#define WOFF2_DEFAULT_GLYPH_BUF 5120
|
|
|
|
|
2019-08-27 10:08:01 +02:00
|
|
|
/* Composite glyph flags. */
|
|
|
|
/* See `CompositeGlyph.java' in `sfntly' for full definitions. */
|
[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'.
2019-07-12 23:44:17 +02:00
|
|
|
#define FLAG_ARG_1_AND_2_ARE_WORDS 1 << 0
|
|
|
|
#define FLAG_WE_HAVE_A_SCALE 1 << 3
|
|
|
|
#define FLAG_MORE_COMPONENTS 1 << 5
|
|
|
|
#define FLAG_WE_HAVE_AN_X_AND_Y_SCALE 1 << 6
|
|
|
|
#define FLAG_WE_HAVE_A_TWO_BY_TWO 1 << 7
|
|
|
|
#define FLAG_WE_HAVE_INSTRUCTIONS 1 << 8
|
|
|
|
|
|
|
|
/* Simple glyph flags */
|
|
|
|
#define GLYF_ON_CURVE 1 << 0
|
|
|
|
#define GLYF_X_SHORT 1 << 1
|
|
|
|
#define GLYF_Y_SHORT 1 << 2
|
|
|
|
#define GLYF_REPEAT 1 << 3
|
|
|
|
#define GLYF_THIS_X_IS_SAME 1 << 4
|
|
|
|
#define GLYF_THIS_Y_IS_SAME 1 << 5
|
|
|
|
|
|
|
|
/* Other constants */
|
|
|
|
#define CONTOUR_OFFSET_END_POINT 10
|
|
|
|
|
|
|
|
|
2019-06-11 20:51:20 +02:00
|
|
|
FT_LOCAL( FT_Error )
|
|
|
|
woff2_open_font( FT_Stream stream,
|
2019-06-30 01:01:04 +02:00
|
|
|
TT_Face face,
|
2019-08-04 22:23:00 +02:00
|
|
|
FT_Int* face_index,
|
|
|
|
FT_Long* num_faces );
|
2019-06-11 20:51:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
FT_END_HEADER
|
|
|
|
|
|
|
|
#endif /* SFWOFF2_H_ */
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|