1754 {
1758
1765
1771
1774 FT_UInt32 file_offset;
1775
1780
1782
1784 {
1785#undef FT_STRUCTURE
1786#define FT_STRUCTURE WOFF2_HeaderRec
1787
1803 };
1804
1805
1808
1809 face_index =
FT_ABS( *face_instance_index ) & 0xFFFF;
1810
1811
1814
1824
1825
1828
1829
1841 {
1842 FT_ERROR((
"woff2_open_font: invalid WOFF2 header\n" ));
1844 }
1845
1846 FT_TRACE2((
"woff2_open_font: WOFF2 Header is valid.\n" ));
1847
1849
1850
1854
1856 "\n"
1857 " tag flags transform origLen transformLen offset\n"
1858 " -----------------------------------------------------------\n" ));
1859
1860
1862 {
1864
1865
1868
1869 if ( (
table->FlagByte & 0x3f ) == 0x3f )
1870 {
1873 }
1874 else
1875 {
1878 {
1879 FT_ERROR((
"woff2_open_font: Unknown table tag." ));
1882 }
1883 }
1884
1886 xform_version = (
table->FlagByte >> 6 ) & 0x03;
1887
1888
1890 {
1891 if ( xform_version == 0 )
1893 }
1894 else if ( xform_version != 0 )
1896
1897 flags |= xform_version;
1898
1901
1903
1905 {
1908
1910 {
1911 FT_ERROR((
"woff2_open_font: Invalid loca `transformLength'.\n" ));
1914 }
1915 }
1916
1917 if ( src_offset +
table->TransformLength < src_offset )
1918 {
1919 FT_ERROR((
"woff2_open_font: invalid WOFF2 table directory.\n" ));
1922 }
1923
1924 table->src_offset = src_offset;
1926 src_offset +=
table->TransformLength;
1928
1929 FT_TRACE2((
" %c%c%c%c %08d %08d %08ld %08ld %08ld\n",
1934 table->FlagByte & 0x3f,
1935 (
table->FlagByte >> 6 ) & 0x03,
1937 table->TransformLength,
1938 table->src_offset ));
1939
1941 }
1942
1943
1945
1949 {
1952 }
1953
1954 FT_TRACE2((
"Table directory parsed.\n" ));
1955
1956
1959
1961 {
1962 FT_TRACE2((
"Font is a TTC, reading collection directory.\n" ));
1963
1966
1969 {
1972 }
1973
1976
1978 {
1981 }
1982
1984
1987
1988 for ( nn = 0; nn < woff2.
num_fonts; nn++ )
1989 {
1991
1992
1997
2000
2001 FT_TRACE5((
"Number of tables in font %d: %d\n",
2003
2004#ifdef FT_DEBUG_LEVEL_TRACE
2007#endif
2008
2009 glyf_index = 0;
2010 loca_index = 0;
2011
2013 {
2016
2017
2020
2023 {
2024 FT_ERROR((
"woff2_open_font: invalid table index\n" ));
2027 }
2028
2030
2033 loca_index = table_index;
2035 glyf_index = table_index;
2036 }
2037
2038#ifdef FT_DEBUG_LEVEL_TRACE
2041#endif
2042
2043
2044 if ( glyf_index > 0 || loca_index > 0 )
2045 {
2046 if ( glyf_index > loca_index ||
2047 loca_index - glyf_index != 1 )
2048 {
2051 }
2052 }
2053 }
2054
2055
2056 FT_TRACE2((
"WOFF2 collection directory is valid.\n" ));
2057 }
2058 else
2060
2064
2065
2066 if ( file_offset > woff2.
length )
2067 {
2070 }
2071
2073 {
2075 {
2078 }
2080 }
2081
2083 {
2085 {
2088 }
2090 }
2091
2093 {
2096 }
2097
2098
2100
2101 if ( *face_instance_index < 0 )
2102 face_index--;
2103
2105 {
2106 if ( *face_instance_index >= 0 )
2107 {
2110 }
2111 else
2112 face_index = 0;
2113 }
2114
2115
2117 {
2119
2120
2121
2125
2126 FT_TRACE4((
"Storing tables for TTC face index %d.\n", face_index ));
2127 for ( nn = 0; nn < ttc_font->
num_tables; nn++ )
2129
2130
2135
2136 for ( nn = 0; nn < ttc_font->
num_tables; nn++ )
2137 indices[nn] = temp_indices[nn];
2138
2140
2141
2144 }
2145
2146
2148
2149
2151 {
2152
2153
2154
2156 sfnt_size = woff2.
length << 6;
2157 else
2159
2160
2161 if (sfnt_size >= (1 << 26))
2162 sfnt_size = 1 << 26;
2163
2164#ifdef FT_DEBUG_LEVEL_TRACE
2166 FT_TRACE4((
"adjusting estimate of uncompressed font size"
2167 " to %lu bytes\n",
2168 sfnt_size ));
2169#endif
2170 }
2171
2172
2176
2178
2180
2182 {
2183 FT_UInt searchRange, entrySelector, rangeShift,
x;
2184
2185
2187 entrySelector = 0;
2189 {
2191 entrySelector += 1;
2192 }
2193 entrySelector--;
2194
2195 searchRange = ( 1 << entrySelector ) * 16;
2196 rangeShift = ( woff2.
num_tables * 16 ) - searchRange;
2197
2202 }
2203
2205
2206
2211
2213 {
2216 }
2217
2219 {
2220 FT_ERROR((
"woff2_open_font: SFNT table lengths are too large.\n" ));
2223 }
2224
2225
2229
2230
2235
2237
2240
2244 &woff2,
2247 &sfnt_size,
2249
2252
2253
2255 {
2256 FT_TRACE5((
"Trimming sfnt stream from %lu to %lu.\n",
2262 }
2263
2264
2265
2269
2273
2274 face->root.stream = sfnt_stream;
2275 face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
2276
2277
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
2290
2292 {
2294
2295
2296 for ( nn = 0; nn < woff2.
num_fonts; nn++ )
2297 {
2299 ttc_font++;
2300 }
2301
2303 }
2304
2306 {
2308 if ( sfnt_stream )
2309 {
2312 }
2313 }
2314
2316 }
struct nls_table * tables
#define FT_FACE_FLAG_EXTERNAL_STREAM
#define FT_ASSERT(condition)
#define FT_ERROR(varformat)
#define FT_TRACE5(varformat)
#define FT_TRACE6(varformat)
#define FT_TRACE2(varformat)
#define FT_TRACE4(varformat)
#define FT_REALLOC(ptr, cursz, newsz)
#define FT_NEW_ARRAY(ptr, count)
#define FT_ALLOC(ptr, size)
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
#define FT_FRAME_ENTER(size)
#define FT_READ_ULONG(var)
FT_Stream_Close(FT_Stream stream)
#define FT_FRAME_ULONG(f)
#define FT_READ_BYTE(var)
#define FT_FRAME_SKIP_BYTES(count)
#define FT_STREAM_READ_FIELDS(fields, object)
FT_Stream_Free(FT_Stream stream, FT_Int external)
#define FT_FRAME_START(size)
FT_Stream_OpenMemory(FT_Stream stream, const FT_Byte *base, FT_ULong size)
#define FT_FRAME_USHORT(f)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei GLenum const GLvoid * indices
GLenum GLuint GLint GLenum face
GLuint GLsizei GLsizei * length
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
static char memory[1024 *256]
static FT_Error woff2_decompress(FT_Byte *dst, FT_ULong dst_size, const FT_Byte *src, FT_ULong src_size)
#define WRITE_ULONG(p, v)
#define READ_255USHORT(var)
static FT_ULong compute_ULong_sum(FT_Byte *buf, FT_ULong size)
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)
compare_tags(const void *a, const void *b)
#define READ_BASE128(var)
static void stream_close(FT_Stream stream)
#define WRITE_USHORT(p, v)
#define WOFF2_FLAGS_TRANSFORM
FT_Stream_CloseFunc close
FT_UShort * table_indices
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList