tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

feat.h (1724B)


      1 // Copyright (c) 2009-2017 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.
      4 
      5 #ifndef OTS_FEAT_H_
      6 #define OTS_FEAT_H_
      7 
      8 #include <vector>
      9 #include <unordered_set>
     10 
     11 #include "ots.h"
     12 #include "graphite.h"
     13 
     14 namespace ots {
     15 
     16 class OpenTypeFEAT : public Table {
     17 public:
     18  explicit OpenTypeFEAT(Font* font, uint32_t tag)
     19      : Table(font, tag, tag) { }
     20 
     21  bool Parse(const uint8_t* data, size_t length);
     22  bool Serialize(OTSStream* out);
     23  bool IsValidFeatureId(uint32_t id) const;
     24 
     25 private:
     26  struct FeatureDefn : public TablePart<OpenTypeFEAT> {
     27    explicit FeatureDefn(OpenTypeFEAT* parent)
     28        : TablePart<OpenTypeFEAT>(parent) { }
     29    bool ParsePart(Buffer& table);
     30    bool SerializePart(OTSStream* out) const;
     31    uint32_t id;
     32    uint16_t numSettings;
     33    uint16_t reserved;
     34    uint32_t offset;
     35    uint16_t flags;
     36    static const uint16_t HAS_DEFAULT_SETTING = 0x4000;
     37    static const uint16_t RESERVED = 0x3700;
     38    static const uint16_t DEFAULT_SETTING = 0x00FF;
     39    uint16_t label;
     40  };
     41  struct FeatureSettingDefn : public TablePart<OpenTypeFEAT> {
     42    explicit FeatureSettingDefn(OpenTypeFEAT* parent)
     43        : TablePart<OpenTypeFEAT>(parent) { }
     44    bool ParsePart(Buffer& table) { return ParsePart(table, true); }
     45    bool ParsePart(Buffer& table, bool used);
     46    bool SerializePart(OTSStream* out) const;
     47    int16_t value;
     48    uint16_t label;
     49  };
     50  uint32_t version;
     51  uint16_t numFeat;
     52  uint16_t reserved;
     53  uint32_t reserved2;
     54  std::vector<FeatureDefn> features;
     55  std::vector<FeatureSettingDefn> featSettings;
     56  std::unordered_set<uint32_t> feature_ids;
     57 };
     58 
     59 }  // namespace ots
     60 
     61 #endif  // OTS_FEAT_H_