summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/font/cfx_cttgsubtable.cpp74
-rw-r--r--core/fpdfapi/font/cfx_cttgsubtable.h57
2 files changed, 31 insertions, 100 deletions
diff --git a/core/fpdfapi/font/cfx_cttgsubtable.cpp b/core/fpdfapi/font/cfx_cttgsubtable.cpp
index 902957a436..901e57b60d 100644
--- a/core/fpdfapi/font/cfx_cttgsubtable.cpp
+++ b/core/fpdfapi/font/cfx_cttgsubtable.cpp
@@ -15,27 +15,14 @@
CFX_CTTGSUBTable::CFX_CTTGSUBTable()
: m_bFeautureMapLoad(false), loaded(false) {}
-CFX_CTTGSUBTable::CFX_CTTGSUBTable(FT_Bytes gsub)
- : m_bFeautureMapLoad(false), loaded(false) {
- LoadGSUBTable(gsub);
-}
-
CFX_CTTGSUBTable::~CFX_CTTGSUBTable() {}
-bool CFX_CTTGSUBTable::IsOk() const {
- return loaded;
-}
-
bool CFX_CTTGSUBTable::LoadGSUBTable(FT_Bytes gsub) {
- header.Version = gsub[0] << 24 | gsub[1] << 16 | gsub[2] << 8 | gsub[3];
- if (header.Version != 0x00010000) {
+ if ((gsub[0] << 24u | gsub[1] << 16u | gsub[2] << 8u | gsub[3]) != 0x00010000)
return false;
- }
- header.ScriptList = gsub[4] << 8 | gsub[5];
- header.FeatureList = gsub[6] << 8 | gsub[7];
- header.LookupList = gsub[8] << 8 | gsub[9];
- return Parse(&gsub[header.ScriptList], &gsub[header.FeatureList],
- &gsub[header.LookupList]);
+
+ return Parse(&gsub[gsub[4] << 8 | gsub[5]], &gsub[gsub[6] << 8 | gsub[7]],
+ &gsub[gsub[8] << 8 | gsub[9]]);
}
bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum,
@@ -47,11 +34,11 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum,
(uint8_t)'t',
};
if (!m_bFeautureMapLoad) {
- for (const auto& script : ScriptList.ScriptRecords) {
+ for (const TScriptRecord& script : ScriptList) {
for (const auto& record : script.Script.LangSysRecords) {
for (const auto& index : record.LangSys.FeatureIndices) {
- if (FeatureList.FeatureRecords[index].FeatureTag == tag[0] ||
- FeatureList.FeatureRecords[index].FeatureTag == tag[1]) {
+ if (FeatureList[index].FeatureTag == tag[0] ||
+ FeatureList[index].FeatureTag == tag[1]) {
m_featureSet.insert(index);
}
}
@@ -59,7 +46,7 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum,
}
if (m_featureSet.empty()) {
int i = 0;
- for (const auto& feature : FeatureList.FeatureRecords) {
+ for (const TFeatureRecord& feature : FeatureList) {
if (feature.FeatureTag == tag[0] || feature.FeatureTag == tag[1])
m_featureSet.insert(i);
++i;
@@ -68,8 +55,7 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum,
m_bFeautureMapLoad = true;
}
for (const auto& item : m_featureSet) {
- if (GetVerticalGlyphSub(glyphnum, vglyphnum,
- &FeatureList.FeatureRecords[item].Feature)) {
+ if (GetVerticalGlyphSub(glyphnum, vglyphnum, &FeatureList[item].Feature)) {
return true;
}
}
@@ -80,10 +66,10 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum,
uint32_t* vglyphnum,
TFeature* Feature) {
for (int index : Feature->LookupListIndices) {
- if (!pdfium::IndexInBounds(LookupList.Lookups, index))
+ if (!pdfium::IndexInBounds(LookupList, index))
continue;
- if (LookupList.Lookups[index].LookupType == 1 &&
- GetVerticalGlyphSub2(glyphnum, vglyphnum, &LookupList.Lookups[index])) {
+ if (LookupList[index].LookupType == 1 &&
+ GetVerticalGlyphSub2(glyphnum, vglyphnum, &LookupList[index])) {
return true;
}
}
@@ -181,16 +167,16 @@ uint32_t CFX_CTTGSUBTable::GetUInt32(FT_Bytes& p) const {
bool CFX_CTTGSUBTable::Parse(FT_Bytes scriptlist,
FT_Bytes featurelist,
FT_Bytes lookuplist) {
- ParseScriptList(scriptlist, &ScriptList);
- ParseFeatureList(featurelist, &FeatureList);
- ParseLookupList(lookuplist, &LookupList);
+ ParseScriptList(scriptlist);
+ ParseFeatureList(featurelist);
+ ParseLookupList(lookuplist);
return true;
}
-void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, TScriptList* rec) {
+void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw) {
FT_Bytes sp = raw;
- rec->ScriptRecords = std::vector<TScriptRecord>(GetUInt16(sp));
- for (auto& scriptRec : rec->ScriptRecords) {
+ ScriptList = std::vector<TScriptRecord>(GetUInt16(sp));
+ for (auto& scriptRec : ScriptList) {
scriptRec.ScriptTag = GetUInt32(sp);
ParseScript(&raw[GetUInt16(sp)], &scriptRec.Script);
}
@@ -215,10 +201,10 @@ void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, TLangSys* rec) {
element = GetUInt16(sp);
}
-void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) {
+void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw) {
FT_Bytes sp = raw;
- rec->FeatureRecords = std::vector<TFeatureRecord>(GetUInt16(sp));
- for (auto& featureRec : rec->FeatureRecords) {
+ FeatureList = std::vector<TFeatureRecord>(GetUInt16(sp));
+ for (auto& featureRec : FeatureList) {
featureRec.FeatureTag = GetUInt32(sp);
ParseFeature(&raw[GetUInt16(sp)], &featureRec.Feature);
}
@@ -232,10 +218,10 @@ void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) {
listIndex = GetUInt16(sp);
}
-void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw, TLookupList* rec) {
+void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw) {
FT_Bytes sp = raw;
- rec->Lookups = std::vector<TLookup>(GetUInt16(sp));
- for (auto& lookup : rec->Lookups)
+ LookupList = std::vector<TLookup>(GetUInt16(sp));
+ for (auto& lookup : LookupList)
ParseLookup(&raw[GetUInt16(sp)], &lookup);
}
@@ -358,22 +344,10 @@ CFX_CTTGSUBTable::TScript::TScript() : DefaultLangSys(0) {}
CFX_CTTGSUBTable::TScript::~TScript() {}
-CFX_CTTGSUBTable::TScriptList::TScriptList() {}
-
-CFX_CTTGSUBTable::TScriptList::~TScriptList() {}
-
CFX_CTTGSUBTable::TFeature::TFeature() : FeatureParams(0) {}
CFX_CTTGSUBTable::TFeature::~TFeature() {}
-CFX_CTTGSUBTable::TFeatureList::TFeatureList() {}
-
-CFX_CTTGSUBTable::TFeatureList::~TFeatureList() {}
-
-CFX_CTTGSUBTable::TLookupList::TLookupList() {}
-
-CFX_CTTGSUBTable::TLookupList::~TLookupList() {}
-
CFX_CTTGSUBTable::TLangSys::TLangSys() : LookupOrder(0), ReqFeatureIndex(0) {}
CFX_CTTGSUBTable::TLangSys::~TLangSys() {}
diff --git a/core/fpdfapi/font/cfx_cttgsubtable.h b/core/fpdfapi/font/cfx_cttgsubtable.h
index f8fd6c5c5e..fc8d125f3e 100644
--- a/core/fpdfapi/font/cfx_cttgsubtable.h
+++ b/core/fpdfapi/font/cfx_cttgsubtable.h
@@ -19,21 +19,12 @@
class CFX_CTTGSUBTable {
public:
CFX_CTTGSUBTable();
- explicit CFX_CTTGSUBTable(FT_Bytes gsub);
- virtual ~CFX_CTTGSUBTable();
+ ~CFX_CTTGSUBTable();
- bool IsOk() const;
bool LoadGSUBTable(FT_Bytes gsub);
bool GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum);
private:
- struct tt_gsub_header {
- uint32_t Version;
- uint16_t ScriptList;
- uint16_t FeatureList;
- uint16_t LookupList;
- };
-
struct TLangSys {
TLangSys();
~TLangSys();
@@ -81,17 +72,6 @@ class CFX_CTTGSUBTable {
TScriptRecord& operator=(const TScriptRecord&) = delete;
};
- struct TScriptList {
- TScriptList();
- ~TScriptList();
-
- std::vector<TScriptRecord> ScriptRecords;
-
- private:
- TScriptList(const TScriptList&) = delete;
- TScriptList& operator=(const TScriptList&) = delete;
- };
-
struct TFeature {
TFeature();
~TFeature();
@@ -115,17 +95,6 @@ class CFX_CTTGSUBTable {
TFeatureRecord& operator=(const TFeatureRecord&) = delete;
};
- struct TFeatureList {
- TFeatureList();
- ~TFeatureList();
-
- std::vector<TFeatureRecord> FeatureRecords;
-
- private:
- TFeatureList(const TFeatureList&) = delete;
- TFeatureList& operator=(const TFeatureList&) = delete;
- };
-
enum TLookupFlag {
LOOKUPFLAG_RightToLeft = 0x0001,
LOOKUPFLAG_IgnoreBaseGlyphs = 0x0002,
@@ -245,24 +214,13 @@ class CFX_CTTGSUBTable {
TLookup& operator=(const TLookup&) = delete;
};
- struct TLookupList {
- TLookupList();
- ~TLookupList();
-
- std::vector<TLookup> Lookups;
-
- private:
- TLookupList(const TLookupList&) = delete;
- TLookupList& operator=(const TLookupList&) = delete;
- };
-
bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist);
- void ParseScriptList(FT_Bytes raw, TScriptList* rec);
+ void ParseScriptList(FT_Bytes raw);
void ParseScript(FT_Bytes raw, TScript* rec);
void ParseLangSys(FT_Bytes raw, TLangSys* rec);
- void ParseFeatureList(FT_Bytes raw, TFeatureList* rec);
+ void ParseFeatureList(FT_Bytes raw);
void ParseFeature(FT_Bytes raw, TFeature* rec);
- void ParseLookupList(FT_Bytes raw, TLookupList* rec);
+ void ParseLookupList(FT_Bytes raw);
void ParseLookup(FT_Bytes raw, TLookup* rec);
std::unique_ptr<TCoverageFormatBase> ParseCoverage(FT_Bytes raw);
void ParseCoverageFormat1(FT_Bytes raw, TCoverageFormat1* rec);
@@ -288,10 +246,9 @@ class CFX_CTTGSUBTable {
std::set<uint32_t> m_featureSet;
bool m_bFeautureMapLoad;
bool loaded;
- tt_gsub_header header;
- TScriptList ScriptList;
- TFeatureList FeatureList;
- TLookupList LookupList;
+ std::vector<TScriptRecord> ScriptList;
+ std::vector<TFeatureRecord> FeatureList;
+ std::vector<TLookup> LookupList;
};
#endif // CORE_FPDFAPI_FONT_CFX_CTTGSUBTABLE_H_