1 // Copyright (c) 2018 The OTS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "variations.h"
12 // -----------------------------------------------------------------------------
14 // -----------------------------------------------------------------------------
16 bool OpenTypeCVAR::Parse(const uint8_t* data
, size_t length
) {
17 Buffer
table(data
, length
);
19 uint16_t majorVersion
;
20 uint16_t minorVersion
;
22 if (!table
.ReadU16(&majorVersion
) ||
23 !table
.ReadU16(&minorVersion
)) {
24 return Drop("Failed to read table header");
27 if (majorVersion
!= 1) {
28 return Drop("Unknown table version");
31 OpenTypeFVAR
* fvar
= static_cast<OpenTypeFVAR
*>(
32 GetFont()->GetTypedTable(OTS_TAG_FVAR
));
34 return DropVariations("Required fvar table is missing");
37 if (!ParseVariationData(GetFont(), data
+ table
.offset(), length
- table
.offset(),
38 fvar
->AxisCount(), 0)) {
39 return Drop("Failed to parse variation data");
43 this->m_length
= length
;
48 bool OpenTypeCVAR::Serialize(OTSStream
* out
) {
49 if (!out
->Write(this->m_data
, this->m_length
)) {
50 return Error("Failed to write cvar table");