Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* Copyright (C) 1991, 2000 Aladdin Enterprises.  All rights reserved.
2
 
3
  This software is provided AS-IS with no warranty, either express or
4
  implied.
5
 
6
  This software is distributed under license and may not be copied,
7
  modified or distributed except as expressly authorized under the terms
8
  of the license contained in the file LICENSE in this distribution.
9
 
10
  For more information about licensing, please refer to
11
  http://www.ghostscript.com/licensing/. For information on
12
  commercial licensing, go to http://www.artifex.com/licensing/ or
13
  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
*/
16
 
17
/* $Id: ifapi.h,v 1.19 2004/08/04 19:36:12 stefan Exp $ */
18
/* Font API interface */
19
 
20
#ifndef ifapi_INCLUDED
21
#  define ifapi_INCLUDED
22
 
23
#include "iplugin.h"
24
 
25
typedef int FracInt; /* A fractional integer with statically unknown number of fraction bits. 
26
                        The number of bits depends on plugin and is being specified in
27
                        FAPI_server::frac_shift.
28
                     */
29
typedef int FAPI_retcode;
30
 
31
typedef enum {
32
    FAPI_FONT_FEATURE_FontMatrix,
33
    FAPI_FONT_FEATURE_UniqueID,
34
    FAPI_FONT_FEATURE_BlueScale,
35
    FAPI_FONT_FEATURE_Weight,
36
    FAPI_FONT_FEATURE_ItalicAngle,
37
    FAPI_FONT_FEATURE_IsFixedPitch,
38
    FAPI_FONT_FEATURE_UnderLinePosition,
39
    FAPI_FONT_FEATURE_UnderlineThickness,
40
    FAPI_FONT_FEATURE_FontType,
41
    FAPI_FONT_FEATURE_FontBBox,
42
    FAPI_FONT_FEATURE_BlueValues_count, 
43
    FAPI_FONT_FEATURE_BlueValues,
44
    FAPI_FONT_FEATURE_OtherBlues_count, 
45
    FAPI_FONT_FEATURE_OtherBlues,
46
    FAPI_FONT_FEATURE_FamilyBlues_count, 
47
    FAPI_FONT_FEATURE_FamilyBlues,
48
    FAPI_FONT_FEATURE_FamilyOtherBlues_count, 
49
    FAPI_FONT_FEATURE_FamilyOtherBlues,
50
    FAPI_FONT_FEATURE_BlueShift,
51
    FAPI_FONT_FEATURE_BlueFuzz,
52
    FAPI_FONT_FEATURE_StdHW,
53
    FAPI_FONT_FEATURE_StdVW,
54
    FAPI_FONT_FEATURE_StemSnapH_count, 
55
    FAPI_FONT_FEATURE_StemSnapH,
56
    FAPI_FONT_FEATURE_StemSnapV_count, 
57
    FAPI_FONT_FEATURE_StemSnapV,
58
    FAPI_FONT_FEATURE_ForceBold,
59
    FAPI_FONT_FEATURE_LanguageGroup,
60
    FAPI_FONT_FEATURE_lenIV,
61
    FAPI_FONT_FEATURE_Subrs_count,
62
    FAPI_FONT_FEATURE_Subrs_total_size,
63
    FAPI_FONT_FEATURE_TT_size
64
} fapi_font_feature;
65
 
66
typedef enum {
67
  FAPI_METRICS_NOTDEF,
68
  FAPI_METRICS_ADD, /* Add to native glyph width. */
69
  FAPI_METRICS_REPLACE_WIDTH, /* Replace the native glyph width. */
70
  FAPI_METRICS_REPLACE /* Replace the native glyph width and lsb. */
71
} FAPI_metrics_type;
72
 
73
typedef struct {
74
    int char_code;
75
    bool is_glyph_index; /* true if char_code contains glyph index */
76
    const unsigned char *char_name; /* to be used exclusively with char_code. */
77
    unsigned int char_name_length;
78
    FAPI_metrics_type metrics_type;
79
    FracInt sb_x, sb_y, aw_x, aw_y; /* replaced PS metrics. */
80
    int metrics_scale; /* Scale for replaced PS metrics. 
81
		          Zero means "em box size". */
82
} FAPI_char_ref;
83
 
84
typedef struct FAPI_font_s FAPI_font;
85
struct FAPI_font_s {
86
    /* server's data : */
87
    void *server_font_data;
88
    bool need_decrypt;
89
    /* client's data : */
90
    const gs_memory_t *memory;
91
    const char *font_file_path;
92
    int subfont;
93
    bool is_type1; /* Only for non-disk fonts; dirty for disk fonts. */
94
    bool is_cid;
95
    bool is_mtx_skipped; /* Ugly. UFST needs only */
96
    void *client_ctx_p;
97
    void *client_font_data;
98
    void *client_font_data2;
99
    const void *char_data;
100
    int char_data_len;
101
    unsigned short (*get_word )(FAPI_font *ff, fapi_font_feature var_id, int index);
102
    unsigned long  (*get_long )(FAPI_font *ff, fapi_font_feature var_id, int index);
103
    float          (*get_float)(FAPI_font *ff, fapi_font_feature var_id, int index);
104
    unsigned short (*get_subr) (FAPI_font *ff, int index,     byte *buf, ushort buf_length);
105
    unsigned short (*get_glyph)(FAPI_font *ff, int char_code, byte *buf, ushort buf_length);
106
    unsigned short (*serialize_tt_font)(FAPI_font *ff, void *buf, int buf_size);
107
};
108
 
109
typedef struct FAPI_path_s FAPI_path;
110
struct FAPI_path_s {
111
    void *olh; /* Client's data. */
112
    int shift;
113
    int (*moveto   )(FAPI_path *, FracInt, FracInt);
114
    int (*lineto   )(FAPI_path *, FracInt, FracInt);
115
    int (*curveto  )(FAPI_path *, FracInt, FracInt, FracInt, FracInt, FracInt, FracInt);
116
    int (*closepath)(FAPI_path *);
117
};
118
 
119
typedef struct FAPI_font_scale_s {
120
    FracInt matrix[6]; 
121
    FracInt HWResolution[2]; 
122
    int subpixels[2];
123
    bool align_to_pixels; 
124
} FAPI_font_scale;
125
 
126
typedef struct FAPI_metrics_s {
127
    int bbox_x0, bbox_y0, bbox_x1, bbox_y1; /* design units */
128
    int escapement; /* design units */
129
    int em_x, em_y; /* design units */
130
} FAPI_metrics;
131
 
132
typedef struct { /* 1bit/pixel only, rows are byte-aligned. */
133
    void *p;
134
    int width, height, line_step;
135
    int orig_x, orig_y; /* origin, 1/16s pixel */
136
} FAPI_raster;
137
 
138
#ifndef FAPI_server_DEFINED
139
#define FAPI_server_DEFINED
140
typedef struct FAPI_server_s FAPI_server;
141
#endif
142
 
143
typedef int FAPI_descendant_code; /* Possible values are descendant font indices and 4 ones defined below. */
144
#define FAPI_DESCENDANT_PREPARED -1 /* See FAPI_prepare_font in zfapi.c . */
145
#define FAPI_TOPLEVEL_PREPARED -2
146
#define FAPI_TOPLEVEL_BEGIN -3
147
#define FAPI_TOPLEVEL_COMPLETE -4
148
 
149
struct FAPI_server_s {
150
    i_plugin_instance ig;
151
    int frac_shift; /* The number of fractional bits in coordinates. */
152
    FAPI_retcode (*ensure_open)(FAPI_server *server);
153
    FAPI_retcode (*get_scaled_font)(FAPI_server *server, FAPI_font *ff, int subfont, const FAPI_font_scale *scale, const char *xlatmap, bool bVertical, FAPI_descendant_code dc);
154
    FAPI_retcode (*get_decodingID)(FAPI_server *server, FAPI_font *ff, const char **decodingID);
155
    FAPI_retcode (*get_font_bbox)(FAPI_server *server, FAPI_font *ff, int BBox[4]);
156
    FAPI_retcode (*get_font_proportional_feature)(FAPI_server *server, FAPI_font *ff, int subfont, bool *bProportional);
157
    FAPI_retcode (*can_retrieve_char_by_name)(FAPI_server *server, FAPI_font *ff, FAPI_char_ref *c, int *result);
158
    FAPI_retcode (*can_replace_metrics)(FAPI_server *server, FAPI_font *ff, FAPI_char_ref *c, int *result);
159
    FAPI_retcode (*get_char_width)(FAPI_server *server, FAPI_font *ff, FAPI_char_ref *c, FAPI_metrics *metrics);
160
    FAPI_retcode (*get_char_raster_metrics)(FAPI_server *server, FAPI_font *ff, FAPI_char_ref *c, FAPI_metrics *metrics);
161
    FAPI_retcode (*get_char_raster)(FAPI_server *server, FAPI_raster *r);
162
    FAPI_retcode (*get_char_outline_metrics)(FAPI_server *server, FAPI_font *ff, FAPI_char_ref *c, FAPI_metrics *metrics);
163
    FAPI_retcode (*get_char_outline)(FAPI_server *server, FAPI_path *p);
164
    FAPI_retcode (*release_char_data)(FAPI_server *server);
165
    FAPI_retcode (*release_typeface)(FAPI_server *server, void *server_font_data);
166
    /*  Some people get confused with terms "font cache" and "character cache".
167
        "font cache" means a cache for scaled font objects, which mainly
168
        keep the font header information and rules for adjusting it to specific raster.
169
        "character cahce" is a cache for specific character outlines and/or character rasters.
170
    */
171
    /*  get_scaled_font opens a typeface with a server and scales it according to CTM and HWResolution.
172
        This creates a server's scaled font object.
173
        Since UFST doesn't provide a handle to this object,
174
        we need to build the data for it and call this function whenever scaled font data may change.
175
        The server must cache scaled fonts internally.
176
        Note that FreeType doesn't provide internal font cache,
177
        so the bridge must do.
178
    */
179
    /*  GS cannot provide information when a scaled font to be closed.
180
        Therefore we don't provide close_scaled_font function in this interface.
181
        The server must cache scaled fonts, and close ones which were
182
        not in use during a long time.
183
    */
184
    /*  Due to the interpreter fallback with CDevProc,
185
        get_char_raster_metrics leaves some data kept by the server,
186
	so taht get_char_raster uses them and release_char_data releases them.
187
        Therefore calls from GS to these functions must not 
188
        interfer with different characters.
189
    */
190
};
191
 
192
 
193
#endif /* ifapi_INCLUDED */