2018-06-03 09:01:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* psfont.h
|
|
|
|
*
|
|
|
|
* Adobe's code for font instances (specification).
|
|
|
|
*
|
|
|
|
* Copyright 2007-2013 Adobe Systems Incorporated.
|
|
|
|
*
|
|
|
|
* This software, and all works of authorship, whether in source or
|
|
|
|
* object code form as indicated by the copyright notice(s) included
|
|
|
|
* herein (collectively, the "Work") is made available, and may only be
|
|
|
|
* used, modified, and distributed under the FreeType Project License,
|
|
|
|
* LICENSE.TXT. Additionally, subject to the terms and conditions of the
|
|
|
|
* FreeType Project License, each contributor to the Work hereby grants
|
|
|
|
* to any individual or legal entity exercising permissions granted by
|
|
|
|
* the FreeType Project License and this section (hereafter, "You" or
|
|
|
|
* "Your") a perpetual, worldwide, non-exclusive, no-charge,
|
|
|
|
* royalty-free, irrevocable (except as stated in this section) patent
|
|
|
|
* license to make, have made, use, offer to sell, sell, import, and
|
|
|
|
* otherwise transfer the Work, where such license applies only to those
|
|
|
|
* patent claims licensable by such contributor that are necessarily
|
|
|
|
* infringed by their contribution(s) alone or by combination of their
|
|
|
|
* contribution(s) with the Work to which such contribution(s) was
|
|
|
|
* submitted. If You institute patent litigation against any entity
|
|
|
|
* (including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
|
|
* the Work or a contribution incorporated within the Work constitutes
|
|
|
|
* direct or contributory patent infringement, then any patent licenses
|
|
|
|
* granted to You under this License for that Work shall terminate as of
|
|
|
|
* the date such litigation is filed.
|
|
|
|
*
|
|
|
|
* By using, modifying, or distributing the Work you indicate that you
|
|
|
|
* have read and understood the terms and conditions of the
|
|
|
|
* FreeType Project License as well as those provided in this section,
|
|
|
|
* and you accept them fully.
|
|
|
|
*
|
|
|
|
*/
|
2013-04-13 15:02:31 +02:00
|
|
|
|
|
|
|
|
2017-10-01 01:39:27 +02:00
|
|
|
#ifndef PSFONT_H_
|
|
|
|
#define PSFONT_H_
|
2013-04-13 15:02:31 +02:00
|
|
|
|
|
|
|
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/internal/services/svcfftl.h>
|
2017-09-24 22:20:38 +02:00
|
|
|
|
2017-09-24 22:40:07 +02:00
|
|
|
#include "psft.h"
|
|
|
|
#include "psblues.h"
|
2013-04-13 15:02:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
FT_BEGIN_HEADER
|
|
|
|
|
|
|
|
|
|
|
|
#define CF2_OPERAND_STACK_SIZE 48
|
2015-03-29 14:47:49 +02:00
|
|
|
#define CF2_MAX_SUBR 16 /* maximum subroutine nesting; */
|
|
|
|
/* only 10 are allowed but there exist */
|
|
|
|
/* fonts like `HiraKakuProN-W3.ttf' */
|
|
|
|
/* (Hiragino Kaku Gothic ProN W3; */
|
|
|
|
/* 8.2d6e1; 2014-12-19) that exceed */
|
|
|
|
/* this limit */
|
[cff] Implement missing operators in new engine (except `random').
* src/cff/cf2font.h (CF2_STORAGE_SIZE): New macro.
* src/cff/cf2intrp.c (cf2_interpT2CharString): Implement the
following operators: abs, add, and, div, drop, dup, eq, exch, get,
ifelse, index, mul, neg, not, or, put, roll, sqrt, sub.
* src/cff/cf2stack.h, src/cff/cf2stack.c (cf2_stack_roll): New
auxiliary function for `roll' operator.
2016-02-07 11:39:54 +01:00
|
|
|
#define CF2_STORAGE_SIZE 32
|
2013-04-13 15:02:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* typedef is in `cf2glue.h' */
|
|
|
|
struct CF2_FontRec_
|
|
|
|
{
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_Error error; /* shared error for this instance */
|
|
|
|
|
2017-09-25 06:15:46 +02:00
|
|
|
FT_Bool isT1;
|
[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
|
|
|
FT_Bool isCFF2;
|
2013-04-13 15:02:31 +02:00
|
|
|
CF2_RenderingFlags renderingFlags;
|
|
|
|
|
|
|
|
/* variables that depend on Transform: */
|
|
|
|
/* the following have zero translation; */
|
|
|
|
/* inner * outer = font * original */
|
|
|
|
|
|
|
|
CF2_Matrix currentTransform; /* original client matrix */
|
|
|
|
CF2_Matrix innerTransform; /* for hinting; erect, scaled */
|
|
|
|
CF2_Matrix outerTransform; /* post hinting; includes rotations */
|
|
|
|
CF2_Fixed ppem; /* transform-dependent */
|
|
|
|
|
[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
|
|
|
/* variation data */
|
|
|
|
CFF_BlendRec blend; /* cached charstring blend vector */
|
|
|
|
CF2_UInt vsindex; /* current vsindex */
|
|
|
|
CF2_UInt lenNDV; /* current length NDV or zero */
|
|
|
|
FT_Fixed* NDV; /* ptr to current NDV or NULL */
|
|
|
|
|
2013-04-13 15:02:31 +02:00
|
|
|
CF2_Int unitsPerEm;
|
|
|
|
|
|
|
|
CF2_Fixed syntheticEmboldeningAmountX; /* character space units */
|
|
|
|
CF2_Fixed syntheticEmboldeningAmountY; /* character space units */
|
|
|
|
|
|
|
|
/* FreeType related members */
|
|
|
|
CF2_OutlineRec outline; /* freetype glyph outline functions */
|
2017-09-25 06:10:20 +02:00
|
|
|
PS_Decoder* decoder;
|
2013-04-13 15:02:31 +02:00
|
|
|
CFF_SubFont lastSubfont; /* FreeType parsed data; */
|
|
|
|
/* top font or subfont */
|
|
|
|
|
|
|
|
/* these flags can vary from one call to the next */
|
|
|
|
FT_Bool hinted;
|
|
|
|
FT_Bool darkened; /* true if stemDarkened or synthetic bold */
|
|
|
|
/* i.e. darkenX != 0 || darkenY != 0 */
|
|
|
|
FT_Bool stemDarkened;
|
|
|
|
|
2013-06-25 23:28:02 +02:00
|
|
|
FT_Int darkenParams[8]; /* 1000 unit character space */
|
|
|
|
|
2013-04-13 15:02:31 +02:00
|
|
|
/* variables that depend on both FontDict and Transform */
|
|
|
|
CF2_Fixed stdVW; /* in character space; depends on dict entry */
|
|
|
|
CF2_Fixed stdHW; /* in character space; depends on dict entry */
|
|
|
|
CF2_Fixed darkenX; /* character space units */
|
|
|
|
CF2_Fixed darkenY; /* depends on transform */
|
|
|
|
/* and private dict (StdVW) */
|
|
|
|
FT_Bool reverseWinding; /* darken assuming */
|
|
|
|
/* counterclockwise winding */
|
|
|
|
|
|
|
|
CF2_BluesRec blues; /* computed zone data */
|
2017-09-24 22:20:38 +02:00
|
|
|
|
2017-10-01 01:39:27 +02:00
|
|
|
FT_Service_CFFLoad cffload; /* pointer to cff functions */
|
2013-04-13 15:02:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
FT_LOCAL( FT_Error )
|
2013-06-07 17:10:21 +02:00
|
|
|
cf2_getGlyphOutline( CF2_Font font,
|
|
|
|
CF2_Buffer charstring,
|
|
|
|
const CF2_Matrix* transform,
|
|
|
|
CF2_F16Dot16* glyphWidth );
|
2013-04-13 15:02:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
FT_END_HEADER
|
|
|
|
|
|
|
|
|
2017-10-01 01:39:27 +02:00
|
|
|
#endif /* PSFONT_H_ */
|
2013-04-13 15:02:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* END */
|