| Index: third_party/ots/src/gpos.cc
|
| diff --git a/third_party/ots/src/gpos.cc b/third_party/ots/src/gpos.cc
|
| index a2b968726e2793b52e1574fffbbf999819e1c286..2625ec8966a7b3c2c92db475f1c75991c3a6341b 100644
|
| --- a/third_party/ots/src/gpos.cc
|
| +++ b/third_party/ots/src/gpos.cc
|
| @@ -38,23 +38,23 @@ const uint16_t kMaxAnchorFormat = 3;
|
| const uint16_t kMaxClassDefValue = 0xFFFF;
|
|
|
| // Lookup type parsers.
|
| -bool ParseSingleAdjustment(const ots::OpenTypeFile *file,
|
| +bool ParseSingleAdjustment(const ots::Font *font,
|
| const uint8_t *data, const size_t length);
|
| -bool ParsePairAdjustment(const ots::OpenTypeFile *file,
|
| +bool ParsePairAdjustment(const ots::Font *font,
|
| const uint8_t *data, const size_t length);
|
| -bool ParseCursiveAttachment(const ots::OpenTypeFile *file,
|
| +bool ParseCursiveAttachment(const ots::Font *font,
|
| const uint8_t *data, const size_t length);
|
| -bool ParseMarkToBaseAttachment(const ots::OpenTypeFile *file,
|
| +bool ParseMarkToBaseAttachment(const ots::Font *font,
|
| const uint8_t *data, const size_t length);
|
| -bool ParseMarkToLigatureAttachment(const ots::OpenTypeFile *file,
|
| +bool ParseMarkToLigatureAttachment(const ots::Font *font,
|
| const uint8_t *data, const size_t length);
|
| -bool ParseMarkToMarkAttachment(const ots::OpenTypeFile *file,
|
| +bool ParseMarkToMarkAttachment(const ots::Font *font,
|
| const uint8_t *data, const size_t length);
|
| -bool ParseContextPositioning(const ots::OpenTypeFile *file,
|
| +bool ParseContextPositioning(const ots::Font *font,
|
| const uint8_t *data, const size_t length);
|
| -bool ParseChainedContextPositioning(const ots::OpenTypeFile *file,
|
| +bool ParseChainedContextPositioning(const ots::Font *font,
|
| const uint8_t *data, const size_t length);
|
| -bool ParseExtensionPositioning(const ots::OpenTypeFile *file,
|
| +bool ParseExtensionPositioning(const ots::Font *font,
|
| const uint8_t *data, const size_t length);
|
|
|
| const ots::LookupSubtableParser::TypeParser kGposTypeParsers[] = {
|
| @@ -76,7 +76,7 @@ const ots::LookupSubtableParser kGposLookupSubtableParser = {
|
|
|
| // Shared Tables: ValueRecord, Anchor Table, and MarkArray
|
|
|
| -bool ParseValueRecord(const ots::OpenTypeFile *file,
|
| +bool ParseValueRecord(const ots::Font *font,
|
| ots::Buffer* subtable, const uint8_t *data,
|
| const size_t length, const uint16_t value_format) {
|
| // Check existence of adjustment fields.
|
| @@ -102,7 +102,7 @@ bool ParseValueRecord(const ots::OpenTypeFile *file,
|
| if (offset >= length) {
|
| return OTS_FAILURE_MSG("Value record offset too high %d >= %ld", offset, length);
|
| }
|
| - if (!ots::ParseDeviceTable(file, data + offset, length - offset)) {
|
| + if (!ots::ParseDeviceTable(font, data + offset, length - offset)) {
|
| return OTS_FAILURE_MSG("Failed to parse device table in value record");
|
| }
|
| }
|
| @@ -111,7 +111,7 @@ bool ParseValueRecord(const ots::OpenTypeFile *file,
|
| return true;
|
| }
|
|
|
| -bool ParseAnchorTable(const ots::OpenTypeFile *file,
|
| +bool ParseAnchorTable(const ots::Font *font,
|
| const uint8_t *data, const size_t length) {
|
| ots::Buffer subtable(data, length);
|
|
|
| @@ -146,7 +146,7 @@ bool ParseAnchorTable(const ots::OpenTypeFile *file,
|
| if (offset_x_device < format_end || offset_x_device >= length) {
|
| return OTS_FAILURE_MSG("Bad x device table offset %d", offset_x_device);
|
| }
|
| - if (!ots::ParseDeviceTable(file, data + offset_x_device,
|
| + if (!ots::ParseDeviceTable(font, data + offset_x_device,
|
| length - offset_x_device)) {
|
| return OTS_FAILURE_MSG("Failed to parse device table in anchor table");
|
| }
|
| @@ -155,7 +155,7 @@ bool ParseAnchorTable(const ots::OpenTypeFile *file,
|
| if (offset_y_device < format_end || offset_y_device >= length) {
|
| return OTS_FAILURE_MSG("Bad y device table offset %d", offset_y_device);
|
| }
|
| - if (!ots::ParseDeviceTable(file, data + offset_y_device,
|
| + if (!ots::ParseDeviceTable(font, data + offset_y_device,
|
| length - offset_y_device)) {
|
| return OTS_FAILURE_MSG("Failed to parse device table in anchor table");
|
| }
|
| @@ -164,7 +164,7 @@ bool ParseAnchorTable(const ots::OpenTypeFile *file,
|
| return true;
|
| }
|
|
|
| -bool ParseMarkArrayTable(const ots::OpenTypeFile *file,
|
| +bool ParseMarkArrayTable(const ots::Font *font,
|
| const uint8_t *data, const size_t length,
|
| const uint16_t class_count) {
|
| ots::Buffer subtable(data, length);
|
| @@ -192,7 +192,7 @@ bool ParseMarkArrayTable(const ots::OpenTypeFile *file,
|
| offset_mark_anchor >= length) {
|
| return OTS_FAILURE_MSG("Bad mark anchor offset %d for mark table %d", offset_mark_anchor, i);
|
| }
|
| - if (!ParseAnchorTable(file, data + offset_mark_anchor,
|
| + if (!ParseAnchorTable(font, data + offset_mark_anchor,
|
| length - offset_mark_anchor)) {
|
| return OTS_FAILURE_MSG("Faled to parse anchor table for mark table %d", i);
|
| }
|
| @@ -203,7 +203,7 @@ bool ParseMarkArrayTable(const ots::OpenTypeFile *file,
|
|
|
| // Lookup Type 1:
|
| // Single Adjustment Positioning Subtable
|
| -bool ParseSingleAdjustment(const ots::OpenTypeFile *file, const uint8_t *data,
|
| +bool ParseSingleAdjustment(const ots::Font *font, const uint8_t *data,
|
| const size_t length) {
|
| ots::Buffer subtable(data, length);
|
|
|
| @@ -218,7 +218,7 @@ bool ParseSingleAdjustment(const ots::OpenTypeFile *file, const uint8_t *data,
|
|
|
| if (format == 1) {
|
| // Format 1 exactly one value record.
|
| - if (!ParseValueRecord(file, &subtable, data, length, value_format)) {
|
| + if (!ParseValueRecord(font, &subtable, data, length, value_format)) {
|
| return OTS_FAILURE_MSG("Failed to parse format 1 single adjustment table");
|
| }
|
| } else if (format == 2) {
|
| @@ -227,7 +227,7 @@ bool ParseSingleAdjustment(const ots::OpenTypeFile *file, const uint8_t *data,
|
| return OTS_FAILURE_MSG("Failed to parse format 2 single adjustment table");
|
| }
|
| for (unsigned i = 0; i < value_count; ++i) {
|
| - if (!ParseValueRecord(file, &subtable, data, length, value_format)) {
|
| + if (!ParseValueRecord(font, &subtable, data, length, value_format)) {
|
| return OTS_FAILURE_MSG("Failed to parse value record %d in format 2 single adjustment table", i);
|
| }
|
| }
|
| @@ -239,16 +239,16 @@ bool ParseSingleAdjustment(const ots::OpenTypeFile *file, const uint8_t *data,
|
| return OTS_FAILURE_MSG("Bad coverage offset %d in single adjustment table", offset_coverage);
|
| }
|
|
|
| - if (!ots::ParseCoverageTable(file, data + offset_coverage,
|
| + if (!ots::ParseCoverageTable(font, data + offset_coverage,
|
| length - offset_coverage,
|
| - file->maxp->num_glyphs)) {
|
| + font->maxp->num_glyphs)) {
|
| return OTS_FAILURE_MSG("Failed to parse coverage table in single adjustment table");
|
| }
|
|
|
| return true;
|
| }
|
|
|
| -bool ParsePairSetTable(const ots::OpenTypeFile *file,
|
| +bool ParsePairSetTable(const ots::Font *font,
|
| const uint8_t *data, const size_t length,
|
| const uint16_t value_format1,
|
| const uint16_t value_format2,
|
| @@ -268,17 +268,17 @@ bool ParsePairSetTable(const ots::OpenTypeFile *file,
|
| if (glyph_id >= num_glyphs) {
|
| return OTS_FAILURE_MSG("glyph id %d too high >= %d", glyph_id, num_glyphs);
|
| }
|
| - if (!ParseValueRecord(file, &subtable, data, length, value_format1)) {
|
| + if (!ParseValueRecord(font, &subtable, data, length, value_format1)) {
|
| return OTS_FAILURE_MSG("Failed to parse value record in format 1 pair set table");
|
| }
|
| - if (!ParseValueRecord(file, &subtable, data, length, value_format2)) {
|
| + if (!ParseValueRecord(font, &subtable, data, length, value_format2)) {
|
| return OTS_FAILURE_MSG("Failed to parse value record in format 2 pair set table");
|
| }
|
| }
|
| return true;
|
| }
|
|
|
| -bool ParsePairPosFormat1(const ots::OpenTypeFile *file,
|
| +bool ParsePairPosFormat1(const ots::Font *font,
|
| const uint8_t *data, const size_t length,
|
| const uint16_t value_format1,
|
| const uint16_t value_format2,
|
| @@ -308,7 +308,7 @@ bool ParsePairPosFormat1(const ots::OpenTypeFile *file,
|
| return OTS_FAILURE_MSG("Bad pair set offset %d for pair set %d", pair_set_offset, i);
|
| }
|
| // Check pair set tables
|
| - if (!ParsePairSetTable(file, data + pair_set_offset, length - pair_set_offset,
|
| + if (!ParsePairSetTable(font, data + pair_set_offset, length - pair_set_offset,
|
| value_format1, value_format2,
|
| num_glyphs)) {
|
| return OTS_FAILURE_MSG("Failed to parse pair set table %d", i);
|
| @@ -318,7 +318,7 @@ bool ParsePairPosFormat1(const ots::OpenTypeFile *file,
|
| return true;
|
| }
|
|
|
| -bool ParsePairPosFormat2(const ots::OpenTypeFile *file,
|
| +bool ParsePairPosFormat2(const ots::Font *font,
|
| const uint8_t *data, const size_t length,
|
| const uint16_t value_format1,
|
| const uint16_t value_format2,
|
| @@ -345,11 +345,11 @@ bool ParsePairPosFormat2(const ots::OpenTypeFile *file,
|
| for (unsigned i = 0; i < class1_count; ++i) {
|
| // Check class 2 records.
|
| for (unsigned j = 0; j < class2_count; ++j) {
|
| - if (value_format1 && !ParseValueRecord(file, &subtable, data, length,
|
| + if (value_format1 && !ParseValueRecord(font, &subtable, data, length,
|
| value_format1)) {
|
| return OTS_FAILURE_MSG("Failed to parse value record 1 %d and %d", j, i);
|
| }
|
| - if (value_format2 && !ParseValueRecord(file, &subtable, data, length,
|
| + if (value_format2 && !ParseValueRecord(font, &subtable, data, length,
|
| value_format2)) {
|
| return OTS_FAILURE_MSG("Falied to parse value record 2 %d and %d", j, i);
|
| }
|
| @@ -361,12 +361,12 @@ bool ParsePairPosFormat2(const ots::OpenTypeFile *file,
|
| offset_class_def2 < subtable.offset() || offset_class_def2 >= length) {
|
| return OTS_FAILURE_MSG("Bad class definition table offsets %d or %d", offset_class_def1, offset_class_def2);
|
| }
|
| - if (!ots::ParseClassDefTable(file, data + offset_class_def1,
|
| + if (!ots::ParseClassDefTable(font, data + offset_class_def1,
|
| length - offset_class_def1,
|
| num_glyphs, kMaxClassDefValue)) {
|
| return OTS_FAILURE_MSG("Failed to parse class definition table 1");
|
| }
|
| - if (!ots::ParseClassDefTable(file, data + offset_class_def2,
|
| + if (!ots::ParseClassDefTable(font, data + offset_class_def2,
|
| length - offset_class_def2,
|
| num_glyphs, kMaxClassDefValue)) {
|
| return OTS_FAILURE_MSG("Failed to parse class definition table 2");
|
| @@ -377,7 +377,7 @@ bool ParsePairPosFormat2(const ots::OpenTypeFile *file,
|
|
|
| // Lookup Type 2:
|
| // Pair Adjustment Positioning Subtable
|
| -bool ParsePairAdjustment(const ots::OpenTypeFile *file, const uint8_t *data,
|
| +bool ParsePairAdjustment(const ots::Font *font, const uint8_t *data,
|
| const size_t length) {
|
| ots::Buffer subtable(data, length);
|
|
|
| @@ -393,13 +393,13 @@ bool ParsePairAdjustment(const ots::OpenTypeFile *file, const uint8_t *data,
|
| }
|
|
|
| if (format == 1) {
|
| - if (!ParsePairPosFormat1(file, data, length, value_format1, value_format2,
|
| - file->maxp->num_glyphs)) {
|
| + if (!ParsePairPosFormat1(font, data, length, value_format1, value_format2,
|
| + font->maxp->num_glyphs)) {
|
| return OTS_FAILURE_MSG("Failed to parse pair pos format 1");
|
| }
|
| } else if (format == 2) {
|
| - if (!ParsePairPosFormat2(file, data, length, value_format1, value_format2,
|
| - file->maxp->num_glyphs)) {
|
| + if (!ParsePairPosFormat2(font, data, length, value_format1, value_format2,
|
| + font->maxp->num_glyphs)) {
|
| return OTS_FAILURE_MSG("Failed to parse pair format 2");
|
| }
|
| } else {
|
| @@ -409,9 +409,9 @@ bool ParsePairAdjustment(const ots::OpenTypeFile *file, const uint8_t *data,
|
| if (offset_coverage < subtable.offset() || offset_coverage >= length) {
|
| return OTS_FAILURE_MSG("Bad pair pos offset coverage %d", offset_coverage);
|
| }
|
| - if (!ots::ParseCoverageTable(file, data + offset_coverage,
|
| + if (!ots::ParseCoverageTable(font, data + offset_coverage,
|
| length - offset_coverage,
|
| - file->maxp->num_glyphs)) {
|
| + font->maxp->num_glyphs)) {
|
| return OTS_FAILURE_MSG("Failed to parse coverage table");
|
| }
|
|
|
| @@ -420,7 +420,7 @@ bool ParsePairAdjustment(const ots::OpenTypeFile *file, const uint8_t *data,
|
|
|
| // Lookup Type 3
|
| // Cursive Attachment Positioning Subtable
|
| -bool ParseCursiveAttachment(const ots::OpenTypeFile *file, const uint8_t *data,
|
| +bool ParseCursiveAttachment(const ots::Font *font, const uint8_t *data,
|
| const size_t length) {
|
| ots::Buffer subtable(data, length);
|
|
|
| @@ -456,7 +456,7 @@ bool ParseCursiveAttachment(const ots::OpenTypeFile *file, const uint8_t *data,
|
| offset_entry_anchor >= length) {
|
| return OTS_FAILURE_MSG("Bad entry anchor offset %d in entry exit record %d", offset_entry_anchor, i);
|
| }
|
| - if (!ParseAnchorTable(file, data + offset_entry_anchor,
|
| + if (!ParseAnchorTable(font, data + offset_entry_anchor,
|
| length - offset_entry_anchor)) {
|
| return OTS_FAILURE_MSG("Failed to parse entry anchor table in entry exit record %d", i);
|
| }
|
| @@ -466,7 +466,7 @@ bool ParseCursiveAttachment(const ots::OpenTypeFile *file, const uint8_t *data,
|
| offset_exit_anchor >= length) {
|
| return OTS_FAILURE_MSG("Bad exit anchor offset %d in entry exit record %d", offset_exit_anchor, i);
|
| }
|
| - if (!ParseAnchorTable(file, data + offset_exit_anchor,
|
| + if (!ParseAnchorTable(font, data + offset_exit_anchor,
|
| length - offset_exit_anchor)) {
|
| return OTS_FAILURE_MSG("Failed to parse exit anchor table in entry exit record %d", i);
|
| }
|
| @@ -476,16 +476,16 @@ bool ParseCursiveAttachment(const ots::OpenTypeFile *file, const uint8_t *data,
|
| if (offset_coverage < subtable.offset() || offset_coverage >= length) {
|
| return OTS_FAILURE_MSG("Bad coverage offset in cursive attachment %d", offset_coverage);
|
| }
|
| - if (!ots::ParseCoverageTable(file, data + offset_coverage,
|
| + if (!ots::ParseCoverageTable(font, data + offset_coverage,
|
| length - offset_coverage,
|
| - file->maxp->num_glyphs)) {
|
| + font->maxp->num_glyphs)) {
|
| return OTS_FAILURE_MSG("Failed to parse coverage table in cursive attachment");
|
| }
|
|
|
| return true;
|
| }
|
|
|
| -bool ParseAnchorArrayTable(const ots::OpenTypeFile *file,
|
| +bool ParseAnchorArrayTable(const ots::Font *font,
|
| const uint8_t *data, const size_t length,
|
| const uint16_t class_count) {
|
| ots::Buffer subtable(data, length);
|
| @@ -511,7 +511,7 @@ bool ParseAnchorArrayTable(const ots::OpenTypeFile *file,
|
| if (offset_record < anchor_array_end || offset_record >= length) {
|
| return OTS_FAILURE_MSG("Bad record offset %d in class %d, record %d", offset_record, j, i);
|
| }
|
| - if (!ParseAnchorTable(file, data + offset_record,
|
| + if (!ParseAnchorTable(font, data + offset_record,
|
| length - offset_record)) {
|
| return OTS_FAILURE_MSG("Failed to parse anchor table for class %d, record %d", j, i);
|
| }
|
| @@ -521,7 +521,7 @@ bool ParseAnchorArrayTable(const ots::OpenTypeFile *file,
|
| return true;
|
| }
|
|
|
| -bool ParseLigatureArrayTable(const ots::OpenTypeFile *file,
|
| +bool ParseLigatureArrayTable(const ots::Font *font,
|
| const uint8_t *data, const size_t length,
|
| const uint16_t class_count) {
|
| ots::Buffer subtable(data, length);
|
| @@ -538,7 +538,7 @@ bool ParseLigatureArrayTable(const ots::OpenTypeFile *file,
|
| if (offset_ligature_attach < 2 || offset_ligature_attach >= length) {
|
| return OTS_FAILURE_MSG("Bad ligature attachment offset %d in ligature %d", offset_ligature_attach, i);
|
| }
|
| - if (!ParseAnchorArrayTable(file, data + offset_ligature_attach,
|
| + if (!ParseAnchorArrayTable(font, data + offset_ligature_attach,
|
| length - offset_ligature_attach, class_count)) {
|
| return OTS_FAILURE_MSG("Failed to parse anchor table for ligature %d", i);
|
| }
|
| @@ -547,7 +547,7 @@ bool ParseLigatureArrayTable(const ots::OpenTypeFile *file,
|
| }
|
|
|
| // Common parser for Lookup Type 4, 5 and 6.
|
| -bool ParseMarkToAttachmentSubtables(const ots::OpenTypeFile *file,
|
| +bool ParseMarkToAttachmentSubtables(const ots::Font *font,
|
| const uint8_t *data, const size_t length,
|
| const GPOS_TYPE type) {
|
| ots::Buffer subtable(data, length);
|
| @@ -578,24 +578,24 @@ bool ParseMarkToAttachmentSubtables(const ots::OpenTypeFile *file,
|
| if (offset_coverage1 < header_end || offset_coverage1 >= length) {
|
| return OTS_FAILURE_MSG("Bad coverage 1 offset %d", offset_coverage1);
|
| }
|
| - if (!ots::ParseCoverageTable(file, data + offset_coverage1,
|
| + if (!ots::ParseCoverageTable(font, data + offset_coverage1,
|
| length - offset_coverage1,
|
| - file->maxp->num_glyphs)) {
|
| + font->maxp->num_glyphs)) {
|
| return OTS_FAILURE_MSG("Failed to parse converge 1 table");
|
| }
|
| if (offset_coverage2 < header_end || offset_coverage2 >= length) {
|
| return OTS_FAILURE_MSG("Bad coverage 2 offset %d", offset_coverage2);
|
| }
|
| - if (!ots::ParseCoverageTable(file, data + offset_coverage2,
|
| + if (!ots::ParseCoverageTable(font, data + offset_coverage2,
|
| length - offset_coverage2,
|
| - file->maxp->num_glyphs)) {
|
| + font->maxp->num_glyphs)) {
|
| return OTS_FAILURE_MSG("Failed to parse coverage table 2");
|
| }
|
|
|
| if (offset_mark_array < header_end || offset_mark_array >= length) {
|
| return OTS_FAILURE_MSG("Bad mark array offset %d", offset_mark_array);
|
| }
|
| - if (!ParseMarkArrayTable(file, data + offset_mark_array,
|
| + if (!ParseMarkArrayTable(font, data + offset_mark_array,
|
| length - offset_mark_array, class_count)) {
|
| return OTS_FAILURE_MSG("Failed to parse mark array");
|
| }
|
| @@ -606,13 +606,13 @@ bool ParseMarkToAttachmentSubtables(const ots::OpenTypeFile *file,
|
| }
|
| if (type == GPOS_TYPE_MARK_TO_BASE_ATTACHMENT ||
|
| type == GPOS_TYPE_MARK_TO_MARK_ATTACHMENT) {
|
| - if (!ParseAnchorArrayTable(file, data + offset_type_specific_array,
|
| + if (!ParseAnchorArrayTable(font, data + offset_type_specific_array,
|
| length - offset_type_specific_array,
|
| class_count)) {
|
| return OTS_FAILURE_MSG("Failed to parse anchor array");
|
| }
|
| } else if (type == GPOS_TYPE_MARK_TO_LIGATURE_ATTACHMENT) {
|
| - if (!ParseLigatureArrayTable(file, data + offset_type_specific_array,
|
| + if (!ParseLigatureArrayTable(font, data + offset_type_specific_array,
|
| length - offset_type_specific_array,
|
| class_count)) {
|
| return OTS_FAILURE_MSG("Failed to parse ligature array");
|
| @@ -626,50 +626,50 @@ bool ParseMarkToAttachmentSubtables(const ots::OpenTypeFile *file,
|
|
|
| // Lookup Type 4:
|
| // MarkToBase Attachment Positioning Subtable
|
| -bool ParseMarkToBaseAttachment(const ots::OpenTypeFile *file,
|
| +bool ParseMarkToBaseAttachment(const ots::Font *font,
|
| const uint8_t *data, const size_t length) {
|
| - return ParseMarkToAttachmentSubtables(file, data, length,
|
| + return ParseMarkToAttachmentSubtables(font, data, length,
|
| GPOS_TYPE_MARK_TO_BASE_ATTACHMENT);
|
| }
|
|
|
| // Lookup Type 5:
|
| // MarkToLigature Attachment Positioning Subtable
|
| -bool ParseMarkToLigatureAttachment(const ots::OpenTypeFile *file,
|
| +bool ParseMarkToLigatureAttachment(const ots::Font *font,
|
| const uint8_t *data, const size_t length) {
|
| - return ParseMarkToAttachmentSubtables(file, data, length,
|
| + return ParseMarkToAttachmentSubtables(font, data, length,
|
| GPOS_TYPE_MARK_TO_LIGATURE_ATTACHMENT);
|
| }
|
|
|
| // Lookup Type 6:
|
| // MarkToMark Attachment Positioning Subtable
|
| -bool ParseMarkToMarkAttachment(const ots::OpenTypeFile *file,
|
| +bool ParseMarkToMarkAttachment(const ots::Font *font,
|
| const uint8_t *data, const size_t length) {
|
| - return ParseMarkToAttachmentSubtables(file, data, length,
|
| + return ParseMarkToAttachmentSubtables(font, data, length,
|
| GPOS_TYPE_MARK_TO_MARK_ATTACHMENT);
|
| }
|
|
|
| // Lookup Type 7:
|
| // Contextual Positioning Subtables
|
| -bool ParseContextPositioning(const ots::OpenTypeFile *file,
|
| +bool ParseContextPositioning(const ots::Font *font,
|
| const uint8_t *data, const size_t length) {
|
| - return ots::ParseContextSubtable(file, data, length, file->maxp->num_glyphs,
|
| - file->gpos->num_lookups);
|
| + return ots::ParseContextSubtable(font, data, length, font->maxp->num_glyphs,
|
| + font->gpos->num_lookups);
|
| }
|
|
|
| // Lookup Type 8:
|
| // Chaining Contexual Positioning Subtable
|
| -bool ParseChainedContextPositioning(const ots::OpenTypeFile *file,
|
| +bool ParseChainedContextPositioning(const ots::Font *font,
|
| const uint8_t *data, const size_t length) {
|
| - return ots::ParseChainingContextSubtable(file, data, length,
|
| - file->maxp->num_glyphs,
|
| - file->gpos->num_lookups);
|
| + return ots::ParseChainingContextSubtable(font, data, length,
|
| + font->maxp->num_glyphs,
|
| + font->gpos->num_lookups);
|
| }
|
|
|
| // Lookup Type 9:
|
| // Extension Positioning
|
| -bool ParseExtensionPositioning(const ots::OpenTypeFile *file,
|
| +bool ParseExtensionPositioning(const ots::Font *font,
|
| const uint8_t *data, const size_t length) {
|
| - return ots::ParseExtensionSubtable(file, data, length,
|
| + return ots::ParseExtensionSubtable(font, data, length,
|
| &kGposLookupSubtableParser);
|
| }
|
|
|
| @@ -678,8 +678,8 @@ bool ParseExtensionPositioning(const ots::OpenTypeFile *file,
|
| #define DROP_THIS_TABLE(msg_) \
|
| do { \
|
| OTS_FAILURE_MSG(msg_ ", table discarded"); \
|
| - file->gpos->data = 0; \
|
| - file->gpos->length = 0; \
|
| + font->gpos->data = 0; \
|
| + font->gpos->length = 0; \
|
| } while (0)
|
|
|
| namespace ots {
|
| @@ -730,16 +730,16 @@ namespace ots {
|
| // # Contour point indexes aren't sorted
|
| // Arial Unicode.ttf
|
|
|
| -bool ots_gpos_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
|
| +bool ots_gpos_parse(Font *font, const uint8_t *data, size_t length) {
|
| // Parsing GPOS table requires num_glyphs which is contained in maxp table.
|
| - if (!file->maxp) {
|
| + if (!font->maxp) {
|
| return OTS_FAILURE_MSG("missing maxp table needed in GPOS");
|
| }
|
|
|
| Buffer table(data, length);
|
|
|
| OpenTypeGPOS *gpos = new OpenTypeGPOS;
|
| - file->gpos = gpos;
|
| + font->gpos = gpos;
|
|
|
| uint32_t version = 0;
|
| uint16_t offset_script_list = 0;
|
| @@ -764,7 +764,7 @@ bool ots_gpos_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
|
| return true;
|
| }
|
|
|
| - if (!ParseLookupListTable(file, data + offset_lookup_list,
|
| + if (!ParseLookupListTable(font, data + offset_lookup_list,
|
| length - offset_lookup_list,
|
| &kGposLookupSubtableParser,
|
| &gpos->num_lookups)) {
|
| @@ -780,7 +780,7 @@ bool ots_gpos_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
|
| return true;
|
| }
|
|
|
| - if (!ParseFeatureListTable(file, data + offset_feature_list,
|
| + if (!ParseFeatureListTable(font, data + offset_feature_list,
|
| length - offset_feature_list, gpos->num_lookups,
|
| &num_features)) {
|
| DROP_THIS_TABLE("Failed to parse feature list table");
|
| @@ -794,7 +794,7 @@ bool ots_gpos_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
|
| return true;
|
| }
|
|
|
| - if (!ParseScriptListTable(file, data + offset_script_list,
|
| + if (!ParseScriptListTable(font, data + offset_script_list,
|
| length - offset_script_list, num_features)) {
|
| DROP_THIS_TABLE("Failed to parse script list table");
|
| return true;
|
| @@ -806,20 +806,25 @@ bool ots_gpos_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
|
| return true;
|
| }
|
|
|
| -bool ots_gpos_should_serialise(OpenTypeFile *file) {
|
| - return file->gpos != NULL && file->gpos->data != NULL;
|
| +bool ots_gpos_should_serialise(Font *font) {
|
| + return font->gpos != NULL && font->gpos->data != NULL;
|
| }
|
|
|
| -bool ots_gpos_serialise(OTSStream *out, OpenTypeFile *file) {
|
| - if (!out->Write(file->gpos->data, file->gpos->length)) {
|
| +bool ots_gpos_serialise(OTSStream *out, Font *font) {
|
| + if (!out->Write(font->gpos->data, font->gpos->length)) {
|
| return OTS_FAILURE_MSG("Failed to write GPOS table");
|
| }
|
|
|
| return true;
|
| }
|
|
|
| -void ots_gpos_free(OpenTypeFile *file) {
|
| - delete file->gpos;
|
| +void ots_gpos_reuse(Font *font, Font *other) {
|
| + font->gpos = other->gpos;
|
| + font->gpos_reused = true;
|
| +}
|
| +
|
| +void ots_gpos_free(Font *font) {
|
| + delete font->gpos;
|
| }
|
|
|
| } // namespace ots
|
|
|