< prev index next >
src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c
Print this page
*** 2,12 ****
*
* sfobjs.c
*
* SFNT object management (base).
*
! * Copyright (C) 1996-2019 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
--- 2,12 ----
*
* sfobjs.c
*
* SFNT object management (base).
*
! * Copyright (C) 1996-2020 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
* modified, and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
*** 20,29 ****
--- 20,30 ----
#include "sfobjs.h"
#include "ttload.h"
#include "ttcmap.h"
#include "ttkern.h"
#include "sfwoff.h"
+ #include "sfwoff2.h"
#include FT_INTERNAL_SFNT_H
#include FT_INTERNAL_DEBUG_H
#include FT_TRUETYPE_IDS_H
#include FT_TRUETYPE_TAGS_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
*** 339,349 ****
/* Fill in face->ttc_header. If the font is not a TTC, it is */
/* synthesized into a TTC with one offset table. */
static FT_Error
sfnt_open_font( FT_Stream stream,
! TT_Face face )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_ULong tag, offset;
--- 340,352 ----
/* Fill in face->ttc_header. If the font is not a TTC, it is */
/* synthesized into a TTC with one offset table. */
static FT_Error
sfnt_open_font( FT_Stream stream,
! TT_Face face,
! FT_Int* face_instance_index,
! FT_Long* woff2_num_faces )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_ULong tag, offset;
*** 383,392 ****
--- 386,414 ----
/* Swap out stream and retry! */
stream = face->root.stream;
goto retry;
}
+ if ( tag == TTAG_wOF2 )
+ {
+ FT_TRACE2(( "sfnt_open_font: file is a WOFF2; synthesizing SFNT\n" ));
+
+ if ( FT_STREAM_SEEK( offset ) )
+ return error;
+
+ error = woff2_open_font( stream,
+ face,
+ face_instance_index,
+ woff2_num_faces );
+ if ( error )
+ return error;
+
+ /* Swap out stream and retry! */
+ stream = face->root.stream;
+ goto retry;
+ }
+
if ( tag != 0x00010000UL &&
tag != TTAG_ttcf &&
tag != TTAG_OTTO &&
tag != TTAG_true &&
tag != TTAG_typ1 &&
*** 462,471 ****
--- 484,494 ----
{
FT_Error error;
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 */
FT_UNUSED( num_params );
FT_UNUSED( params );
*** 512,522 ****
}
#endif
FT_TRACE2(( "SFNT driver\n" ));
! error = sfnt_open_font( stream, face );
if ( error )
return error;
/* Stream may have changed in sfnt_open_font. */
stream = face->root.stream;
--- 535,548 ----
}
#endif
FT_TRACE2(( "SFNT driver\n" ));
! error = sfnt_open_font( stream,
! face,
! &face_instance_index,
! &woff2_num_faces );
if ( error )
return error;
/* Stream may have changed in sfnt_open_font. */
stream = face->root.stream;
*** 687,696 ****
--- 713,726 ----
#endif
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;
}
#define LOAD_( x ) \
< prev index next >