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 {
// include components (set bit in >glyphs) of currently loaded compound glyph (with >curgid) // returns additional space requirements (when bits below >donegid are touched) static int otf_subset_glyf(OTF_FILE *otf,int curgid,int donegid,BITSET glyphs) // {{{ { int ret=0; if (get_SHORT(otf->gly)>=0) { // not composite return ret; // done } char *cur=otf->gly+10; unsigned short flags; do { flags=get_USHORT(cur); const unsigned short sub_gid=get_USHORT(cur+2); assert(sub_gid<otf->numGlyphs); if (!bit_check(glyphs,sub_gid)) { // bad: temporarily load sub glyph const int len=otf_get_glyph(otf,sub_gid); assert(len>0); bit_set(glyphs,sub_gid); if (sub_gid<donegid) { ret+=len; ret+=otf_subset_glyf(otf,sub_gid,donegid,glyphs); // composite of composites?, e.g. in DejaVu } const int res=otf_get_glyph(otf,curgid); // reload current glyph assert(res); } // skip parameters cur+=6; if (flags&0x01) { cur+=2; } if (flags&0x08) { cur+=2; } else if (flags&0x40) { cur+=4; } else if (flags&0x80) { cur+=8; } } while (flags&0x20); // more components return ret; }