-
Notifications
You must be signed in to change notification settings - Fork 1
/
sfnt.h
82 lines (65 loc) · 2.41 KB
/
sfnt.h
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
#ifndef _SFNT_H
#define _SFNT_H
#include <stdio.h>
typedef struct {
unsigned int tag;
unsigned int checkSum;
unsigned int offset;
unsigned int length;
unsigned int compLength; // for WOFF
} OTF_DIRENT;
typedef struct {
unsigned int length;
unsigned int origLength;
unsigned short majorVersion,minorVersion;
unsigned int metaOffset;
unsigned int metaLength;
unsigned int metaOrigLength;
unsigned int privOffset;
unsigned int privLength;
} OTF_WOFF_HEADER;
typedef struct {
FILE *f;
int flags;
unsigned int numTTC,useTTC;
unsigned int version;
OTF_WOFF_HEADER woff;
unsigned short numTables;
OTF_DIRENT *tables;
unsigned short unitsPerEm;
unsigned short indexToLocFormat; // 0=short, 1=long
unsigned short numGlyphs;
// optionally loaded data
unsigned int *glyphOffsets;
unsigned short numberOfHMetrics;
char *hmtx,*name,*cmap;
const char *unimap; // ptr to (3,1) or (3,0) cmap start
// single glyf buffer, allocated large enough by otf_load_more()
char *gly;
OTF_DIRENT *glyfTable; // direct access
char *glyf; // even more direct access...
} OTF_FILE;
#define OTF_F_CACHE_GLYF 0x00001
#define OTF_F_WOFF 0x08000
#define OTF_F_FMT_CFF 0x10000
#define OTF_F_DO_CHECKSUM 0x40000
// to load TTC collections: append e.g. "/3" for the third font in the file.
OTF_FILE *otf_load(const char *file);
OTF_FILE *otf_load2(FILE *f,int use_ttc/*=-1*/); // takes f
void otf_close(OTF_FILE *otf);
#define OTF_TAG(a,b,c,d) (unsigned int)( ((a)<<24)|((b)<<16)|((c)<<8)|(d) )
#define OTF_UNTAG(a) (((unsigned int)(a)>>24)&0xff),(((unsigned int)(a)>>16)&0xff),\
(((unsigned int)(a)>>8)&0xff),(((unsigned int)(a))&0xff)
char *otf_get_table(OTF_FILE *otf,unsigned int tag,int *ret_len);
int otf_get_width(OTF_FILE *otf,unsigned short gid);
const char *otf_get_name(OTF_FILE *otf,int platformID,int encodingID,int languageID,int nameID,int *ret_len);
int otf_get_glyph(OTF_FILE *otf,unsigned short gid);
unsigned short otf_from_unicode(OTF_FILE *otf,int unicode);
#include "bitset.h"
#include "iofn.h"
// TODO?! allow glyphs==NULL for non-subsetting table reduction?
int otf_subset(OTF_FILE *otf,BITSET glyphs,OUTPUT_FN output,void *context);
int otf_ttc_extract(OTF_FILE *otf,OUTPUT_FN output,void *context);
int otf_subset_cff(OTF_FILE *otf,BITSET glyphs,OUTPUT_FN output,void *context);
int otf_cff_extract(OTF_FILE *otf,OUTPUT_FN output,void *context);
#endif