Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gdef.h" | 5 #include "gdef.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "layout.h" | 9 #include "layout.h" |
| 10 #include "maxp.h" | 10 #include "maxp.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 uint16_t mark_set_count = 0; | 199 uint16_t mark_set_count = 0; |
| 200 if (!subtable.ReadU16(&format) || | 200 if (!subtable.ReadU16(&format) || |
| 201 !subtable.ReadU16(&mark_set_count)) { | 201 !subtable.ReadU16(&mark_set_count)) { |
| 202 return OTS_FAILURE(); | 202 return OTS_FAILURE(); |
| 203 } | 203 } |
| 204 if (format != 1) { | 204 if (format != 1) { |
| 205 OTS_WARNING("bad mark glyph set table format: %u", format); | 205 OTS_WARNING("bad mark glyph set table format: %u", format); |
| 206 return OTS_FAILURE(); | 206 return OTS_FAILURE(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 const unsigned mark_sets_end = static_cast<unsigned>(4) + 2*mark_set_count; | 209 const unsigned mark_sets_end = static_cast<unsigned>(4) + 2*mark_set_count; |
|
Yusuke Sato
2011/02/04 06:12:52
since file->gdef->num_mark_glyph_sets is 16bit uns
bashi
2011/02/07 01:17:07
Done.
| |
| 210 for (unsigned i = 0; i < mark_set_count; ++i) { | 210 for (unsigned i = 0; i < mark_set_count; ++i) { |
| 211 uint32_t offset_coverage = 0; | 211 uint32_t offset_coverage = 0; |
| 212 if (!subtable.ReadU32(&offset_coverage)) { | 212 if (!subtable.ReadU32(&offset_coverage)) { |
| 213 return OTS_FAILURE(); | 213 return OTS_FAILURE(); |
| 214 } | 214 } |
| 215 if (offset_coverage >= length || | 215 if (offset_coverage >= length || |
| 216 offset_coverage < mark_sets_end) { | 216 offset_coverage < mark_sets_end) { |
| 217 return OTS_FAILURE(); | 217 return OTS_FAILURE(); |
| 218 } | 218 } |
| 219 if (!ots::ParseCoverageTable(data + offset_coverage, | 219 if (!ots::ParseCoverageTable(data + offset_coverage, |
| 220 length - offset_coverage, num_glyphs)) { | 220 length - offset_coverage, num_glyphs)) { |
| 221 return OTS_FAILURE(); | 221 return OTS_FAILURE(); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 file->gdef->num_mark_glyph_sets = mark_set_count; | |
| 224 return true; | 225 return true; |
| 225 } | 226 } |
| 226 | 227 |
| 227 } // namespace | 228 } // namespace |
| 228 | 229 |
| 229 #define DROP_THIS_TABLE \ | 230 #define DROP_THIS_TABLE \ |
| 230 do { delete file->gdef; file->gdef = 0; } while (0) | 231 do { delete file->gdef; file->gdef = 0; } while (0) |
| 231 | 232 |
| 232 namespace ots { | 233 namespace ots { |
| 233 | 234 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 offset_mark_attach_class_def < gdef_header_end) { | 323 offset_mark_attach_class_def < gdef_header_end) { |
| 323 return OTS_FAILURE(); | 324 return OTS_FAILURE(); |
| 324 } | 325 } |
| 325 if (!ParseMarkAttachClassDefTable(file, | 326 if (!ParseMarkAttachClassDefTable(file, |
| 326 data + offset_mark_attach_class_def, | 327 data + offset_mark_attach_class_def, |
| 327 length - offset_mark_attach_class_def, | 328 length - offset_mark_attach_class_def, |
| 328 num_glyphs)) { | 329 num_glyphs)) { |
| 329 DROP_THIS_TABLE; | 330 DROP_THIS_TABLE; |
| 330 return true; | 331 return true; |
| 331 } | 332 } |
| 333 gdef->has_mark_attachment_class_def = true; | |
| 332 } | 334 } |
| 333 | 335 |
| 334 if (offset_mark_glyph_sets_def) { | 336 if (offset_mark_glyph_sets_def) { |
| 335 if (offset_mark_glyph_sets_def >= length || | 337 if (offset_mark_glyph_sets_def >= length || |
| 336 offset_mark_glyph_sets_def < gdef_header_end) { | 338 offset_mark_glyph_sets_def < gdef_header_end) { |
| 337 return OTS_FAILURE(); | 339 return OTS_FAILURE(); |
| 338 } | 340 } |
| 339 if (!ParseMarkGlyphSetsDefTable(file, | 341 if (!ParseMarkGlyphSetsDefTable(file, |
| 340 data + offset_mark_glyph_sets_def, | 342 data + offset_mark_glyph_sets_def, |
| 341 length - offset_mark_glyph_sets_def, | 343 length - offset_mark_glyph_sets_def, |
| 342 num_glyphs)) { | 344 num_glyphs)) { |
| 343 DROP_THIS_TABLE; | 345 DROP_THIS_TABLE; |
| 344 return true; | 346 return true; |
| 345 } | 347 } |
| 348 gdef->has_mark_glyph_sets_def = true; | |
| 346 } | 349 } |
| 347 gdef->data = data; | 350 gdef->data = data; |
| 348 gdef->length = length; | 351 gdef->length = length; |
| 349 return true; | 352 return true; |
| 350 } | 353 } |
| 351 | 354 |
| 352 bool ots_gdef_should_serialise(OpenTypeFile *file) { | 355 bool ots_gdef_should_serialise(OpenTypeFile *file) { |
| 353 return file->gdef != NULL; | 356 return file->gdef != NULL; |
| 354 } | 357 } |
| 355 | 358 |
| 356 bool ots_gdef_serialise(OTSStream *out, OpenTypeFile *file) { | 359 bool ots_gdef_serialise(OTSStream *out, OpenTypeFile *file) { |
| 357 if (!out->Write(file->gdef->data, file->gdef->length)) { | 360 if (!out->Write(file->gdef->data, file->gdef->length)) { |
| 358 return OTS_FAILURE(); | 361 return OTS_FAILURE(); |
| 359 } | 362 } |
| 360 | 363 |
| 361 return true; | 364 return true; |
| 362 } | 365 } |
| 363 | 366 |
| 364 void ots_gdef_free(OpenTypeFile *file) { | 367 void ots_gdef_free(OpenTypeFile *file) { |
| 365 delete file->gdef; | 368 delete file->gdef; |
| 366 } | 369 } |
| 367 | 370 |
| 368 } // namespace ots | 371 } // namespace ots |
| 369 | 372 |
| OLD | NEW |