5
#include "embed_sfnt_int.h"
10
enum { WEIGHT_THIN=100,
11
WEIGHT_EXTRALIGHT=200, WEIGHT_ULTRALIGHT=200,
13
WEIGHT_NORMAL=400, WEIGHT_REGULAR=400,
15
WEIGHT_SEMIBOLD=600, // DEMI
17
WEIGHT_EXTRABOLD=800, WEIGHT_ULTRABOLD=800,
18
WEIGHT_BLACK=900, WEIGHT_HEAVY=900 };
20
void show_post(OTF_FILE *otf) // {{{
26
buf=otf_get_table(otf,OTF_TAG('p','o','s','t'),&len);
29
printf("No post table\n");
33
printf("POST: (%d bytes)\n"
35
" italicAngle: %d.%d\n"
36
" underlinePosition: %d\n"
37
" underlineThickness: %d\n"
40
" vmType1: %d %d\n",len,
42
get_LONG(buf+4)>>16,get_ULONG(buf+4)&0xffff,
46
get_ULONG(buf+16),get_ULONG(buf+20),
47
get_ULONG(buf+24),get_ULONG(buf+38));
52
void show_name(OTF_FILE *otf) // {{{
58
buf=otf_get_table(otf,OTF_TAG('n','a','m','e'),&len);
61
printf("No name table\n");
65
int name_count=get_USHORT(buf+2);
66
const char *nstore=buf+get_USHORT(buf+4);
67
for (iA=0;iA<name_count;iA++) {
68
const char *nrec=buf+6+12*iA;
69
printf(" { platformID/encodingID/languageID/nameID: %d/%d/%d/%d\n"
70
" length: %d, offset: %d, data :",
77
if ( (get_USHORT(nrec)==0)||
78
( (get_USHORT(nrec)==3) ) ) { // WCHAR
79
int nlen=get_USHORT(nrec+8);
80
int npos=get_USHORT(nrec+10);
81
for (;nlen>0;nlen-=2,npos+=2) {
82
if (nstore[npos]!=0x00) {
85
printf("%c",nstore[npos+1]);
91
get_USHORT(nrec+8),nstore+get_USHORT(nrec+10));
98
void show_cmap(OTF_FILE *otf) // {{{
103
char *cmap=otf_get_table(otf,OTF_TAG('c','m','a','p'),&len);
106
printf("No cmap table\n");
110
assert(get_USHORT(cmap)==0x0000); // version
111
const int numTables=get_USHORT(cmap+2);
112
printf(" numTables: %d\n",numTables);
113
for (iA=0;iA<numTables;iA++) {
114
const char *nrec=cmap+4+8*iA;
115
const char *ndata=cmap+get_ULONG(nrec+4);
116
assert(ndata>=cmap+4+8*numTables);
117
printf(" platformID/encodingID: %d/%d\n"
118
" offset: %d data (format: %d, length: %d, language: %d);\n",
119
get_USHORT(nrec),get_USHORT(nrec+2),
121
get_USHORT(ndata),get_USHORT(ndata+2),get_USHORT(ndata+4));
127
void show_glyf(OTF_FILE *otf,int full) // {{{
131
// ensure >glyphOffsets and >gly is there
132
if ( (!otf->gly)||(!otf->glyphOffsets) ) {
133
if (otf_load_glyf(otf)!=0) {
140
int compGlyf=0,zeroGlyf=0;
144
for (iA=0;iA<otf->numGlyphs;iA++) {
145
int len=otf_get_glyph(otf,iA);
148
} else if (get_SHORT(otf->gly)==-1) {
152
printf("%d(%d) ",get_SHORT(otf->gly),len);
158
printf("numGlyf(nonnull): %d(%d), composites: %d\n",otf->numGlyphs,otf->numGlyphs-zeroGlyf,compGlyf);
163
void show_hmtx(OTF_FILE *otf) // {{{
168
otf_get_width(otf,0); // load table.
170
printf("NOTE: no hmtx table!\n");
173
printf("hmtx (%d):\n",otf->numberOfHMetrics);
174
for (iA=0;iA<otf->numberOfHMetrics;iA++) {
176
get_USHORT(otf->hmtx+iA*4),
177
get_SHORT(otf->hmtx+iA*4+2));
179
printf(" (last is repeated for the remaining %d glyphs)\n",otf->numGlyphs-otf->numberOfHMetrics);
183
int main(int argc,char **argv)
185
const char *fn=TESTFONT;
189
OTF_FILE *otf=otf_load(fn);
192
printf("TTC has %d fonts, using %d\n",otf->numTTC,otf->useTTC);
194
if (otf->version==0x00010000) {
195
printf("Got TTF 1.0\n");
196
} else if (otf->version==OTF_TAG('O','T','T','O')) {
197
printf("Got OTF(CFF)\n");
198
} else if (otf->version==OTF_TAG('t','r','u','e')) {
199
printf("Got TTF (true)\n");
200
} else if (otf->version==OTF_TAG('t','y','p','1')) {
201
printf("Got SFNT(Type1)\n");
204
printf("Has %d tables\n",otf->numTables);
207
for (iA=0;iA<otf->numTables;iA++) {
208
printf("%c%c%c%c %d @%d\n",OTF_UNTAG(otf->tables[iA].tag),otf->tables[iA].length,otf->tables[iA].offset);
210
printf("unitsPerEm: %d, indexToLocFormat: %d\n",
211
otf->unitsPerEm,otf->indexToLocFormat);
212
printf("num glyphs: %d\n",otf->numGlyphs);
213
otf_get_width(otf,0); // load table.
214
printf("numberOfHMetrics: %d\n",otf->numberOfHMetrics);
216
printf("Embedding rights: %x\n",emb_otf_get_rights(otf));
223
// printf("%d %d\n",otf_from_unicode(otf,'A'),0);
225
if (!(otf->flags&OTF_F_FMT_CFF)) {