839 {
842
843
845
847
857
858 const FT_ULong glyf_start = *out_offset;
860
862
867
868
871
878
879 FT_TRACE4((
"num_glyphs = %u; index_format = %u\n",
880 num_glyphs, index_format ));
881
882 info->num_glyphs = num_glyphs;
883
884
885
886
887
888 expected_loca_length = ( index_format ? 4 : 2 ) *
890 if (
info->loca_table->dst_length != expected_loca_length )
892
893 offset = ( 2 + num_substreams ) * 4;
894 if (
offset >
info->glyf_table->TransformLength )
896
897 for (
i = 0;
i < num_substreams; ++
i )
898 {
900
901
904 if ( substream_size >
info->glyf_table->TransformLength -
offset )
906
909 substreams[
i].
size = substream_size;
910
911 FT_TRACE5((
" Substream %d: offset = %lu; size = %lu;\n",
914 }
915
918
919 points_size = 0;
921
922
923 bitmap_length = ( ( num_glyphs + 31U ) >> 5 ) << 2;
925
929
932
933 for (
i = 0;
i < num_glyphs; ++
i )
934 {
941
942
943
944 bbox_offset = bbox_bitmap_offset + (
i >> 3 );
948 if ( bbox_bitmap & ( 0x80 >> (
i & 7 ) ) )
950
951
956
957 if ( n_contours == 0xffff )
958 {
959
965
966
967
968 if ( !have_bbox )
970
973 &composite_size,
974 &have_instructions) )
976
977 if ( have_instructions )
978 {
983 }
984
985 size_needed = 12 + composite_size + instruction_size;
986 if ( glyph_buf_size < size_needed )
987 {
990 glyph_buf_size = size_needed;
991 }
992
993 pointer = glyph_buf + glyph_size;
995 glyph_size += 2;
996
997
1001
1002
1006
1008 glyph_size += 8;
1009
1013
1015 glyph_size += composite_size;
1016
1017 if ( have_instructions )
1018 {
1019 pointer = glyph_buf + glyph_size;
1021 glyph_size += 2;
1022
1026
1028 glyph_size += instruction_size;
1029 }
1030 }
1031 else if ( n_contours > 0 )
1032 {
1033
1046
1048
1049
1052
1055
1056 for (
j = 0;
j < n_contours; ++
j )
1057 {
1060 n_points_arr[
j] = n_points_contour;
1061
1062 if ( total_n_points + n_points_contour < total_n_points )
1064 total_n_points += n_points_contour;
1065 }
1067
1068 flag_size = total_n_points;
1071
1074
1079
1083 triplet_bytes_used = 0;
1084
1085
1086 points_size = total_n_points;
1089
1091 triplet_buf,
1092 triplet_size,
1093 total_n_points,
1095 &triplet_bytes_used ) )
1097
1100
1104
1106
1107 if ( total_n_points >= ( 1 << 27 ) )
1109
1110 size_needed = 12 +
1111 ( 2 * n_contours ) +
1112 ( 5 * total_n_points ) +
1113 instruction_size;
1114 if ( glyph_buf_size < size_needed )
1115 {
1118 glyph_buf_size = size_needed;
1119 }
1120
1121 pointer = glyph_buf + glyph_size;
1123 glyph_size += 2;
1124
1125 if ( have_bbox )
1126 {
1127
1131
1132
1137 }
1138 else
1140
1142
1143 pointer = glyph_buf + glyph_size;
1144 end_point = -1;
1145
1146 for ( contour_ix = 0; contour_ix < n_contours; ++contour_ix )
1147 {
1148 end_point += n_points_arr[contour_ix];
1149 if ( end_point >= 65536 )
1151
1153 glyph_size += 2;
1154 }
1155
1157 glyph_size += 2;
1158
1162
1164 glyph_size += instruction_size;
1165
1168 n_contours,
1169 instruction_size,
1170 glyph_buf,
1171 glyph_buf_size,
1172 &glyph_size ) )
1174
1177 }
1178 else
1179 {
1180
1181
1182 if ( have_bbox )
1183 {
1184 FT_ERROR((
"Empty glyph has a bbox.\n" ));
1186 }
1187 }
1188
1189 loca_values[
i] = dest_offset - glyf_start;
1190
1193
1196
1198
1199
1200 if ( n_contours > 0 )
1202 }
1203
1204 info->glyf_table->dst_length = dest_offset -
info->glyf_table->dst_offset;
1205 info->loca_table->dst_offset = dest_offset;
1206
1207
1208 loca_values[num_glyphs] =
info->glyf_table->dst_length;
1209
1211 num_glyphs + 1,
1212 index_format,
1213 loca_checksum,
1215 sfnt_size,
1216 &dest_offset,
1219
1220 info->loca_table->dst_length = dest_offset -
info->loca_table->dst_offset;
1221
1223 FT_TRACE4((
" dst_offset = %lu\n",
info->loca_table->dst_offset ));
1224 FT_TRACE4((
" dst_length = %lu\n",
info->loca_table->dst_length ));
1225 FT_TRACE4((
" checksum = %09lx\n", *loca_checksum ));
1226
1227
1229 *out_offset = dest_offset;
1230
1236
1238
1242
1243
1245
1251
1253 }
#define FT_TRACE5(varformat)
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
#define FT_STREAM_READ(buffer, count)
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 void compute_bbox(FT_ULong n_points, const WOFF2_Point points, FT_Byte *dst, FT_UShort *src_x_min)
#define INSTRUCTION_STREAM
#define READ_255USHORT(var)
static FT_Error store_loca(FT_ULong *loca_values, FT_ULong loca_values_size, FT_UShort index_format, FT_ULong *checksum, FT_Byte **sfnt_bytes, FT_ULong *sfnt_size, FT_ULong *out_offset, FT_Memory memory)
static FT_Error store_points(FT_ULong n_points, const WOFF2_Point points, FT_UShort n_contours, FT_UShort instruction_len, FT_Byte *dst, FT_ULong dst_size, FT_ULong *glyph_size)
static FT_Error triplet_decode(const FT_Byte *flags_in, const FT_Byte *in, FT_ULong in_size, FT_ULong n_points, WOFF2_Point result, FT_ULong *in_bytes_used)
#define WRITE_USHORT(p, v)
static FT_Error compositeGlyph_size(FT_Stream stream, FT_ULong offset, FT_ULong *size, FT_Bool *have_instructions)
#define WOFF2_DEFAULT_GLYPH_BUF
#define CONTOUR_OFFSET_END_POINT