summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/mfluadir/otfcc/include/otfcc/table/glyf.h
blob: 740492cbb96feb853602819e86203ce64b77f237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef CARYLL_INCLUDE_TABLE_GLYF_H
#define CARYLL_INCLUDE_TABLE_GLYF_H

#include "table-common.h"
#include "head.h"
#include "maxp.h"
#include "fvar.h"

enum GlyphType { SIMPLE, COMPOSITE };

typedef struct {
	VQ x;
	VQ y;
	int8_t onCurve; // a mask indicates whether a point is on-curve or off-curve
	                // bit 0     : 1 for on-curve, 0 for off-curve. JSON field: "on"
	                // bit 1 - 7 : unused, set to 0
	                // in JSON, they are separated into several boolean fields.
} glyf_Point;
extern caryll_ValElementInterface(glyf_Point) glyf_iPoint;
typedef caryll_Vector(glyf_Point) glyf_Contour;
extern caryll_VectorInterface(glyf_Contour, glyf_Point) glyf_iContour;

typedef caryll_Vector(glyf_Contour) glyf_ContourList;
extern caryll_VectorInterface(glyf_ContourList, glyf_Contour) glyf_iContourList;

// CFF stems and hint masks
typedef struct {
	pos_t position;
	pos_t width;
	uint16_t map;
} glyf_PostscriptStemDef;
extern caryll_ElementInterface(glyf_PostscriptStemDef) glyf_iPostscriptStemDef;
typedef caryll_Vector(glyf_PostscriptStemDef) glyf_StemDefList;
extern caryll_VectorInterface(glyf_StemDefList, glyf_PostscriptStemDef) glyf_iStemDefList;

typedef struct {
	uint16_t pointsBefore;
	uint16_t contoursBefore;
	bool maskH[0x100];
	bool maskV[0x100];
} glyf_PostscriptHintMask;
extern caryll_ElementInterface(glyf_PostscriptHintMask) glyf_iPostscriptHintMask;
typedef caryll_Vector(glyf_PostscriptHintMask) glyf_MaskList;
extern caryll_VectorInterface(glyf_MaskList, glyf_PostscriptHintMask) glyf_iMaskList;

typedef enum {
	REF_XY = 0,
	REF_ANCHOR_ANCHOR = 1,
	REF_ANCHOR_XY = 2,
	REF_ANCHOR_CONSOLIDATED = 3,
	REF_ANCHOR_CONSOLIDATING_ANCHOR = 4,
	REF_ANCHOR_CONSOLIDATING_XY = 5,
} RefAnchorStatus;

typedef struct {
	//// NOTE: this part and below looks like a glyf_Point
	VQ x;
	VQ y;
	// flags
	bool roundToGrid;
	bool useMyMetrics;
	// the glyph being referenced
	otfcc_GlyphHandle glyph;
	// transformation term
	scale_t a;
	scale_t b;
	scale_t c;
	scale_t d;
	// Anchorness term
	RefAnchorStatus isAnchored;
	shapeid_t inner;
	shapeid_t outer;
} glyf_ComponentReference;
extern caryll_ValElementInterface(glyf_ComponentReference) glyf_iComponentReference;
typedef caryll_Vector(glyf_ComponentReference) glyf_ReferenceList;
extern caryll_VectorInterface(glyf_ReferenceList, glyf_ComponentReference) glyf_iReferenceList;

typedef struct {
	pos_t xMin;
	pos_t xMax;
	pos_t yMin;
	pos_t yMax;
	uint16_t nestDepth;
	uint16_t nPoints;
	uint16_t nContours;
	uint16_t nCompositePoints;
	uint16_t nCompositeContours;
} glyf_GlyphStat;

typedef struct {
	sds name;

	// Metrics
	VQ horizontalOrigin;
	VQ advanceWidth;
	VQ verticalOrigin;
	VQ advanceHeight;

	// Outline
	// NOTE: SFNT does not support mixed glyphs, but we do.
	OWNING glyf_ContourList contours;
	OWNING glyf_ReferenceList references;

	// Postscript hints
	OWNING glyf_StemDefList stemH;
	OWNING glyf_StemDefList stemV;
	OWNING glyf_MaskList hintMasks;
	OWNING glyf_MaskList contourMasks;

	// TTF instructions
	uint16_t instructionsLength;
	uint8_t *instructions;
	// TTF Screen specific
	uint8_t yPel;

	// CID FDSelect
	otfcc_FDHandle fdSelect;
	glyphid_t cid; // Subset CID fonts may need this to represent the original CID entry

	// Stats
	glyf_GlyphStat stat;
} glyf_Glyph;

typedef glyf_Glyph *glyf_GlyphPtr;
extern caryll_ElementInterface(glyf_GlyphPtr) glyf_iGlyphPtr;
typedef caryll_Vector(glyf_GlyphPtr) table_glyf;
extern caryll_VectorInterface(table_glyf, glyf_GlyphPtr) table_iGlyf;

#endif