Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7638 views
1
#ifndef MUPDF_PDF_FONT_H
2
#define MUPDF_PDF_FONT_H
3
4
/*
5
* Font
6
*/
7
8
enum
9
{
10
PDF_FD_FIXED_PITCH = 1 << 0,
11
PDF_FD_SERIF = 1 << 1,
12
PDF_FD_SYMBOLIC = 1 << 2,
13
PDF_FD_SCRIPT = 1 << 3,
14
PDF_FD_NONSYMBOLIC = 1 << 5,
15
PDF_FD_ITALIC = 1 << 6,
16
PDF_FD_ALL_CAP = 1 << 16,
17
PDF_FD_SMALL_CAP = 1 << 17,
18
PDF_FD_FORCE_BOLD = 1 << 18
19
};
20
21
void pdf_load_encoding(char **estrings, char *encoding);
22
int pdf_lookup_agl(char *name);
23
const char **pdf_lookup_agl_duplicates(int ucs);
24
25
extern const unsigned short pdf_doc_encoding[256];
26
extern const char * const pdf_mac_roman[256];
27
extern const char * const pdf_mac_expert[256];
28
extern const char * const pdf_win_ansi[256];
29
extern const char * const pdf_standard[256];
30
31
typedef struct pdf_font_desc_s pdf_font_desc;
32
typedef struct pdf_hmtx_s pdf_hmtx;
33
typedef struct pdf_vmtx_s pdf_vmtx;
34
35
struct pdf_hmtx_s
36
{
37
unsigned short lo;
38
unsigned short hi;
39
int w; /* type3 fonts can be big! */
40
};
41
42
struct pdf_vmtx_s
43
{
44
unsigned short lo;
45
unsigned short hi;
46
short x;
47
short y;
48
short w;
49
};
50
51
struct pdf_font_desc_s
52
{
53
fz_storable storable;
54
unsigned int size;
55
56
fz_font *font;
57
58
/* FontDescriptor */
59
int flags;
60
float italic_angle;
61
float ascent;
62
float descent;
63
float cap_height;
64
float x_height;
65
float missing_width;
66
67
/* Encoding (CMap) */
68
pdf_cmap *encoding;
69
pdf_cmap *to_ttf_cmap;
70
int cid_to_gid_len;
71
unsigned short *cid_to_gid;
72
73
/* ToUnicode */
74
pdf_cmap *to_unicode;
75
int cid_to_ucs_len;
76
unsigned short *cid_to_ucs;
77
78
/* Metrics (given in the PDF file) */
79
int wmode;
80
81
int hmtx_len, hmtx_cap;
82
pdf_hmtx dhmtx;
83
pdf_hmtx *hmtx;
84
85
int vmtx_len, vmtx_cap;
86
pdf_vmtx dvmtx;
87
pdf_vmtx *vmtx;
88
89
int is_embedded;
90
};
91
92
void pdf_set_font_wmode(fz_context *ctx, pdf_font_desc *font, int wmode);
93
void pdf_set_default_hmtx(fz_context *ctx, pdf_font_desc *font, int w);
94
void pdf_set_default_vmtx(fz_context *ctx, pdf_font_desc *font, int y, int w);
95
void pdf_add_hmtx(fz_context *ctx, pdf_font_desc *font, int lo, int hi, int w);
96
void pdf_add_vmtx(fz_context *ctx, pdf_font_desc *font, int lo, int hi, int x, int y, int w);
97
void pdf_end_hmtx(fz_context *ctx, pdf_font_desc *font);
98
void pdf_end_vmtx(fz_context *ctx, pdf_font_desc *font);
99
pdf_hmtx pdf_lookup_hmtx(fz_context *ctx, pdf_font_desc *font, int cid);
100
pdf_vmtx pdf_lookup_vmtx(fz_context *ctx, pdf_font_desc *font, int cid);
101
102
void pdf_load_to_unicode(fz_context *ctx, pdf_document *doc, pdf_font_desc *font, char **strings, char *collection, pdf_obj *cmapstm);
103
104
int pdf_font_cid_to_gid(fz_context *ctx, pdf_font_desc *fontdesc, int cid);
105
106
unsigned char *pdf_lookup_builtin_font(fz_context *ctx, const char *name, unsigned int *len);
107
unsigned char *pdf_lookup_substitute_font(fz_context *ctx, int mono, int serif, int bold, int italic, unsigned int *len);
108
unsigned char *pdf_lookup_substitute_cjk_font(fz_context *ctx, int ros, int serif, int wmode, unsigned int *len, int *index);
109
110
pdf_font_desc *pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *obj);
111
void pdf_load_type3_glyphs(fz_context *ctx, pdf_document *doc, pdf_font_desc *fontdesc, int nestedDepth);
112
pdf_font_desc *pdf_load_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *obj, int nestedDepth);
113
pdf_font_desc *pdf_load_hail_mary_font(fz_context *ctx, pdf_document *doc);
114
115
pdf_font_desc *pdf_new_font_desc(fz_context *ctx);
116
pdf_font_desc *pdf_keep_font(fz_context *ctx, pdf_font_desc *fontdesc);
117
void pdf_drop_font(fz_context *ctx, pdf_font_desc *font);
118
119
#ifndef NDEBUG
120
void pdf_print_font(fz_context *ctx, pdf_font_desc *fontdesc);
121
#endif
122
123
fz_rect *pdf_measure_text(fz_context *ctx, pdf_font_desc *fontdesc, unsigned char *buf, int len, fz_rect *rect);
124
float pdf_text_stride(fz_context *ctx, pdf_font_desc *fontdesc, float fontsize, unsigned char *buf, int len, float room, int *count);
125
126
void pdf_run_glyph(fz_context *ctx, pdf_document *doc, pdf_obj *resources, fz_buffer *contents, fz_device *dev, const fz_matrix *ctm, void *gstate, int nestedDepth);
127
128
#endif
129
130