diff options
author | Nikhil Ramakrishnan <ramakrishnan.nikhil@gmail.com> | 2019-08-05 01:53:00 +0530 |
---|---|---|
committer | Werner Lemberg <wl@gnu.org> | 2019-08-27 09:56:36 +0200 |
commit | 5367e0ca016bc79096cb3b57217fc1326dc3b997 (patch) | |
tree | e35405bf4770442c98a261fad25c2920bec73a6a /src/sfnt/sfobjs.c | |
parent | bb7668d7c30e16ef1d6442c4aa2b694fadd15295 (diff) | |
download | freetype2-5367e0ca016bc79096cb3b57217fc1326dc3b997.tar.gz |
[sfnt] Support `face->num_faces' for WOFF2 fonts.
Set correct value of `face->num_faces' for WOFF2 fonts. This is
being handled separately because we only load the tables for the
requested font face in `woff2_open_font' and create a single-face
sfnt stream.
The full discussion is at:
https://lists.gnu.org/archive/html/freetype-devel/2019-08/msg00000.html
* src/sfnt/sfobjs.c (sfnt_open_font): Add parameter
`woff2_num_faces'.
(sfnt_init_face): Introduce variable `woff2_num_faces', and change
`face->root.num_faces' if `woff2_num_faces' is set.
* src/sfnt/sfwoff2.c (woff2_open_font): Validate requested face
index and handle negative face indices.
* src/sfnt/sfwoff2.h (woff2_open_font): Add parameter `num_faces' to
declaration.
Diffstat (limited to 'src/sfnt/sfobjs.c')
-rw-r--r-- | src/sfnt/sfobjs.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index 7fe25ace7..f6da955ba 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -343,7 +343,8 @@ static FT_Error sfnt_open_font( FT_Stream stream, TT_Face face, - FT_Int* face_instance_index ) + FT_Int* face_instance_index, + FT_Long* woff2_num_faces ) { FT_Memory memory = stream->memory; FT_Error error; @@ -394,7 +395,10 @@ if ( FT_STREAM_SEEK( offset ) ) return error; - error = woff2_open_font( stream, face, face_instance_index ); + error = woff2_open_font( stream, + face, + face_instance_index, + woff2_num_faces ); if ( error ) return error; @@ -479,9 +483,10 @@ FT_Parameter* params ) { FT_Error error; - FT_Library library = face->root.driver->root.library; + FT_Library library = face->root.driver->root.library; SFNT_Service sfnt; FT_Int face_index; + FT_Long woff2_num_faces = 0; /* for now, parameters are unused */ @@ -532,7 +537,10 @@ FT_TRACE2(( "SFNT driver\n" )); - error = sfnt_open_font( stream, face, &face_instance_index ); + error = sfnt_open_font( stream, + face, + &face_instance_index, + &woff2_num_faces ); if ( error ) return error; @@ -707,6 +715,10 @@ face->root.num_faces = face->ttc_header.count; face->root.face_index = face_instance_index; + /* `num_faces' for a WOFF2 needs to be handled separately. */ + if( woff2_num_faces ) + face->root.num_faces = woff2_num_faces; + return error; } |