diff options
Diffstat (limited to 'core/fpdfapi/font/ttgsubtable.h')
-rw-r--r-- | core/fpdfapi/font/ttgsubtable.h | 126 |
1 files changed, 68 insertions, 58 deletions
diff --git a/core/fpdfapi/font/ttgsubtable.h b/core/fpdfapi/font/ttgsubtable.h index e0e4bbbd05..f927269540 100644 --- a/core/fpdfapi/font/ttgsubtable.h +++ b/core/fpdfapi/font/ttgsubtable.h @@ -9,8 +9,9 @@ #include <stdint.h> -#include <map> #include <memory> +#include <set> +#include <vector> #include "core/fxcrt/fx_basic.h" #include "core/fxge/fx_font.h" @@ -45,19 +46,20 @@ class CFX_CTTGSUBTable { uint16_t FeatureList; uint16_t LookupList; }; + struct TLangSys { TLangSys(); ~TLangSys(); uint16_t LookupOrder; uint16_t ReqFeatureIndex; - uint16_t FeatureCount; - std::unique_ptr<uint16_t[]> FeatureIndex; + std::vector<uint16_t> FeatureIndices; private: - TLangSys(const TLangSys&); - TLangSys& operator=(const TLangSys&); + TLangSys(const TLangSys&) = delete; + TLangSys& operator=(const TLangSys&) = delete; }; + struct TLangSysRecord { TLangSysRecord() : LangSysTag(0) {} @@ -65,21 +67,22 @@ class CFX_CTTGSUBTable { TLangSys LangSys; private: - TLangSysRecord(const TLangSysRecord&); - TLangSysRecord& operator=(const TLangSysRecord&); + TLangSysRecord(const TLangSysRecord&) = delete; + TLangSysRecord& operator=(const TLangSysRecord&) = delete; }; + struct TScript { TScript(); ~TScript(); uint16_t DefaultLangSys; - uint16_t LangSysCount; - std::unique_ptr<TLangSysRecord[]> LangSysRecord; + std::vector<TLangSysRecord> LangSysRecords; private: - TScript(const TScript&); - TScript& operator=(const TScript&); + TScript(const TScript&) = delete; + TScript& operator=(const TScript&) = delete; }; + struct TScriptRecord { TScriptRecord() : ScriptTag(0) {} @@ -87,32 +90,33 @@ class CFX_CTTGSUBTable { TScript Script; private: - TScriptRecord(const TScriptRecord&); - TScriptRecord& operator=(const TScriptRecord&); + TScriptRecord(const TScriptRecord&) = delete; + TScriptRecord& operator=(const TScriptRecord&) = delete; }; + struct TScriptList { TScriptList(); ~TScriptList(); - uint16_t ScriptCount; - std::unique_ptr<TScriptRecord[]> ScriptRecord; + std::vector<TScriptRecord> ScriptRecords; private: - TScriptList(const TScriptList&); - TScriptList& operator=(const TScriptList&); + TScriptList(const TScriptList&) = delete; + TScriptList& operator=(const TScriptList&) = delete; }; + struct TFeature { TFeature(); ~TFeature(); uint16_t FeatureParams; - int LookupCount; - std::unique_ptr<uint16_t[]> LookupListIndex; + std::vector<uint16_t> LookupListIndices; private: - TFeature(const TFeature&); - TFeature& operator=(const TFeature&); + TFeature(const TFeature&) = delete; + TFeature& operator=(const TFeature&) = delete; }; + struct TFeatureRecord { TFeatureRecord() : FeatureTag(0) {} @@ -120,20 +124,21 @@ class CFX_CTTGSUBTable { TFeature Feature; private: - TFeatureRecord(const TFeatureRecord&); - TFeatureRecord& operator=(const TFeatureRecord&); + TFeatureRecord(const TFeatureRecord&) = delete; + TFeatureRecord& operator=(const TFeatureRecord&) = delete; }; + struct TFeatureList { TFeatureList(); ~TFeatureList(); - int FeatureCount; - std::unique_ptr<TFeatureRecord[]> FeatureRecord; + std::vector<TFeatureRecord> FeatureRecords; private: - TFeatureList(const TFeatureList&); - TFeatureList& operator=(const TFeatureList&); + TFeatureList(const TFeatureList&) = delete; + TFeatureList& operator=(const TFeatureList&) = delete; }; + enum TLookupFlag { LOOKUPFLAG_RightToLeft = 0x0001, LOOKUPFLAG_IgnoreBaseGlyphs = 0x0002, @@ -142,6 +147,7 @@ class CFX_CTTGSUBTable { LOOKUPFLAG_Reserved = 0x00F0, LOOKUPFLAG_MarkAttachmentType = 0xFF00, }; + struct TCoverageFormatBase { TCoverageFormatBase() : CoverageFormat(0) {} explicit TCoverageFormatBase(uint16_t format) : CoverageFormat(format) {} @@ -154,17 +160,18 @@ class CFX_CTTGSUBTable { TCoverageFormatBase(const TCoverageFormatBase&); TCoverageFormatBase& operator=(const TCoverageFormatBase&); }; + struct TCoverageFormat1 : public TCoverageFormatBase { TCoverageFormat1(); ~TCoverageFormat1() override; - uint16_t GlyphCount; - std::unique_ptr<uint16_t[]> GlyphArray; + std::vector<uint16_t> GlyphArray; private: - TCoverageFormat1(const TCoverageFormat1&); - TCoverageFormat1& operator=(const TCoverageFormat1&); + TCoverageFormat1(const TCoverageFormat1&) = delete; + TCoverageFormat1& operator=(const TCoverageFormat1&) = delete; }; + struct TRangeRecord { TRangeRecord(); @@ -177,19 +184,20 @@ class CFX_CTTGSUBTable { uint16_t StartCoverageIndex; private: - TRangeRecord(const TRangeRecord&); + TRangeRecord(const TRangeRecord&) = delete; }; + struct TCoverageFormat2 : public TCoverageFormatBase { TCoverageFormat2(); ~TCoverageFormat2() override; - uint16_t RangeCount; - std::unique_ptr<TRangeRecord[]> RangeRecord; + std::vector<TRangeRecord> RangeRecords; private: - TCoverageFormat2(const TCoverageFormat2&); - TCoverageFormat2& operator=(const TCoverageFormat2&); + TCoverageFormat2(const TCoverageFormat2&) = delete; + TCoverageFormat2& operator=(const TCoverageFormat2&) = delete; }; + struct TDevice { TDevice() : StartSize(0), EndSize(0), DeltaFormat(0) {} @@ -198,9 +206,10 @@ class CFX_CTTGSUBTable { uint16_t DeltaFormat; private: - TDevice(const TDevice&); - TDevice& operator=(const TDevice&); + TDevice(const TDevice&) = delete; + TDevice& operator=(const TDevice&) = delete; }; + struct TSubTableBase { TSubTableBase() : SubstFormat(0) {} explicit TSubTableBase(uint16_t format) : SubstFormat(format) {} @@ -209,9 +218,10 @@ class CFX_CTTGSUBTable { uint16_t SubstFormat; private: - TSubTableBase(const TSubTableBase&); - TSubTableBase& operator=(const TSubTableBase&); + TSubTableBase(const TSubTableBase&) = delete; + TSubTableBase& operator=(const TSubTableBase&) = delete; }; + struct TSingleSubstFormat1 : public TSubTableBase { TSingleSubstFormat1(); ~TSingleSubstFormat1() override; @@ -220,44 +230,44 @@ class CFX_CTTGSUBTable { int16_t DeltaGlyphID; private: - TSingleSubstFormat1(const TSingleSubstFormat1&); - TSingleSubstFormat1& operator=(const TSingleSubstFormat1&); + TSingleSubstFormat1(const TSingleSubstFormat1&) = delete; + TSingleSubstFormat1& operator=(const TSingleSubstFormat1&) = delete; }; + struct TSingleSubstFormat2 : public TSubTableBase { TSingleSubstFormat2(); ~TSingleSubstFormat2() override; std::unique_ptr<TCoverageFormatBase> Coverage; - uint16_t GlyphCount; - std::unique_ptr<uint16_t[]> Substitute; + std::vector<uint16_t> Substitutes; private: - TSingleSubstFormat2(const TSingleSubstFormat2&); - TSingleSubstFormat2& operator=(const TSingleSubstFormat2&); + TSingleSubstFormat2(const TSingleSubstFormat2&) = delete; + TSingleSubstFormat2& operator=(const TSingleSubstFormat2&) = delete; }; + struct TLookup { TLookup(); ~TLookup(); uint16_t LookupType; uint16_t LookupFlag; - uint16_t SubTableCount; - std::unique_ptr<TSubTableBase* []> SubTable; + std::vector<std::unique_ptr<TSubTableBase>> SubTables; private: - TLookup(const TLookup&); - TLookup& operator=(const TLookup&); + TLookup(const TLookup&) = delete; + TLookup& operator=(const TLookup&) = delete; }; + struct TLookupList { TLookupList(); ~TLookupList(); - int LookupCount; - std::unique_ptr<TLookup[]> Lookup; + std::vector<TLookup> Lookups; private: - TLookupList(const TLookupList&); - TLookupList& operator=(const TLookupList&); + TLookupList(const TLookupList&) = delete; + TLookupList& operator=(const TLookupList&) = delete; }; bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist); @@ -271,16 +281,16 @@ class CFX_CTTGSUBTable { TCoverageFormatBase* ParseCoverage(FT_Bytes raw); void ParseCoverageFormat1(FT_Bytes raw, TCoverageFormat1* rec); void ParseCoverageFormat2(FT_Bytes raw, TCoverageFormat2* rec); - void ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec); + void ParseSingleSubst(FT_Bytes raw, std::unique_ptr<TSubTableBase>* rec); void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1* rec); void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec); bool GetVerticalGlyphSub(uint32_t glyphnum, uint32_t* vglyphnum, - TFeature* Feature) const; + TFeature* Feature); bool GetVerticalGlyphSub2(uint32_t glyphnum, uint32_t* vglyphnum, - TLookup* Lookup) const; + TLookup* Lookup); int GetCoverageIndex(TCoverageFormatBase* Coverage, uint32_t g) const; uint8_t GetUInt8(FT_Bytes& p) const; @@ -289,7 +299,7 @@ class CFX_CTTGSUBTable { int32_t GetInt32(FT_Bytes& p) const; uint32_t GetUInt32(FT_Bytes& p) const; - std::map<uint32_t, uint32_t> m_featureMap; + std::set<uint32_t> m_featureSet; bool m_bFeautureMapLoad; bool loaded; tt_gsub_header header; |