Here is a preliminary patch to permit a font WITHOUT essential tables, if its header declares CFF/OpenType (by OTTO tag) and CFF table is included.
This patch does not use cmap table, it uses the character-glyph mapping info (Encoding dict) in CFF table. It is NOT expected behaviour, because CID-keyed CFF font for CJK scripts has no Encoding dict. I have to work more about... Regards, mpsuzuki suzuki toshiya wrote: > Thank you for providing a sample. > > For first, please let me comment to your question "why". An OpenType > embedded in PDF should not be expected to be usable as a self standing > OpenType font. It is a component of PDF, and some essential information > are removed (because the identical or substitution information are > stored in the side of PDF). If you check OpenType specification, > http://www.microsoft.com/typography/otspec/otff.htm#otttables > you will find that "head" is essential table and the font lacking it > is not an officially self-standing OpenType font. And, PDF has their > own convention how to transform/compress the OpenType font and PDF > spec does not request the embedded OpenType is conforming to OpenType > spec. > > # without "head" table, TrueType font parser cannot access the > # glyph program, because only the "head" table provides the info > # how to calculate the glyph program storage location from the > # glyph index. but in this case, "CFF" table is used, so it > # is not essential. > > Anyway, I understand FreeType is often expected to load the embedded > OpenType font data in PDF. And, your sample would not require complex > trick to load as self standing font; Your sample is a simple concatenation > of cmap table and CFF table. It would not be so difficult changing FreeType > to pass included CFF stream to CFF parser. But yet I'm not sure if > the cmap table content should be used (if it should be used, more work > is needed). > > > > Regards, > mpsuzuki > > Harry Roberts wrote: >> At sfnt/ttload.c:~280 >> >> The font doesn't have the two expected tables (head, sing) - if I ignore >> that fact and return `SFNT_Err_Ok` from `check_table_dir` then the font >> loads fine and renders perfectly. >> >> Why does the FreeType TTF loader required these two headers when it works >> without them? >> >> ``` >> 282: FT_TRACE2(( "check_table_dir:" )); >> 283: #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS >> 284: FT_TRACE2(( " neither `head', `bhed', nor `sing' table found\n" >> )); >> 285: #else >> 286: FT_TRACE2(( " neither `head' nor `sing' table found\n" )); >> 287: #endif >> 288: error = SFNT_Err_Table_Missing; >> ``` >> >> On 7 November 2012 01:12, Harry Roberts <ha...@midnight-labs.org> wrote: >> >>> Recently I have come across many fonts embedded within PDF files which >>> cannot be loaded by FreeType v2.4.10. >>> >>> I suspect Enfocus PitStop is mangling the fonts when the PDF file is >>> 'optimized'. >>> >>> Attached is the font file (extracted from a PDF) and test case. >>> >>> Adobe Acrobat and Photoshop are able to load the fonts. FontForge can also >>> open the font, and after 'Exporting to OpenType' the test case is able to >>> load the font successfully. >>> >>> I am still trying to debug the problem, but my knowledge of FreeType and >>> font format internals is being stretched. Any insight would be appreciated. >>> >>> Regards, >>> - Harry >>> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Freetype-devel mailing list >> Freetype-devel@nongnu.org >> https://lists.nongnu.org/mailman/listinfo/freetype-devel > > > _______________________________________________ > Freetype-devel mailing list > Freetype-devel@nongnu.org > https://lists.nongnu.org/mailman/listinfo/freetype-devel
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index 16914f2..22a545b 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -171,7 +171,7 @@ { FT_Error error; FT_UShort nn, valid_entries = 0; - FT_UInt has_head = 0, has_sing = 0, has_meta = 0; + FT_UInt has_head = 0, has_sing = 0, has_meta = 0, has_cff = 0; FT_ULong offset = sfnt->offset + 12; static const FT_Frame_Field table_dir_entry_fields[] = @@ -260,6 +260,8 @@ has_sing = 1; else if ( table.Tag == TTAG_META ) has_meta = 1; + else if ( table.Tag == TTAG_CFF ) + has_cff = 1; } sfnt->num_tables = valid_entries; @@ -272,7 +274,7 @@ } /* if `sing' and `meta' tables are present, there is no `head' table */ - if ( has_head || ( has_sing && has_meta ) ) + if ( has_head || ( sfnt->format_tag != TTAG_OTTO && has_cff ) || ( has_sing && has_meta ) ) { error = SFNT_Err_Ok; goto Exit; @@ -281,9 +283,9 @@ { FT_TRACE2(( "check_table_dir:" )); #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - FT_TRACE2(( " neither `head', `bhed', nor `sing' table found\n" )); + FT_TRACE2(( " neither `head', `CFF ', `bhed', nor `sing' table found\n" )); #else - FT_TRACE2(( " neither `head' nor `sing' table found\n" )); + FT_TRACE2(( " neither `head', `CFF ', nor `sing' table found\n" )); #endif error = SFNT_Err_Table_Missing; }
_______________________________________________ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel