diff --git a/docs/CHANGES b/docs/CHANGES index ea62d3c8c..a06df26ee 100644 --- a/docs/CHANGES +++ b/docs/CHANGES @@ -56,6 +56,8 @@ CHANGES BETWEEN 2.13.3 and 2.14.0 (2025-Mmm-DD) face's default value for the corresponding axis, that is, the set up face is not at its default position. + - `FT_Load_Sfnt_Table` can now also load a font's table directory. + - The TrueType instruction interpreter was optimized to produce 15% gain in the glyph loading speed. diff --git a/include/freetype/tttables.h b/include/freetype/tttables.h index 2cf0ff1bc..ae9553386 100644 --- a/include/freetype/tttables.h +++ b/include/freetype/tttables.h @@ -705,6 +705,9 @@ FT_BEGIN_HEADER * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new * one with @FT_MAKE_TAG. * + * [Since 2.14] Use value~1 if you want to access the table directory + * of the (currently selected) font. + * * offset :: * The starting offset in the table (or file if tag~==~0). * diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index c3a5fae2c..f64ce8890 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -535,7 +535,8 @@ * The tag of table to load. Use the value 0 if you want * to access the whole font file, else set this parameter * to a valid TrueType table tag that you can forge with - * the MAKE_TT_TAG macro. + * the MAKE_TT_TAG macro. Use value 1 to access the table + * directory. * * offset :: * The starting offset in the table (or the file if @@ -577,7 +578,18 @@ FT_ULong size; - if ( tag != 0 ) + if ( tag == 0 ) + { + /* The whole font file. */ + size = face->root.stream->size; + } + else if ( tag == 1 ) + { + /* The currently selected font's table directory. */ + offset += face->ttc_header.offsets[face->root.face_index & 0xFFFF]; + size = 4 + 8 + 16 * face->num_tables; + } + else { /* look for tag in font directory */ table = tt_face_lookup_table( face, tag ); @@ -590,9 +602,6 @@ offset += table->Offset; size = table->Length; } - else - /* tag == 0 -- the user wants to access the font file directly */ - size = face->root.stream->size; if ( length && *length == 0 ) {