2000-12-08 03:42:29 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* cffparse.h */
|
|
|
|
/* */
|
|
|
|
/* CFF token stream parser (specification) */
|
|
|
|
/* */
|
2017-01-04 20:16:34 +01:00
|
|
|
/* Copyright 1996-2017 by */
|
2000-12-08 03:42:29 +01:00
|
|
|
/* 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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2016-01-12 21:37:13 +01:00
|
|
|
#ifndef CFFPARSE_H_
|
|
|
|
#define CFFPARSE_H_
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
#include <ft2build.h>
|
* include/freetype/internal/bdftypes.h: removed obsolete header
* include/freetype/internal/cfftypes.h, src/cff/cfftypes.h,
src/cff/cffload.h, src/cff/cffobjs.h, src/cff/cffparse.h,
include/freetype/internal/services/svbdf.h: moving "cfftypes.h" from
'include/freetype/internal' to 'src/cff' since no other modules needs
to known about these types
* include/freetype/internal/t42types.h,
include/freetype/internal/internal.h, src/type42/t42objs.h,
src/type42/t42drivr.c, src/type42/t42types.h: moving "t42types.h" from
'include/freetype/internal' to 'src/type42' since no other modules needs
to known about these types
* src/gzip/infblock.c: removing compiler warning
* include/freetype/internal/services/svpsinfo.h,
include/freetype/internal/ftserv.h, src/cff/cffdrivr.c,
src/cid/ciddrivr.c, src/type1/t1driver.c, src/type42/t42drivr.c,
src/base/fttype1.c: migrating to FT_SERVICE_ID_POSTSCRIPT_INFO defined
in "svpsinfo.h", removing some sad hacks.
2003-10-29 22:43:52 +01:00
|
|
|
#include "cfftypes.h"
|
2000-12-08 03:42:29 +01:00
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
FT_BEGIN_HEADER
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
/* CFF uses constant parser stack size; */
|
|
|
|
/* CFF2 can increase from default 193 */
|
2000-12-08 03:42:29 +01:00
|
|
|
#define CFF_MAX_STACK_DEPTH 96
|
2017-03-30 21:07:17 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* There are plans to remove the `maxstack' operator in a forthcoming
|
|
|
|
* revision of the CFF2 specification, increasing the (then static) stack
|
|
|
|
* size to 513. By making the default stack size equal to the maximum
|
|
|
|
* stack size, the operator is essentially disabled, which has the
|
|
|
|
* desired effect in FreeType.
|
|
|
|
*/
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
#define CFF2_MAX_STACK 513
|
2017-03-30 21:07:17 +02:00
|
|
|
#define CFF2_DEFAULT_STACK 513
|
[cff] Implement CFF2 support (1/2).
This commit does not contain the blend code for font variation
support, which follows in another commit.
You should ignore whitespace while inspecting this commit.
* include/freetype/internal/tttypes.h (TT_Face): Add `isCFF2'
member.
* src/cff/cf2font.h (CF2_Font): Add `isCFF2' member.
* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Handle `isCFF2'
flag.
(cf2_getMaxstack): New function.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c (cf2_escRESERVED_38): New enum.
(cf2_interpT2CharString): Handle CFF2 differences.
Add tracing message for errors.
* src/cff/cffdrivr.c (cff_get_glyph_name, cff_get_name_index):
Update for CFF2.
* src/cff/cffload.c (FT_FIXED_ONE): New macro.
(cff_index_init, cff_index_load_offsets, cff_index_access_element,
cff_index_get_name, cff_ft_select_get, cff_load_private_dict,
cff_subfont_load, cff_font_load): Handle CFF2.
* src/cff/cffload.h: Updated.
* src/cff/cffobjs.c (cff_face_init): Handle CFF2.
* src/cff/cffparse.c (cff_parse_maxstack): New function.
(CFFCODE_TOPDICT, CFFCODE_PRIVATE): Removed
* src/cff/cffparse.h (CFF2_MAX_STACK, CFF2_DEFAULT_STACK): New
macros.
(CFF2_CODE_TOPDICT, CFF2_CODE_FONTDICT, CFF2_CODE_PRIVATE): New
macros.
* src/cff/cfftoken.h: Add fields for CFF2 dictionaries (but no blend
stuff).
* src/cff/cfftypes.h (CFF_Index): Add `hdr_size' field.
(CFF_FontRecDict): Add `maxstack' field.
(CFF_Private): Add `subfont' field.
(CFF_Font): Add `top_dict_length' and `cff2' fields.
* src/sfnt/sfobjs.c (sfnt_load_face): Handle `CFF2' table.
2016-12-15 20:27:47 +01:00
|
|
|
|
|
|
|
#define CFF_CODE_TOPDICT 0x1000
|
|
|
|
#define CFF_CODE_PRIVATE 0x2000
|
|
|
|
#define CFF2_CODE_TOPDICT 0x3000
|
|
|
|
#define CFF2_CODE_FONTDICT 0x4000
|
|
|
|
#define CFF2_CODE_PRIVATE 0x5000
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2002-03-20 10:44:20 +01:00
|
|
|
typedef struct CFF_ParserRec_
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2016-02-15 20:41:58 +01:00
|
|
|
FT_Library library;
|
|
|
|
FT_Byte* start;
|
|
|
|
FT_Byte* limit;
|
|
|
|
FT_Byte* cursor;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2016-12-15 11:22:15 +01:00
|
|
|
FT_Byte** stack;
|
2016-02-15 20:41:58 +01:00
|
|
|
FT_Byte** top;
|
2016-12-15 11:22:15 +01:00
|
|
|
FT_UInt stackSize; /* allocated size */
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2016-02-15 20:41:58 +01:00
|
|
|
FT_UInt object_code;
|
|
|
|
void* object;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2016-02-15 20:41:58 +01:00
|
|
|
FT_UShort num_designs; /* a copy of `CFF_FontRecDict->num_designs' */
|
|
|
|
FT_UShort num_axes; /* a copy of `CFF_FontRecDict->num_axes' */
|
2016-02-14 16:03:15 +01:00
|
|
|
|
2002-03-20 10:44:20 +01:00
|
|
|
} CFF_ParserRec, *CFF_Parser;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2016-12-15 12:17:22 +01:00
|
|
|
FT_LOCAL( FT_Long )
|
|
|
|
cff_parse_num( CFF_Parser parser,
|
|
|
|
FT_Byte** d );
|
|
|
|
|
2016-12-15 11:22:15 +01:00
|
|
|
FT_LOCAL( FT_Error )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_parser_init( CFF_Parser parser,
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_UInt code,
|
2009-04-05 16:34:40 +02:00
|
|
|
void* object,
|
2016-02-14 16:03:15 +01:00
|
|
|
FT_Library library,
|
2016-12-15 11:22:15 +01:00
|
|
|
FT_UInt stackSize,
|
2016-02-15 20:41:58 +01:00
|
|
|
FT_UShort num_designs,
|
|
|
|
FT_UShort num_axes );
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2016-12-15 11:22:15 +01:00
|
|
|
FT_LOCAL( void )
|
|
|
|
cff_parser_done( CFF_Parser parser );
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL( FT_Error )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_parser_run( CFF_Parser parser,
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_Byte* start,
|
|
|
|
FT_Byte* limit );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2009-04-05 16:34:40 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
cff_kind_none = 0,
|
|
|
|
cff_kind_num,
|
|
|
|
cff_kind_fixed,
|
|
|
|
cff_kind_fixed_thousand,
|
|
|
|
cff_kind_string,
|
|
|
|
cff_kind_bool,
|
|
|
|
cff_kind_delta,
|
|
|
|
cff_kind_callback,
|
[cff] Implement CFF2 support (2/2).
The font variation code. All parts dependent on the GX code in the
`truetype' module are guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
In other words, you can still compile the `cff' module without
defining TT_CONFIG_OPTION_GX_VAR_SUPPORT (which brings you CFF2
support without font variation).
* src/cff/cf2font.c (cf2_font_setup): Add support for font
variation.
* src/cff/cf2font.h (CF2_Font): Add fields for variation data.
* src/cff/cf2ft.c (cf2_free_instance): Free blend data.
(cf2_getVStore, cf2_getNormalizedVector): New functions.
* src/cff/cf2ft.h: Updated.
* src/cff/cf2intrp.c: Include `cffload.h'.
(cf2_cmdRESERVED_15, cf2_cmdRESERVED_16): Replace with...
(cf2_cmdVSINDEX, cf2_cmdBLEND): ... this new enum values.
(cf2_doBlend): New function.
(cf2_interpT2CharString): Handle `vsindex' and `blend' opcodes.
* src/cff/cffload.c (FT_fdot14ToFixed): New macro.
(cff_vstore_done, cff_vstore_load): New functions.
(cff_blend_clear, cff_blend_doBlend, cff_blend_build_vector,
cff_blend_check_vector): New functions.
(cff_load_private_dict): Add arguments for blend vector.
Handle blend data.
(cff_subfont_load, cff_subfont_done): Updated.
(cff_font_load): Handle CFF2 variation store data.
(cff_font_done): Updated.
* src/cff/cffload.h: Include `cffparse.h'.
Updated.
* src/cff/cffobjs.c (cff_face_done): Updated.
* src/cff/cffparse.c: Include `cffload.h'.
(cff_parse_num): Handle internal value 255.
(cff_parse_vsindex, cff_parse_blend): New functions.
(CFF_FIELD_BLEND): New macro.
(cff_parser_run): Updated.
* src/cff/cffparse.h (cff_kind_blend): New enum value.
* src/cff/cfftoken.h: Handle `vstore', `vsindex', and `blend'
dictionary values.
* src/cff/cfftypes.h (CFF_VarData, CFF_AxisCoords, CFF_VarRegion,
CFF_VStore, CFF_Blend): New structures.
(CFF_FontRecDict): Add `vstore_offset' field.
(CFF_Private): Add `vsindex' field.
(CFF_SubFont): Add fields for blend data.
(CFF_Font): Add `vstore' field.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): `CFF2' is equal to `gvar',
since glyph variation data is directly embedded.
(TT_Set_MM_Blend): Don't load `gvar' table for CFF2 fonts.
2016-12-15 21:56:44 +01:00
|
|
|
cff_kind_blend,
|
2009-04-05 16:34:40 +02:00
|
|
|
|
|
|
|
cff_kind_max /* do not remove */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* now generate handlers for the most simple fields */
|
|
|
|
typedef FT_Error (*CFF_Field_Reader)( CFF_Parser parser );
|
|
|
|
|
|
|
|
typedef struct CFF_Field_Handler_
|
|
|
|
{
|
|
|
|
int kind;
|
|
|
|
int code;
|
|
|
|
FT_UInt offset;
|
|
|
|
FT_Byte size;
|
|
|
|
CFF_Field_Reader reader;
|
|
|
|
FT_UInt array_max;
|
|
|
|
FT_UInt count_offset;
|
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
|
|
|
const char* id;
|
|
|
|
#endif
|
|
|
|
|
2009-04-05 16:34:40 +02:00
|
|
|
} CFF_Field_Handler;
|
|
|
|
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
FT_END_HEADER
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2016-01-12 21:37:13 +01:00
|
|
|
#endif /* CFFPARSE_H_ */
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* END */
|