Commit d10b5739 authored by Ryan VanderMeulen's avatar Ryan VanderMeulen
Browse files

Bug 1835833 - Update OTS to 9.1.0. r=jfkthame

parent 738c5394
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ This is the Sanitiser for OpenType project, from http://code.google.com/p/ots/.

Our reference repository is https://github.com/khaledhosny/ots/.

Current revision: 35643038c4904538aa74c2c691f8d792efdbd6c0 (9.0.0)
Current revision: 75933e1bdc98bdb095f6274b284e1c365f2c510e (9.1.0)

Upstream files included: LICENSE, src/, include/, tests/*.cc

+64 −9
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@

#include "fvar.h"

#include "variations.h"

namespace ots {

// -----------------------------------------------------------------------------
@@ -20,9 +22,11 @@ bool OpenTypeAVAR::Parse(const uint8_t* data, size_t length) {
      !table.ReadU16(&this->axisCount)) {
    return Drop("Failed to read table header");
  }
  if (this->majorVersion != 1) {
  if (this->majorVersion > 2) {
    return Drop("Unknown table version");
  }
  if (this->majorVersion == 1) {
    // We can fix table
    if (this->minorVersion > 0) {
      // we only know how to serialize version 1.0
      Warning("Downgrading minor version to 0");
@@ -32,6 +36,15 @@ bool OpenTypeAVAR::Parse(const uint8_t* data, size_t length) {
      Warning("Expected reserved=0");
      this->reserved = 0;
    }
  } else {
    // We serialize data unchanged, so drop even for minor errors
    if (this->minorVersion > 0) {
      return Drop("Unknown minor table version");
    }
    if (this->reserved != 0) {
      return Drop("Expected reserved=0");
    }
  }

  OpenTypeFVAR* fvar = static_cast<OpenTypeFVAR*>(
      GetFont()->GetTypedTable(OTS_TAG_FVAR));
@@ -79,10 +92,52 @@ bool OpenTypeAVAR::Parse(const uint8_t* data, size_t length) {
    }
  }

  if (this->majorVersion < 2)
    return true;

  uint32_t axisIndexMapOffset;
  uint32_t varStoreOffset;

  if (!table.ReadU32(&axisIndexMapOffset) ||
      !table.ReadU32(&varStoreOffset)) {
    return Drop("Failed to read version 2 offsets");
  }

  Font *font = GetFont();
  uint32_t headerSize = table.offset();

  if (axisIndexMapOffset) {
    if (axisIndexMapOffset < headerSize || axisIndexMapOffset >= length) {
      return Drop("Bad delta set index offset in table header");
    }
    if (!ParseDeltaSetIndexMap(font, data + axisIndexMapOffset, length - axisIndexMapOffset)) {
      return Drop("Failed to parse delta set index map");
    }
  }

  if (varStoreOffset) {
    if (varStoreOffset < headerSize || varStoreOffset >= length) {
      return Drop("Bad item variation store offset in table header");
    }
    if (!ParseItemVariationStore(font, data + varStoreOffset, length - varStoreOffset)) {
      return Drop("Failed to parse item variation store");
    }
  }

  this->m_data = data;
  this->m_length = length;

  return true;
}

bool OpenTypeAVAR::Serialize(OTSStream* out) {
  if (this->majorVersion >= 2) {
    if (!out->Write(this->m_data, this->m_length)) {
      return Error("Failed to write table");
    }
    return true;
  }

  if (!out->WriteU16(this->majorVersion) ||
      !out->WriteU16(this->minorVersion) ||
      !out->WriteU16(this->reserved) ||
+4 −0
Original line number Diff line number Diff line
@@ -35,6 +35,10 @@ class OpenTypeAVAR : public Table {
  };

  std::vector<std::vector<AxisValueMap>> axisSegmentMaps;

  // Only used for versions >= 2
  const uint8_t *m_data;
  size_t m_length;
};

}  // namespace ots
+1 −1
Original line number Diff line number Diff line
@@ -384,7 +384,7 @@ bool ExecuteCharStringOperator(ots::OpenTypeCFF& cff,
    }
    uint16_t k = cff.region_index_count.at(cs_ctx.vsindex);
    uint16_t n = argument_stack->top();
    if (stack_size < n * (k + 1) + 1) {
    if (stack_size < n * (k + 1u) + 1u) {
      return OTS_FAILURE();
    }

+2 −0
Original line number Diff line number Diff line
@@ -194,7 +194,9 @@ bool OpenTypeCPAL::Serialize(OTSStream *out) {
  uint16_t numPalettes = this->colorRecordIndices.size();
  uint16_t numColorRecords = this->colorRecords.size();

#ifndef NDEBUG
  off_t start = out->Tell();
#endif

  size_t colorRecordsArrayOffset = 4 * sizeof(uint16_t) + sizeof(uint32_t) +
      numPalettes * sizeof(uint16_t);
Loading