1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gxfont42.h 9212 2008-11-09 19:09:30Z leonardo $ */
15
/* Type 42 font data definition */
17
#ifndef gxfont42_INCLUDED
18
# define gxfont42_INCLUDED
20
#ifndef gs_glyph_cache_DEFINED
21
# define gs_glyph_cache_DEFINED
22
typedef struct gs_glyph_cache_s gs_glyph_cache;
25
#ifndef cached_fm_pair_DEFINED
26
# define cached_fm_pair_DEFINED
27
typedef struct cached_fm_pair_s cached_fm_pair;
30
/* This is the type-specific information for a Type 42 (TrueType) font. */
31
#ifndef gs_type42_data_DEFINED
32
#define gs_type42_data_DEFINED
33
typedef struct gs_type42_data_s gs_type42_data;
35
#ifndef gs_font_type42_DEFINED
36
# define gs_font_type42_DEFINED
37
typedef struct gs_font_type42_s gs_font_type42;
41
typedef enum gs_type42_metrics_options_s {
42
gs_type42_metrics_options_WMODE0 = 0,
43
gs_type42_metrics_options_WMODE1 = 1,
44
gs_type42_metrics_options_BBOX = 2,
45
gs_type42_metrics_options_WMODE0_AND_BBOX = 4,
46
gs_type42_metrics_options_WMODE1_AND_BBOX = 5,
47
} gs_type42_metrics_options_t;
48
#define gs_type42_metrics_options_wmode(a) ((a)&gs_type42_metrics_options_WMODE1)
49
#define gs_type42_metrics_options_sbw_requested(a) (~(a)&gs_type42_metrics_options_BBOX)
50
#define gs_type42_metrics_options_bbox_requested(a)((a)&6)
52
/* Export the default get_metrics procedure.
53
The length of sbw is >=4 when bbox in not requested,
56
int gs_type42_default_get_metrics(gs_font_type42 *pfont, uint glyph_index,
57
gs_type42_metrics_options_t options, float *sbw);
59
typedef struct gs_type42_mtx_s {
60
uint numMetrics; /* num*Metrics from [hv]hea */
61
ulong offset; /* offset to [hv]mtx table */
62
uint length; /* length of [hv]mtx table */
64
struct gs_type42_data_s {
65
/* The following are set by the client. */
66
int (*string_proc) (gs_font_type42 *, ulong, uint, const byte **);
67
void *proc_data; /* data for procedures */
69
* The following are initialized by ...font_init, but may be reset by
72
uint (*get_glyph_index)(gs_font_type42 *pfont, gs_glyph glyph);
73
int (*get_outline)(gs_font_type42 *pfont, uint glyph_index,
74
gs_glyph_data_t *pgd);
75
int (*get_metrics)(gs_font_type42 *pfont, uint glyph_index,
76
gs_type42_metrics_options_t options,
77
float *sbw_bbox/* See comment for gs_type42_default_get_metrics */);
78
uint (*substitute_glyph_index_vertical)(gs_font_type42 *pfont, uint glyph_index,
79
int WMode, gs_glyph glyph);
81
/* The following are cached values. */
82
ulong cmap; /* offset to cmap table (not used by */
83
/* renderer, only here for clients) */
84
ulong glyf; /* offset to glyf table */
85
uint unitsPerEm; /* from head */
86
uint indexToLocFormat; /* from head */
87
gs_type42_mtx_t metrics[2]; /* hhea/hmtx, vhea/vmtx (indexed by WMode) */
88
ulong loca; /* offset to loca table */
89
ulong name_offset; /* offset to name table */
90
ulong os2_offset; /* offset to OS/2 table */
92
* TrueType fonts specify the number of glyphs in two different ways:
93
* the size of the loca table, and an explicit value in maxp. Currently
94
* the value of numGlyphs in this structure is computed from the size of
95
* loca. This is wrong: incrementally downloaded TrueType (or
96
* CIDFontType 2) fonts will have no loca table, but will have a
97
* reasonable glyph count in maxp. Unfortunately, a significant amount
98
* of code now depends on the incorrect definition of numGlyphs.
99
* Therefore, rather than run the risk of introducing bugs by changing
100
* the definition and/or by changing the name of the data member, we add
101
* another member trueNumGlyphs to hold the value from maxp.
103
uint numGlyphs; /* from size of loca */
104
uint trueNumGlyphs; /* from maxp */
105
uint *len_glyphs; /* built from the loca table */
106
gs_glyph_cache *gdcache;
107
bool warning_patented;
108
bool warning_bad_instruction;
109
byte *gsub; /* GSUB */
112
#define gs_font_type42_common\
113
gs_font_base_common;\
115
struct gs_font_type42_s {
116
gs_font_type42_common;
119
extern_st(st_gs_font_type42);
120
#define public_st_gs_font_type42() /* in gstype42.c */\
121
gs_public_st_suffix_add4_final(st_gs_font_type42, gs_font_type42,\
122
"gs_font_type42", font_type42_enum_ptrs, font_type42_reloc_ptrs,\
123
gs_font_finalize, st_gs_font_base, data.proc_data, data.len_glyphs, \
124
data.gdcache, data.gsub)
127
* Because a Type 42 font contains so many cached values,
128
* we provide a procedure to initialize them from the font data.
129
* Note that this initializes the type42_data procedures other than
130
* string_proc, and the font procedures as well.
131
* USE_ttfReader subclasses gs_font_type42 with ttfReader or without.
132
* FAPI will disable ttfReader as well.
134
int gs_type42_font_init(gs_font_type42 *pfont, int subfontid);
136
/* Read data from sfnts. */
137
int gs_type42_read_data(gs_font_type42 * pfont, ulong pos, uint length, byte *buf);
139
/* Read data from sfnts. */
140
/* A temporary macro for simplifying the old code change. */
141
#define READ_SFNTS(pfont, pos, length, buf)\
143
if (length > sizeof(buf))\
144
return_error(gs_error_unregistered);/* Must not happen. */\
145
code = gs_type42_read_data(pfont, (ulong)(pos), length, buf);\
146
if ( code < 0 ) return code;\
149
#define MAX_NUM_TT_TABLES 40
151
/* Append the outline of a TrueType character to a path. */
152
int gs_type42_append(uint glyph_index, gs_state * pgs,
153
gx_path * ppath, gs_text_enum_t *penum, gs_font *pfont,
156
/* Get the metrics of a TrueType character. */
157
int gs_type42_get_metrics(gs_font_type42 * pfont, uint glyph_index,
160
int gs_type42_get_outline_from_TT_file(gs_font_type42 * pfont, stream *s, uint glyph_index,
161
gs_glyph_data_t *pgd);
163
/* Export the font procedures so they can be called from the interpreter. */
164
font_proc_enumerate_glyph(gs_type42_enumerate_glyph);
165
font_proc_glyph_info(gs_type42_glyph_info);
166
font_proc_glyph_outline(gs_type42_glyph_outline);
168
/* Get glyph info by glyph index. */
169
int gs_type42_glyph_info_by_gid(gs_font *font, gs_glyph glyph, const gs_matrix *pmat,
170
int members, gs_glyph_info_t *info, uint glyph_index);
172
int gs_type42_font_info(gs_font *font, const gs_point *pscale, int members,
173
gs_font_info_t *info);
174
int gs_truetype_font_info(gs_font *font, const gs_point *pscale, int members,
175
gs_font_info_t *info);
177
uint gs_type42_substitute_glyph_index_vertical(gs_font_type42 *pfont, uint glyph_index,
178
int WMode, gs_glyph glyph);
179
#endif /* gxfont42_INCLUDED */