1 /****************************************************************************
2 *
3 * cffload.c
4 *
5 * OpenType and CFF data/program tables loader (body).
6 *
7 * Copyright (C) 1996-2019 by
8 * David Turner, Robert Wilhelm, and Werner Lemberg.
9 *
10 * This file is part of the FreeType project, and may only be used,
11 * modified, and distributed under the terms of the FreeType project
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute
13 * this file you indicate that you have read the license and
14 * understand and accept it fully.
15 *
16 */
17
18
19 #include <ft2build.h>
20 #include FT_INTERNAL_DEBUG_H
21 #include FT_INTERNAL_OBJECTS_H
22 #include FT_INTERNAL_STREAM_H
23 #include FT_TRUETYPE_TAGS_H
24 #include FT_TYPE1_TABLES_H
25 #include FT_INTERNAL_POSTSCRIPT_AUX_H
26
27 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
2040 top->maxstack = cff2 ? CFF2_DEFAULT_STACK : 48;
2041
2042 if ( idx->count ) /* count is nonzero for a real index */
2043 error = cff_index_access_element( idx, font_index, &dict, &dict_len );
2044 else
2045 {
2046 /* CFF2 has a fake top dict index; */
2047 /* simulate `cff_index_access_element' */
2048
2049 /* Note: macros implicitly use `stream' and set `error' */
2050 if ( FT_STREAM_SEEK( idx->data_offset ) ||
2051 FT_FRAME_EXTRACT( idx->data_size, dict ) )
2052 goto Exit;
2053
2054 dict_len = idx->data_size;
2055 }
2056
2057 if ( !error )
2058 {
2059 FT_TRACE4(( " top dictionary:\n" ));
2060 error = cff_parser_run( &parser, dict, dict + dict_len );
2061 }
2062
2063 /* clean up regardless of error */
2064 if ( idx->count )
2065 cff_index_forget_element( idx, &dict );
2066 else
2067 FT_FRAME_RELEASE( dict );
2068
2069 if ( error )
2070 goto Exit;
2071
2072 /* if it is a CID font, we stop there */
2073 if ( top->cid_registry != 0xFFFFU )
2074 goto Exit;
2075
2076 /* Parse the private dictionary, if any. */
2077 /* */
2078 /* CFF2 does not have a private dictionary in the Top DICT */
2079 /* but may have one in a Font DICT. We need to parse */
2080 /* the latter here in order to load any local subrs. */
|
1 /****************************************************************************
2 *
3 * cffload.c
4 *
5 * OpenType and CFF data/program tables loader (body).
6 *
7 * Copyright (C) 1996-2020 by
8 * David Turner, Robert Wilhelm, and Werner Lemberg.
9 *
10 * This file is part of the FreeType project, and may only be used,
11 * modified, and distributed under the terms of the FreeType project
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute
13 * this file you indicate that you have read the license and
14 * understand and accept it fully.
15 *
16 */
17
18
19 #include <ft2build.h>
20 #include FT_INTERNAL_DEBUG_H
21 #include FT_INTERNAL_OBJECTS_H
22 #include FT_INTERNAL_STREAM_H
23 #include FT_TRUETYPE_TAGS_H
24 #include FT_TYPE1_TABLES_H
25 #include FT_INTERNAL_POSTSCRIPT_AUX_H
26
27 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
2040 top->maxstack = cff2 ? CFF2_DEFAULT_STACK : 48;
2041
2042 if ( idx->count ) /* count is nonzero for a real index */
2043 error = cff_index_access_element( idx, font_index, &dict, &dict_len );
2044 else
2045 {
2046 /* CFF2 has a fake top dict index; */
2047 /* simulate `cff_index_access_element' */
2048
2049 /* Note: macros implicitly use `stream' and set `error' */
2050 if ( FT_STREAM_SEEK( idx->data_offset ) ||
2051 FT_FRAME_EXTRACT( idx->data_size, dict ) )
2052 goto Exit;
2053
2054 dict_len = idx->data_size;
2055 }
2056
2057 if ( !error )
2058 {
2059 FT_TRACE4(( " top dictionary:\n" ));
2060 error = cff_parser_run( &parser, dict, FT_OFFSET( dict, dict_len ) );
2061 }
2062
2063 /* clean up regardless of error */
2064 if ( idx->count )
2065 cff_index_forget_element( idx, &dict );
2066 else
2067 FT_FRAME_RELEASE( dict );
2068
2069 if ( error )
2070 goto Exit;
2071
2072 /* if it is a CID font, we stop there */
2073 if ( top->cid_registry != 0xFFFFU )
2074 goto Exit;
2075
2076 /* Parse the private dictionary, if any. */
2077 /* */
2078 /* CFF2 does not have a private dictionary in the Top DICT */
2079 /* but may have one in a Font DICT. We need to parse */
2080 /* the latter here in order to load any local subrs. */
|