Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfx_cttgsubtable.h
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef CORE_FPDFAPI_FONT_CFX_CTTGSUBTABLE_H_
8#define CORE_FPDFAPI_FONT_CFX_CTTGSUBTABLE_H_
9
10#include <stdint.h>
11
12#include <set>
13#include <vector>
14
15#include "core/fxcrt/data_vector.h"
16#include "third_party/abseil-cpp/absl/types/optional.h"
17#include "third_party/abseil-cpp/absl/types/variant.h"
18#include "third_party/base/containers/span.h"
19
21 public:
22 explicit CFX_CTTGSUBTable(pdfium::span<const uint8_t> gsub);
24
25 uint32_t GetVerticalGlyph(uint32_t glyphnum) const;
26
27 private:
30
31 struct FeatureRecord {
32 FeatureRecord();
33 ~FeatureRecord();
34
35 uint32_t feature_tag = 0;
36 DataVector<uint16_t> lookup_list_indices;
37 };
38
39 struct RangeRecord {
40 RangeRecord();
41
42 uint16_t start = 0;
43 uint16_t end = 0;
44 uint16_t start_coverage_index = 0;
45 };
46
47 // GlyphArray for format 1.
48 // RangeRecords for format 2.
49 using CoverageFormat = absl::
51
52 struct SubTable {
53 SubTable();
54 SubTable(const SubTable& that) = delete;
55 SubTable& operator=(const SubTable& that) = delete;
56 SubTable(SubTable&& that) noexcept;
57 SubTable& operator=(SubTable&& that) noexcept;
58 ~SubTable();
59
60 CoverageFormat coverage;
61 // DeltaGlyphID for format 1.
62 // Substitutes for format 2.
63 absl::variant<absl::monostate, int16_t, DataVector<uint16_t>> table_data;
64 };
65
66 struct Lookup {
67 using SubTables = std::vector<SubTable>;
68
69 Lookup();
70 Lookup(const Lookup& that) = delete;
71 Lookup& operator=(const Lookup& that) = delete;
72 Lookup(Lookup&& that) noexcept;
73 Lookup& operator=(Lookup&& that) noexcept;
74 ~Lookup();
75
76 uint16_t lookup_type = 0;
77 SubTables sub_tables;
78 };
79
80 bool LoadGSUBTable(pdfium::span<const uint8_t> gsub);
81 void Parse(pdfium::span<const uint8_t> scriptlist,
82 pdfium::span<const uint8_t> featurelist,
83 pdfium::span<const uint8_t> lookuplist);
84 void ParseScriptList(pdfium::span<const uint8_t> raw);
85 ScriptRecord ParseScript(const uint8_t* raw);
86 FeatureIndices ParseLangSys(const uint8_t* raw);
87 void ParseFeatureList(pdfium::span<const uint8_t> raw);
88 DataVector<uint16_t> ParseFeatureLookupListIndices(const uint8_t* raw);
89 void ParseLookupList(pdfium::span<const uint8_t> raw);
90 Lookup ParseLookup(const uint8_t* raw);
91 CoverageFormat ParseCoverage(const uint8_t* raw);
92 SubTable ParseSingleSubst(const uint8_t* raw);
93
94 absl::optional<uint32_t> GetVerticalGlyphSub(const FeatureRecord& feature,
95 uint32_t glyphnum) const;
96 absl::optional<uint32_t> GetVerticalGlyphSub2(const Lookup& lookup,
97 uint32_t glyphnum) const;
98 int GetCoverageIndex(const CoverageFormat& coverage, uint32_t g) const;
99
100 uint8_t GetUInt8(const uint8_t*& p) const;
101 int16_t GetInt16(const uint8_t*& p) const;
102 uint16_t GetUInt16(const uint8_t*& p) const;
103 int32_t GetInt32(const uint8_t*& p) const;
104 uint32_t GetUInt32(const uint8_t*& p) const;
105
106 std::set<uint32_t> feature_set_;
107 std::vector<ScriptRecord> script_list_;
108 std::vector<FeatureRecord> feature_list_;
109 std::vector<Lookup> lookup_list_;
110};
111
112#endif // CORE_FPDFAPI_FONT_CFX_CTTGSUBTABLE_H_
uint32_t GetVerticalGlyph(uint32_t glyphnum) const
CFX_CTTGSUBTable(pdfium::span< const uint8_t > gsub)
static constexpr uint32_t MakeTag(char c1, char c2, char c3, char c4)