ReactOS 0.4.16-dev-2332-g4cba65d
sfwoff2.h File Reference
Include dependency graph for sfwoff2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WOFF2_FLAGS_TRANSFORM   1 << 8
 
#define WOFF2_SFNT_HEADER_SIZE   12
 
#define WOFF2_SFNT_ENTRY_SIZE   16
 
#define WOFF2_DEFAULT_MAX_SIZE   30 * 1024 * 1024
 
#define WOFF2_DEFAULT_GLYPH_BUF   5120
 
#define FLAG_ARG_1_AND_2_ARE_WORDS   1 << 0
 
#define FLAG_WE_HAVE_A_SCALE   1 << 3
 
#define FLAG_MORE_COMPONENTS   1 << 5
 
#define FLAG_WE_HAVE_AN_X_AND_Y_SCALE   1 << 6
 
#define FLAG_WE_HAVE_A_TWO_BY_TWO   1 << 7
 
#define FLAG_WE_HAVE_INSTRUCTIONS   1 << 8
 
#define GLYF_ON_CURVE   1 << 0
 
#define GLYF_X_SHORT   1 << 1
 
#define GLYF_Y_SHORT   1 << 2
 
#define GLYF_REPEAT   1 << 3
 
#define GLYF_THIS_X_IS_SAME   1 << 4
 
#define GLYF_THIS_Y_IS_SAME   1 << 5
 
#define CONTOUR_OFFSET_END_POINT   10
 

Functions

 woff2_open_font (FT_Stream stream, TT_Face face, FT_Int *face_index, FT_Long *num_faces)
 

Macro Definition Documentation

◆ CONTOUR_OFFSET_END_POINT

#define CONTOUR_OFFSET_END_POINT   10

Definition at line 60 of file sfwoff2.h.

◆ FLAG_ARG_1_AND_2_ARE_WORDS

#define FLAG_ARG_1_AND_2_ARE_WORDS   1 << 0

Definition at line 44 of file sfwoff2.h.

◆ FLAG_MORE_COMPONENTS

#define FLAG_MORE_COMPONENTS   1 << 5

Definition at line 46 of file sfwoff2.h.

◆ FLAG_WE_HAVE_A_SCALE

#define FLAG_WE_HAVE_A_SCALE   1 << 3

Definition at line 45 of file sfwoff2.h.

◆ FLAG_WE_HAVE_A_TWO_BY_TWO

#define FLAG_WE_HAVE_A_TWO_BY_TWO   1 << 7

Definition at line 48 of file sfwoff2.h.

◆ FLAG_WE_HAVE_AN_X_AND_Y_SCALE

#define FLAG_WE_HAVE_AN_X_AND_Y_SCALE   1 << 6

Definition at line 47 of file sfwoff2.h.

◆ FLAG_WE_HAVE_INSTRUCTIONS

#define FLAG_WE_HAVE_INSTRUCTIONS   1 << 8

Definition at line 49 of file sfwoff2.h.

◆ GLYF_ON_CURVE

#define GLYF_ON_CURVE   1 << 0

Definition at line 52 of file sfwoff2.h.

◆ GLYF_REPEAT

#define GLYF_REPEAT   1 << 3

Definition at line 55 of file sfwoff2.h.

◆ GLYF_THIS_X_IS_SAME

#define GLYF_THIS_X_IS_SAME   1 << 4

Definition at line 56 of file sfwoff2.h.

◆ GLYF_THIS_Y_IS_SAME

#define GLYF_THIS_Y_IS_SAME   1 << 5

Definition at line 57 of file sfwoff2.h.

◆ GLYF_X_SHORT

#define GLYF_X_SHORT   1 << 1

Definition at line 53 of file sfwoff2.h.

◆ GLYF_Y_SHORT

#define GLYF_Y_SHORT   1 << 2

Definition at line 54 of file sfwoff2.h.

◆ WOFF2_DEFAULT_GLYPH_BUF

#define WOFF2_DEFAULT_GLYPH_BUF   5120

Definition at line 40 of file sfwoff2.h.

◆ WOFF2_DEFAULT_MAX_SIZE

#define WOFF2_DEFAULT_MAX_SIZE   30 * 1024 * 1024

Definition at line 37 of file sfwoff2.h.

◆ WOFF2_FLAGS_TRANSFORM

#define WOFF2_FLAGS_TRANSFORM   1 << 8

Definition at line 31 of file sfwoff2.h.

◆ WOFF2_SFNT_ENTRY_SIZE

#define WOFF2_SFNT_ENTRY_SIZE   16

Definition at line 34 of file sfwoff2.h.

◆ WOFF2_SFNT_HEADER_SIZE

#define WOFF2_SFNT_HEADER_SIZE   12

Definition at line 33 of file sfwoff2.h.

Function Documentation

◆ woff2_open_font()

woff2_open_font ( FT_Stream  stream,
TT_Face  face,
FT_Int face_index,
FT_Long num_faces 
)

Definition at line 1750 of file sfwoff2.c.

1754 {
1755 FT_Memory memory = stream->memory;
1757 FT_Int face_index;
1758
1759 WOFF2_HeaderRec woff2;
1760 WOFF2_InfoRec info = { 0, 0, 0, NULL, NULL, NULL, NULL };
1763 WOFF2_Table* temp_indices = NULL;
1764 WOFF2_Table last_table;
1765
1766 FT_Int nn;
1767 FT_ULong j;
1769 FT_UShort xform_version;
1770 FT_ULong src_offset = 0;
1771
1772 FT_UInt glyf_index;
1773 FT_UInt loca_index;
1774 FT_UInt32 file_offset;
1775
1776 FT_Byte* sfnt = NULL;
1777 FT_Stream sfnt_stream = NULL;
1778 FT_Byte* sfnt_header;
1779 FT_ULong sfnt_size;
1780
1781 FT_Byte* uncompressed_buf = NULL;
1782
1783 static const FT_Frame_Field woff2_header_fields[] =
1784 {
1785#undef FT_STRUCTURE
1786#define FT_STRUCTURE WOFF2_HeaderRec
1787
1788 FT_FRAME_START( 48 ),
1790 FT_FRAME_ULONG ( flavor ),
1792 FT_FRAME_USHORT ( num_tables ),
1794 FT_FRAME_ULONG ( totalSfntSize ),
1795 FT_FRAME_ULONG ( totalCompressedSize ),
1796 FT_FRAME_SKIP_BYTES( 2 * 2 ),
1797 FT_FRAME_ULONG ( metaOffset ),
1798 FT_FRAME_ULONG ( metaLength ),
1799 FT_FRAME_ULONG ( metaOrigLength ),
1800 FT_FRAME_ULONG ( privOffset ),
1801 FT_FRAME_ULONG ( privLength ),
1803 };
1804
1805
1806 FT_ASSERT( stream == face->root.stream );
1807 FT_ASSERT( FT_STREAM_POS() == 0 );
1808
1809 face_index = FT_ABS( *face_instance_index ) & 0xFFFF;
1810
1811 /* Read WOFF2 Header. */
1812 if ( FT_STREAM_READ_FIELDS( woff2_header_fields, &woff2 ) )
1813 return error;
1814
1815 FT_TRACE4(( "signature -> 0x%lX\n", woff2.signature ));
1816 FT_TRACE2(( "flavor -> 0x%08lx\n", woff2.flavor ));
1817 FT_TRACE4(( "length -> %lu\n", woff2.length ));
1818 FT_TRACE2(( "num_tables -> %hu\n", woff2.num_tables ));
1819 FT_TRACE4(( "totalSfntSize -> %lu\n", woff2.totalSfntSize ));
1820 FT_TRACE4(( "metaOffset -> %lu\n", woff2.metaOffset ));
1821 FT_TRACE4(( "metaLength -> %lu\n", woff2.metaLength ));
1822 FT_TRACE4(( "privOffset -> %lu\n", woff2.privOffset ));
1823 FT_TRACE4(( "privLength -> %lu\n", woff2.privLength ));
1824
1825 /* Make sure we don't recurse back here. */
1826 if ( woff2.flavor == TTAG_wOF2 )
1827 return FT_THROW( Invalid_Table );
1828
1829 /* Miscellaneous checks. */
1830 if ( woff2.length != stream->size ||
1831 woff2.num_tables == 0 ||
1832 48 + woff2.num_tables * 20UL >= woff2.length ||
1833 ( woff2.metaOffset == 0 && ( woff2.metaLength != 0 ||
1834 woff2.metaOrigLength != 0 ) ) ||
1835 ( woff2.metaLength != 0 && woff2.metaOrigLength == 0 ) ||
1836 ( woff2.metaOffset >= woff2.length ) ||
1837 ( woff2.length - woff2.metaOffset < woff2.metaLength ) ||
1838 ( woff2.privOffset == 0 && woff2.privLength != 0 ) ||
1839 ( woff2.privOffset >= woff2.length ) ||
1840 ( woff2.length - woff2.privOffset < woff2.privLength ) )
1841 {
1842 FT_ERROR(( "woff2_open_font: invalid WOFF2 header\n" ));
1843 return FT_THROW( Invalid_Table );
1844 }
1845
1846 FT_TRACE2(( "woff2_open_font: WOFF2 Header is valid.\n" ));
1847
1848 woff2.ttc_fonts = NULL;
1849
1850 /* Read table directory. */
1851 if ( FT_NEW_ARRAY( tables, woff2.num_tables ) ||
1852 FT_NEW_ARRAY( indices, woff2.num_tables ) )
1853 goto Exit;
1854
1855 FT_TRACE2((
1856 "\n"
1857 " tag flags transform origLen transformLen offset\n"
1858 " -----------------------------------------------------------\n" ));
1859 /* " XXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX" */
1860
1861 for ( nn = 0; nn < woff2.num_tables; nn++ )
1862 {
1863 WOFF2_Table table = tables + nn;
1864
1865
1866 if ( FT_READ_BYTE( table->FlagByte ) )
1867 goto Exit;
1868
1869 if ( ( table->FlagByte & 0x3f ) == 0x3f )
1870 {
1871 if ( FT_READ_ULONG( table->Tag ) )
1872 goto Exit;
1873 }
1874 else
1875 {
1876 table->Tag = woff2_known_tags( table->FlagByte & 0x3f );
1877 if ( !table->Tag )
1878 {
1879 FT_ERROR(( "woff2_open_font: Unknown table tag." ));
1880 error = FT_THROW( Invalid_Table );
1881 goto Exit;
1882 }
1883 }
1884
1885 flags = 0;
1886 xform_version = ( table->FlagByte >> 6 ) & 0x03;
1887
1888 /* 0 means xform for glyph/loca, non-0 for others. */
1889 if ( table->Tag == TTAG_glyf || table->Tag == TTAG_loca )
1890 {
1891 if ( xform_version == 0 )
1893 }
1894 else if ( xform_version != 0 )
1896
1897 flags |= xform_version;
1898
1899 if ( READ_BASE128( table->dst_length ) )
1900 goto Exit;
1901
1902 table->TransformLength = table->dst_length;
1903
1904 if ( ( flags & WOFF2_FLAGS_TRANSFORM ) != 0 )
1905 {
1906 if ( READ_BASE128( table->TransformLength ) )
1907 goto Exit;
1908
1909 if ( table->Tag == TTAG_loca && table->TransformLength )
1910 {
1911 FT_ERROR(( "woff2_open_font: Invalid loca `transformLength'.\n" ));
1912 error = FT_THROW( Invalid_Table );
1913 goto Exit;
1914 }
1915 }
1916
1917 if ( src_offset + table->TransformLength < src_offset )
1918 {
1919 FT_ERROR(( "woff2_open_font: invalid WOFF2 table directory.\n" ));
1920 error = FT_THROW( Invalid_Table );
1921 goto Exit;
1922 }
1923
1924 table->src_offset = src_offset;
1925 table->src_length = table->TransformLength;
1926 src_offset += table->TransformLength;
1927 table->flags = flags;
1928
1929 FT_TRACE2(( " %c%c%c%c %08d %08d %08ld %08ld %08ld\n",
1930 (FT_Char)( table->Tag >> 24 ),
1931 (FT_Char)( table->Tag >> 16 ),
1932 (FT_Char)( table->Tag >> 8 ),
1933 (FT_Char)( table->Tag ),
1934 table->FlagByte & 0x3f,
1935 ( table->FlagByte >> 6 ) & 0x03,
1936 table->dst_length,
1937 table->TransformLength,
1938 table->src_offset ));
1939
1940 indices[nn] = table;
1941 }
1942
1943 /* End of last table is uncompressed size. */
1944 last_table = indices[woff2.num_tables - 1];
1945
1946 woff2.uncompressed_size = last_table->src_offset +
1947 last_table->src_length;
1948 if ( woff2.uncompressed_size < last_table->src_offset )
1949 {
1950 error = FT_THROW( Invalid_Table );
1951 goto Exit;
1952 }
1953
1954 FT_TRACE2(( "Table directory parsed.\n" ));
1955
1956 /* Check for and read collection directory. */
1957 woff2.num_fonts = 1;
1958 woff2.header_version = 0;
1959
1960 if ( woff2.flavor == TTAG_ttcf )
1961 {
1962 FT_TRACE2(( "Font is a TTC, reading collection directory.\n" ));
1963
1964 if ( FT_READ_ULONG( woff2.header_version ) )
1965 goto Exit;
1966
1967 if ( woff2.header_version != 0x00010000 &&
1968 woff2.header_version != 0x00020000 )
1969 {
1970 error = FT_THROW( Invalid_Table );
1971 goto Exit;
1972 }
1973
1974 if ( READ_255USHORT( woff2.num_fonts ) )
1975 goto Exit;
1976
1977 if ( !woff2.num_fonts )
1978 {
1979 error = FT_THROW( Invalid_Table );
1980 goto Exit;
1981 }
1982
1983 FT_TRACE4(( "Number of fonts in TTC: %d\n", woff2.num_fonts ));
1984
1985 if ( FT_NEW_ARRAY( woff2.ttc_fonts, woff2.num_fonts ) )
1986 goto Exit;
1987
1988 for ( nn = 0; nn < woff2.num_fonts; nn++ )
1989 {
1990 WOFF2_TtcFont ttc_font = woff2.ttc_fonts + nn;
1991
1992
1993 if ( READ_255USHORT( ttc_font->num_tables ) )
1994 goto Exit;
1995 if ( FT_READ_ULONG( ttc_font->flavor ) )
1996 goto Exit;
1997
1998 if ( FT_NEW_ARRAY( ttc_font->table_indices, ttc_font->num_tables ) )
1999 goto Exit;
2000
2001 FT_TRACE5(( "Number of tables in font %d: %d\n",
2002 nn, ttc_font->num_tables ));
2003
2004#ifdef FT_DEBUG_LEVEL_TRACE
2005 if ( ttc_font->num_tables )
2006 FT_TRACE6(( " Indices: " ));
2007#endif
2008
2009 glyf_index = 0;
2010 loca_index = 0;
2011
2012 for ( j = 0; j < ttc_font->num_tables; j++ )
2013 {
2014 FT_UShort table_index;
2016
2017
2018 if ( READ_255USHORT( table_index ) )
2019 goto Exit;
2020
2021 FT_TRACE6(( "%hu ", table_index ));
2022 if ( table_index >= woff2.num_tables )
2023 {
2024 FT_ERROR(( "woff2_open_font: invalid table index\n" ));
2025 error = FT_THROW( Invalid_Table );
2026 goto Exit;
2027 }
2028
2029 ttc_font->table_indices[j] = table_index;
2030
2031 table = indices[table_index];
2032 if ( table->Tag == TTAG_loca )
2033 loca_index = table_index;
2034 if ( table->Tag == TTAG_glyf )
2035 glyf_index = table_index;
2036 }
2037
2038#ifdef FT_DEBUG_LEVEL_TRACE
2039 if ( ttc_font->num_tables )
2040 FT_TRACE6(( "\n" ));
2041#endif
2042
2043 /* glyf and loca must be consecutive */
2044 if ( glyf_index > 0 || loca_index > 0 )
2045 {
2046 if ( glyf_index > loca_index ||
2047 loca_index - glyf_index != 1 )
2048 {
2049 error = FT_THROW( Invalid_Table );
2050 goto Exit;
2051 }
2052 }
2053 }
2054
2055 /* Collection directory reading complete. */
2056 FT_TRACE2(( "WOFF2 collection directory is valid.\n" ));
2057 }
2058 else
2059 woff2.ttc_fonts = NULL;
2060
2062 file_offset = ROUND4( woff2.compressed_offset +
2063 woff2.totalCompressedSize );
2064
2065 /* Some more checks before we start reading the tables. */
2066 if ( file_offset > woff2.length )
2067 {
2068 error = FT_THROW( Invalid_Table );
2069 goto Exit;
2070 }
2071
2072 if ( woff2.metaOffset )
2073 {
2074 if ( file_offset != woff2.metaOffset )
2075 {
2076 error = FT_THROW( Invalid_Table );
2077 goto Exit;
2078 }
2079 file_offset = ROUND4(woff2.metaOffset + woff2.metaLength);
2080 }
2081
2082 if ( woff2.privOffset )
2083 {
2084 if ( file_offset != woff2.privOffset )
2085 {
2086 error = FT_THROW( Invalid_Table );
2087 goto Exit;
2088 }
2089 file_offset = ROUND4(woff2.privOffset + woff2.privLength);
2090 }
2091
2092 if ( file_offset != ( ROUND4( woff2.length ) ) )
2093 {
2094 error = FT_THROW( Invalid_Table );
2095 goto Exit;
2096 }
2097
2098 /* Validate requested face index. */
2099 *num_faces = woff2.num_fonts;
2100 /* value -(N+1) requests information on index N */
2101 if ( *face_instance_index < 0 )
2102 face_index--;
2103
2104 if ( face_index >= woff2.num_fonts )
2105 {
2106 if ( *face_instance_index >= 0 )
2107 {
2108 error = FT_THROW( Invalid_Argument );
2109 goto Exit;
2110 }
2111 else
2112 face_index = 0;
2113 }
2114
2115 /* Only retain tables of the requested face in a TTC. */
2116 if ( woff2.header_version )
2117 {
2118 WOFF2_TtcFont ttc_font = woff2.ttc_fonts + face_index;
2119
2120
2121 /* Create a temporary array. */
2122 if ( FT_NEW_ARRAY( temp_indices,
2123 ttc_font->num_tables ) )
2124 goto Exit;
2125
2126 FT_TRACE4(( "Storing tables for TTC face index %d.\n", face_index ));
2127 for ( nn = 0; nn < ttc_font->num_tables; nn++ )
2128 temp_indices[nn] = indices[ttc_font->table_indices[nn]];
2129
2130 /* Resize array to required size. */
2132 woff2.num_tables,
2133 ttc_font->num_tables ) )
2134 goto Exit;
2135
2136 for ( nn = 0; nn < ttc_font->num_tables; nn++ )
2137 indices[nn] = temp_indices[nn];
2138
2139 FT_FREE( temp_indices );
2140
2141 /* Change header values. */
2142 woff2.flavor = ttc_font->flavor;
2143 woff2.num_tables = ttc_font->num_tables;
2144 }
2145
2146 /* We need to allocate this much at the minimum. */
2147 sfnt_size = 12 + woff2.num_tables * 16UL;
2148 /* This is what we normally expect. */
2149 /* Initially trust `totalSfntSize' and change later as required. */
2150 if ( woff2.totalSfntSize > sfnt_size )
2151 {
2152 /* However, adjust the value to something reasonable. */
2153
2154 /* Factor 64 is heuristic. */
2155 if ( ( woff2.totalSfntSize >> 6 ) > woff2.length )
2156 sfnt_size = woff2.length << 6;
2157 else
2158 sfnt_size = woff2.totalSfntSize;
2159
2160 /* Value 1<<26 = 67108864 is heuristic. */
2161 if (sfnt_size >= (1 << 26))
2162 sfnt_size = 1 << 26;
2163
2164#ifdef FT_DEBUG_LEVEL_TRACE
2165 if ( sfnt_size != woff2.totalSfntSize )
2166 FT_TRACE4(( "adjusting estimate of uncompressed font size"
2167 " to %lu bytes\n",
2168 sfnt_size ));
2169#endif
2170 }
2171
2172 /* Write sfnt header. */
2173 if ( FT_ALLOC( sfnt, sfnt_size ) ||
2174 FT_NEW( sfnt_stream ) )
2175 goto Exit;
2176
2177 sfnt_header = sfnt;
2178
2179 WRITE_ULONG( sfnt_header, woff2.flavor );
2180
2181 if ( woff2.num_tables )
2182 {
2183 FT_UInt searchRange, entrySelector, rangeShift, x;
2184
2185
2186 x = woff2.num_tables;
2187 entrySelector = 0;
2188 while ( x )
2189 {
2190 x >>= 1;
2191 entrySelector += 1;
2192 }
2193 entrySelector--;
2194
2195 searchRange = ( 1 << entrySelector ) * 16;
2196 rangeShift = ( woff2.num_tables * 16 ) - searchRange;
2197
2198 WRITE_USHORT( sfnt_header, woff2.num_tables );
2199 WRITE_USHORT( sfnt_header, searchRange );
2200 WRITE_USHORT( sfnt_header, entrySelector );
2201 WRITE_USHORT( sfnt_header, rangeShift );
2202 }
2203
2204 info.header_checksum = compute_ULong_sum( sfnt, 12 );
2205
2206 /* Sort tables by tag. */
2208 woff2.num_tables,
2209 sizeof ( WOFF2_Table ),
2210 compare_tags );
2211
2212 if ( woff2.uncompressed_size < 1 )
2213 {
2214 error = FT_THROW( Invalid_Table );
2215 goto Exit;
2216 }
2217
2218 if ( woff2.uncompressed_size > sfnt_size )
2219 {
2220 FT_ERROR(( "woff2_open_font: SFNT table lengths are too large.\n" ));
2221 error = FT_THROW( Invalid_Table );
2222 goto Exit;
2223 }
2224
2225 /* Allocate memory for uncompressed table data. */
2226 if ( FT_ALLOC( uncompressed_buf, woff2.uncompressed_size ) ||
2228 goto Exit;
2229
2230 /* Uncompress the stream. */
2231 error = woff2_decompress( uncompressed_buf,
2232 woff2.uncompressed_size,
2233 stream->cursor,
2234 woff2.totalCompressedSize );
2235
2236 FT_FRAME_EXIT();
2237
2238 if ( error )
2239 goto Exit;
2240
2241 error = reconstruct_font( uncompressed_buf,
2242 woff2.uncompressed_size,
2243 indices,
2244 &woff2,
2245 &info,
2246 &sfnt,
2247 &sfnt_size,
2248 memory );
2249
2250 if ( error )
2251 goto Exit;
2252
2253 /* Resize `sfnt' to actual size of sfnt stream. */
2254 if ( woff2.actual_sfnt_size < sfnt_size )
2255 {
2256 FT_TRACE5(( "Trimming sfnt stream from %lu to %lu.\n",
2257 sfnt_size, woff2.actual_sfnt_size ));
2258 if ( FT_REALLOC( sfnt,
2259 (FT_ULong)( sfnt_size ),
2260 (FT_ULong)( woff2.actual_sfnt_size ) ) )
2261 goto Exit;
2262 }
2263
2264 /* `reconstruct_font' has done all the work. */
2265 /* Swap out stream and return. */
2266 FT_Stream_OpenMemory( sfnt_stream, sfnt, woff2.actual_sfnt_size );
2267 sfnt_stream->memory = stream->memory;
2268 sfnt_stream->close = stream_close;
2269
2271 face->root.stream,
2272 ( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );
2273
2274 face->root.stream = sfnt_stream;
2275 face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
2276
2277 /* Set face_index to 0 or -1. */
2278 if ( *face_instance_index >= 0 )
2279 *face_instance_index = 0;
2280 else
2281 *face_instance_index = -1;
2282
2283 FT_TRACE2(( "woff2_open_font: SFNT synthesized.\n" ));
2284
2285 Exit:
2286 FT_FREE( tables );
2287 FT_FREE( indices );
2288 FT_FREE( uncompressed_buf );
2289 FT_FREE( info.x_mins );
2290
2291 if ( woff2.ttc_fonts )
2292 {
2293 WOFF2_TtcFont ttc_font = woff2.ttc_fonts;
2294
2295
2296 for ( nn = 0; nn < woff2.num_fonts; nn++ )
2297 {
2298 FT_FREE( ttc_font->table_indices );
2299 ttc_font++;
2300 }
2301
2302 FT_FREE( woff2.ttc_fonts );
2303 }
2304
2305 if ( error )
2306 {
2307 FT_FREE( sfnt );
2308 if ( sfnt_stream )
2309 {
2310 FT_Stream_Close( sfnt_stream );
2311 FT_FREE( sfnt_stream );
2312 }
2313 }
2314
2315 return error;
2316 }
#define NULL
Definition: types.h:112
struct nls_table * tables
Definition: nls_base.c:22
#define FT_FACE_FLAG_EXTERNAL_STREAM
Definition: freetype.h:1207
return FT_Err_Ok
Definition: ftbbox.c:526
#define FT_ASSERT(condition)
Definition: ftdebug.h:241
#define FT_ERROR(varformat)
Definition: ftdebug.h:211
#define FT_TRACE5(varformat)
Definition: ftdebug.h:192
#define FT_TRACE6(varformat)
Definition: ftdebug.h:193
#define FT_THROW(e)
Definition: ftdebug.h:243
#define FT_TRACE2(varformat)
Definition: ftdebug.h:189
#define FT_TRACE4(varformat)
Definition: ftdebug.h:191
#define FT_REALLOC(ptr, cursz, newsz)
Definition: ftmemory.h:314
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:341
#define FT_NEW(ptr)
Definition: ftmemory.h:339
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:311
#define FT_FREE(ptr)
Definition: ftmemory.h:337
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
Definition: ftmemory.h:344
#define FT_ABS(a)
Definition: ftobjs.h:73
#define ft_qsort
Definition: ftstdlib.h:122
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:548
#define FT_FRAME_END
Definition: ftstream.h:118
#define FT_READ_ULONG(var)
Definition: ftstream.h:343
#define FT_STREAM_POS()
Definition: ftstream.h:522
FT_Stream_Close(FT_Stream stream)
Definition: ftstream.c:48
#define FT_FRAME_ULONG(f)
Definition: ftstream.h:121
#define FT_READ_BYTE(var)
Definition: ftstream.h:336
#define FT_FRAME_EXIT()
Definition: ftstream.h:553
#define FT_FRAME_SKIP_BYTES(count)
Definition: ftstream.h:147
#define FT_STREAM_READ_FIELDS(fields, object)
Definition: ftstream.h:544
FT_Stream_Free(FT_Stream stream, FT_Int external)
Definition: ftobjs.c:257
#define FT_FRAME_START(size)
Definition: ftstream.h:117
FT_Stream_OpenMemory(FT_Stream stream, const FT_Byte *base, FT_ULong size)
Definition: ftstream.c:34
#define FT_FRAME_USHORT(f)
Definition: ftstream.h:123
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:64
signed char FT_Char
Definition: fttypes.h:143
unsigned long FT_ULong
Definition: fttypes.h:253
unsigned char FT_Byte
Definition: fttypes.h:154
int FT_Error
Definition: fttypes.h:299
unsigned short FT_UShort
Definition: fttypes.h:209
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
if(dx< 0)
Definition: linetemp.h:194
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:122
static FT_Error woff2_decompress(FT_Byte *dst, FT_ULong dst_size, const FT_Byte *src, FT_ULong src_size)
Definition: sfwoff2.c:314
#define WRITE_ULONG(p, v)
Definition: sfwoff2.c:57
#define READ_255USHORT(var)
Definition: sfwoff2.c:42
#define ROUND4(var)
Definition: sfwoff2.c:47
static FT_ULong compute_ULong_sum(FT_Byte *buf, FT_ULong size)
Definition: sfwoff2.c:285
static FT_Error reconstruct_font(FT_Byte *transformed_buf, FT_ULong transformed_buf_size, WOFF2_Table *indices, WOFF2_Header woff2, WOFF2_Info info, FT_Byte **sfnt_bytes, FT_ULong *sfnt_size, FT_Memory memory)
Definition: sfwoff2.c:1504
compare_tags(const void *a, const void *b)
Definition: sfwoff2.c:105
#define READ_BASE128(var)
Definition: sfwoff2.c:44
static void stream_close(FT_Stream stream)
Definition: sfwoff2.c:91
#define WRITE_USHORT(p, v)
Definition: sfwoff2.c:49
#define WOFF2_FLAGS_TRANSFORM
Definition: sfwoff2.h:31
static void Exit(void)
Definition: sock.c:1330
FT_Memory memory
Definition: ftsystem.h:338
FT_Stream_CloseFunc close
Definition: ftsystem.h:336
FT_ULong metaOffset
Definition: wofftypes.h:161
FT_ULong metaOrigLength
Definition: wofftypes.h:163
FT_ULong totalCompressedSize
Definition: wofftypes.h:160
FT_UShort num_fonts
Definition: wofftypes.h:170
FT_ULong actual_sfnt_size
Definition: wofftypes.h:171
FT_ULong totalSfntSize
Definition: wofftypes.h:159
FT_ULong privLength
Definition: wofftypes.h:165
FT_ULong length
Definition: wofftypes.h:157
WOFF2_TtcFont ttc_fonts
Definition: wofftypes.h:173
FT_ULong signature
Definition: wofftypes.h:155
FT_UShort num_tables
Definition: wofftypes.h:158
FT_ULong metaLength
Definition: wofftypes.h:162
FT_ULong flavor
Definition: wofftypes.h:156
FT_ULong header_version
Definition: wofftypes.h:169
FT_ULong privOffset
Definition: wofftypes.h:164
FT_ULong compressed_offset
Definition: wofftypes.h:168
FT_ULong uncompressed_size
Definition: wofftypes.h:167
FT_ULong src_length
Definition: wofftypes.h:200
FT_ULong src_offset
Definition: wofftypes.h:199
FT_UShort * table_indices
Definition: wofftypes.h:129
FT_UShort num_tables
Definition: wofftypes.h:128
FT_ULong flavor
Definition: wofftypes.h:127
Definition: parse.h:23
unsigned int size
Definition: parse.h:27
SFNT_Service sfnt
Definition: ttdriver.c:208
#define TTAG_ttcf
Definition: tttags.h:101
#define TTAG_glyf
Definition: tttags.h:62
#define TTAG_wOF2
Definition: tttags.h:109
#define TTAG_loca
Definition: tttags.h:75
woff2_known_tags(FT_Byte index)
Definition: woff2tags.c:32
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by sfnt_open_font().