void emb_otf_get_pdf_fontdescr(OTF_FILE *otf,EMB_PDF_FONTDESCR *ret) // {{{ { int len; // TODO // ... fill in struct char *head=otf_get_table(otf,OTF_TAG('h','e','a','d'),&len); assert(head); // version is 1.0 from otf_load ret->bbxmin=get_SHORT(head+36)*1000/otf->unitsPerEm; ret->bbymin=get_SHORT(head+38)*1000/otf->unitsPerEm; ret->bbxmax=get_SHORT(head+40)*1000/otf->unitsPerEm; ret->bbymax=get_SHORT(head+42)*1000/otf->unitsPerEm; const int macStyle=get_USHORT(head+44); free(head); char *post=otf_get_table(otf,OTF_TAG('p','o','s','t'),&len); assert(post); const unsigned int post_version=get_ULONG(post); // check length assert( (post_version!=0x00010000)||(len==32) ); assert( (post_version!=0x00020000)||(len>=34+2*otf->numGlyphs) ); assert( (post_version!=0x00025000)||(len==35+otf->numGlyphs) ); assert( (post_version!=0x00030000)||(len==32) ); assert( (post_version!=0x00020000)||(get_USHORT(post+32)==otf->numGlyphs) ); // assert( (post_version==0x00030000)==(!!(otf->flags&OTF_F_FMT_CFF)) ); // ghostscript embedding does this.. // TODO: v4 (apple) : uint16 reencoding[numGlyphs] if ( (post_version==0x00010000)|| (post_version==0x00020000)|| (post_version==0x00025000)|| (post_version==0x00030000) ) { ret->italicAngle=get_LONG(post+4)>>16; if (get_ULONG(post+12)>0) { // monospaced ret->flags|=1; } } else {
EMB_RIGHT_TYPE emb_otf_get_rights(OTF_FILE *otf) // {{{ { EMB_RIGHT_TYPE ret=EMB_RIGHT_FULL; int len; char *os2=otf_get_table(otf,OTF_TAG('O','S','/','2'),&len); if (os2) { const unsigned short os2_version=get_USHORT(os2); // check len assert( (os2_version!=0x0000)||(len==78) ); assert( (os2_version!=0x0001)||(len==86) ); assert( (os2_version<0x0002)||(os2_version>0x0004)||(len==96) ); if (os2_version<=0x0004) { // get rights unsigned short fsType=get_USHORT(os2+8); ret=fsType&0x0200; if ((fsType&0x0f)==0x0002) { ret|=EMB_RIGHT_NONE; } else if ((fsType&0x0f)==0x0004) { ret|=EMB_RIGHT_READONLY; } } free(os2); } return ret; }
EMB_RIGHT_TYPE emb_otf_get_rights(OTF_FILE *otf) // {{{ { EMB_RIGHT_TYPE ret=EMB_RIGHT_FULL; int len; char *os2=otf_get_table(otf,OTF_TAG('O','S','/','2'),&len); if (os2) { const unsigned short os2_version=get_USHORT(os2); // check len assert( (os2_version!=0x0000)||(len==78) ); assert( (os2_version!=0x0001)||(len==86) ); assert( (os2_version<0x0002)||(os2_version>0x0004)||(len==96) ); if (os2_version<=0x0004) { // get rights unsigned short fsType=get_USHORT(os2+8); // from Adobe's Fontpolicies_v9.pdf, pg 13: if (fsType==0x0002) { ret=EMB_RIGHT_NONE; } else { ret=fsType&0x0300; // EMB_RIGHT_BITMAPONLY, EMB_RIGHT_NO_SUBSET if ((fsType&0x000c)==0x0004) { ret|=EMB_RIGHT_READONLY; } } } free(os2); } return ret; }