summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_font
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/fpdf_font')
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_simplefont.h5
-rw-r--r--core/fpdfapi/fpdf_font/font_int.h21
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font.cpp8
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font_cid.cpp19
-rw-r--r--core/fpdfapi/fpdf_font/ttgsubtable.cpp143
-rw-r--r--core/fpdfapi/fpdf_font/ttgsubtable.h182
6 files changed, 260 insertions, 118 deletions
diff --git a/core/fpdfapi/fpdf_font/cpdf_simplefont.h b/core/fpdfapi/fpdf_font/cpdf_simplefont.h
index 881744a405..51266bbe6c 100644
--- a/core/fpdfapi/fpdf_font/cpdf_simplefont.h
+++ b/core/fpdfapi/fpdf_font/cpdf_simplefont.h
@@ -15,9 +15,9 @@
class CPDF_SimpleFont : public CPDF_Font {
public:
CPDF_SimpleFont();
- virtual ~CPDF_SimpleFont();
+ ~CPDF_SimpleFont() override;
- // CPDF_Font:
+ // CPDF_Font
int GetCharWidthF(uint32_t charcode, int level = 0) override;
FX_RECT GetCharBBox(uint32_t charcode, int level = 0) override;
int GlyphFromCharCode(uint32_t charcode,
@@ -33,7 +33,6 @@ class CPDF_SimpleFont : public CPDF_Font {
FX_BOOL LoadCommon();
void LoadSubstFont();
- void LoadFaceMetrics();
void LoadCharMetrics(int charcode);
CPDF_FontEncoding m_Encoding;
diff --git a/core/fpdfapi/fpdf_font/font_int.h b/core/fpdfapi/fpdf_font/font_int.h
index e159b1e34c..ea6c246e78 100644
--- a/core/fpdfapi/fpdf_font/font_int.h
+++ b/core/fpdfapi/fpdf_font/font_int.h
@@ -28,6 +28,7 @@ class CPDF_CMapManager {
public:
CPDF_CMapManager();
~CPDF_CMapManager();
+
void* GetPackage(FX_BOOL bPrompt);
CPDF_CMap* GetPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPromptCJK);
CPDF_CID2UnicodeMap* GetCID2UnicodeMap(CIDSet charset, FX_BOOL bPromptCJK);
@@ -89,7 +90,7 @@ struct CMap_CodeRange {
class CPDF_CMapParser {
public:
CPDF_CMapParser();
- ~CPDF_CMapParser() {}
+ ~CPDF_CMapParser();
FX_BOOL Initialize(CPDF_CMap* pMap);
void ParseWord(const CFX_ByteStringC& str);
CFX_BinaryBuf m_AddMaps;
@@ -108,7 +109,9 @@ class CPDF_CMapParser {
int m_CodeSeq;
uint32_t m_CodePoints[4];
CFX_ArrayTemplate<CMap_CodeRange> m_CodeRanges;
- CFX_ByteString m_Registry, m_Ordering, m_Supplement;
+ CFX_ByteString m_Registry;
+ CFX_ByteString m_Ordering;
+ CFX_ByteString m_Supplement;
CFX_ByteString m_LastWord;
};
@@ -140,8 +143,9 @@ class CPDF_CMap {
FX_BOOL bPromptCJK);
FX_BOOL LoadEmbedded(const uint8_t* pData, uint32_t dwSize);
void Release();
- FX_BOOL IsLoaded() const { return m_bLoaded; }
- FX_BOOL IsVertWriting() const { return m_bVertical; }
+
+ FX_BOOL IsLoaded() const;
+ FX_BOOL IsVertWriting() const;
uint16_t CIDFromCharCode(uint32_t charcode) const;
uint32_t CharCodeFromCID(uint16_t CID) const;
int GetCharSize(uint32_t charcode) const;
@@ -172,6 +176,7 @@ class CPDF_CID2UnicodeMap {
public:
CPDF_CID2UnicodeMap();
~CPDF_CID2UnicodeMap();
+
FX_BOOL Initialize();
FX_BOOL IsLoaded();
void Load(CPDF_CMapManager* pMgr, CIDSet charset, FX_BOOL bPromptCJK);
@@ -185,9 +190,13 @@ class CPDF_CID2UnicodeMap {
class CPDF_ToUnicodeMap {
public:
+ CPDF_ToUnicodeMap();
+ ~CPDF_ToUnicodeMap();
+
void Load(CPDF_Stream* pStream);
- CFX_WideString Lookup(uint32_t charcode);
- uint32_t ReverseLookup(FX_WCHAR unicode);
+
+ CFX_WideString Lookup(uint32_t charcode) const;
+ uint32_t ReverseLookup(FX_WCHAR unicode) const;
protected:
std::map<uint32_t, uint32_t> m_Map;
diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp
index e5442215c4..1735f0ba25 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -93,7 +93,7 @@ short TT2PDF(int m, FXFT_Face face) {
return (m * 1000 + upm / 2) / upm;
}
-CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) {
+CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const {
auto it = m_Map.find(charcode);
if (it != m_Map.end()) {
uint32_t value = it->second;
@@ -122,7 +122,7 @@ CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) {
return CFX_WideString();
}
-uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) {
+uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) const {
for (const auto& pair : m_Map) {
if (pair.second == static_cast<uint32_t>(unicode))
return pair.first;
@@ -193,6 +193,10 @@ CFX_WideString CPDF_ToUnicodeMap::StringToWideString(
return result;
}
+CPDF_ToUnicodeMap::CPDF_ToUnicodeMap() : m_pBaseMap(nullptr) {}
+
+CPDF_ToUnicodeMap::~CPDF_ToUnicodeMap() {}
+
void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
CIDSet cid_set = CIDSET_UNKNOWN;
CPDF_StreamAcc stream;
diff --git a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 2a55955cc0..efc5e7cedc 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -341,11 +341,12 @@ CPDF_CID2UnicodeMap* CPDF_CMapManager::LoadCID2UnicodeMap(CIDSet charset,
pMap->Load(this, charset, bPromptCJK);
return pMap;
}
-CPDF_CMapParser::CPDF_CMapParser() {
- m_pCMap = nullptr;
- m_Status = 0;
- m_CodeSeq = 0;
-}
+
+CPDF_CMapParser::CPDF_CMapParser()
+ : m_pCMap(nullptr), m_Status(0), m_CodeSeq(0) {}
+
+CPDF_CMapParser::~CPDF_CMapParser() {}
+
FX_BOOL CPDF_CMapParser::Initialize(CPDF_CMap* pCMap) {
m_pCMap = pCMap;
m_Status = 0;
@@ -525,6 +526,14 @@ void CPDF_CMap::Release() {
}
}
+FX_BOOL CPDF_CMap::IsLoaded() const {
+ return m_bLoaded;
+}
+
+FX_BOOL CPDF_CMap::IsVertWriting() const {
+ return m_bVertical;
+}
+
FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr,
const FX_CHAR* pName,
FX_BOOL bPromptCJK) {
diff --git a/core/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/fpdfapi/fpdf_font/ttgsubtable.cpp
index 5734816a87..8900e274fe 100644
--- a/core/fpdfapi/fpdf_font/ttgsubtable.cpp
+++ b/core/fpdfapi/fpdf_font/ttgsubtable.cpp
@@ -13,16 +13,20 @@
#include "third_party/base/stl_util.h"
CFX_GlyphMap::CFX_GlyphMap() {}
+
CFX_GlyphMap::~CFX_GlyphMap() {}
+
extern "C" {
static int _CompareInt(const void* p1, const void* p2) {
return (*(uint32_t*)p1) - (*(uint32_t*)p2);
}
};
+
struct _IntPair {
int32_t key;
int32_t value;
};
+
void CFX_GlyphMap::SetAt(int key, int value) {
uint32_t count = m_Buffer.GetSize() / sizeof(_IntPair);
_IntPair* buf = (_IntPair*)m_Buffer.GetBuffer();
@@ -45,6 +49,7 @@ void CFX_GlyphMap::SetAt(int key, int value) {
}
m_Buffer.InsertBlock(low * sizeof(_IntPair), &pair, sizeof(_IntPair));
}
+
FX_BOOL CFX_GlyphMap::Lookup(int key, int& value) {
void* pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(),
m_Buffer.GetSize() / sizeof(_IntPair),
@@ -55,6 +60,21 @@ FX_BOOL CFX_GlyphMap::Lookup(int key, int& value) {
value = ((uint32_t*)pResult)[1];
return TRUE;
}
+
+CFX_CTTGSUBTable::CFX_CTTGSUBTable(void)
+ : 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(void) 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) {
@@ -66,6 +86,7 @@ bool CFX_CTTGSUBTable::LoadGSUBTable(FT_Bytes gsub) {
return Parse(&gsub[header.ScriptList], &gsub[header.FeatureList],
&gsub[header.LookupList]);
}
+
bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum,
uint32_t* vglyphnum) {
uint32_t tag[] = {
@@ -113,9 +134,10 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum,
}
return false;
}
+
bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum,
uint32_t* vglyphnum,
- struct TFeature* Feature) {
+ struct TFeature* Feature) const {
for (int i = 0; i < Feature->LookupCount; i++) {
int index = Feature->LookupListIndex[i];
if (index < 0 || LookupList.LookupCount < index) {
@@ -130,9 +152,10 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum,
}
return false;
}
+
bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum,
uint32_t* vglyphnum,
- struct TLookup* Lookup) {
+ struct TLookup* Lookup) const {
for (int i = 0; i < Lookup->SubTableCount; i++) {
switch (Lookup->SubTable[i]->SubstFormat) {
case 1: {
@@ -157,8 +180,9 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum,
}
return false;
}
+
int CFX_CTTGSUBTable::GetCoverageIndex(struct TCoverageFormatBase* Coverage,
- uint32_t g) {
+ uint32_t g) const {
int i = 0;
if (!Coverage) {
return -1;
@@ -188,6 +212,37 @@ int CFX_CTTGSUBTable::GetCoverageIndex(struct TCoverageFormatBase* Coverage,
}
return -1;
}
+
+uint8_t CFX_CTTGSUBTable::GetUInt8(FT_Bytes& p) const {
+ uint8_t ret = p[0];
+ p += 1;
+ return ret;
+}
+
+int16_t CFX_CTTGSUBTable::GetInt16(FT_Bytes& p) const {
+ uint16_t ret = p[0] << 8 | p[1];
+ p += 2;
+ return *(int16_t*)&ret;
+}
+
+uint16_t CFX_CTTGSUBTable::GetUInt16(FT_Bytes& p) const {
+ uint16_t ret = p[0] << 8 | p[1];
+ p += 2;
+ return ret;
+}
+
+int32_t CFX_CTTGSUBTable::GetInt32(FT_Bytes& p) const {
+ uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
+ p += 4;
+ return *(int32_t*)&ret;
+}
+
+uint32_t CFX_CTTGSUBTable::GetUInt32(FT_Bytes& p) const {
+ uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
+ p += 4;
+ return ret;
+}
+
bool CFX_CTTGSUBTable::Parse(FT_Bytes scriptlist,
FT_Bytes featurelist,
FT_Bytes lookuplist) {
@@ -196,6 +251,7 @@ bool CFX_CTTGSUBTable::Parse(FT_Bytes scriptlist,
ParseLookupList(lookuplist, &LookupList);
return true;
}
+
void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, struct TScriptList* rec) {
int i;
FT_Bytes sp = raw;
@@ -210,6 +266,7 @@ void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, struct TScriptList* rec) {
ParseScript(&raw[offset], &rec->ScriptRecord[i].Script);
}
}
+
void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, struct TScript* rec) {
int i;
FT_Bytes sp = raw;
@@ -225,6 +282,7 @@ void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, struct TScript* rec) {
ParseLangSys(&raw[offset], &rec->LangSysRecord[i].LangSys);
}
}
+
void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, struct TLangSys* rec) {
FT_Bytes sp = raw;
rec->LookupOrder = GetUInt16(sp);
@@ -239,6 +297,7 @@ void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, struct TLangSys* rec) {
rec->FeatureIndex[i] = GetUInt16(sp);
}
}
+
void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) {
int i;
FT_Bytes sp = raw;
@@ -253,6 +312,7 @@ void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) {
ParseFeature(&raw[offset], &rec->FeatureRecord[i].Feature);
}
}
+
void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) {
int i;
FT_Bytes sp = raw;
@@ -266,6 +326,7 @@ void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) {
rec->LookupListIndex[i] = GetUInt16(sp);
}
}
+
void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw, TLookupList* rec) {
int i;
FT_Bytes sp = raw;
@@ -279,6 +340,7 @@ void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw, TLookupList* rec) {
ParseLookup(&raw[offset], &rec->Lookup[i]);
}
}
+
void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) {
int i;
FT_Bytes sp = raw;
@@ -300,6 +362,7 @@ void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) {
ParseSingleSubst(&raw[offset], &rec->SubTable[i]);
}
}
+
void CFX_CTTGSUBTable::ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec) {
FT_Bytes sp = raw;
uint16_t Format = GetUInt16(sp);
@@ -314,6 +377,7 @@ void CFX_CTTGSUBTable::ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec) {
break;
}
}
+
void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw,
TCoverageFormat1* rec) {
int i;
@@ -328,6 +392,7 @@ void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw,
rec->GlyphArray[i] = GetUInt16(sp);
}
}
+
void CFX_CTTGSUBTable::ParseCoverageFormat2(FT_Bytes raw,
TCoverageFormat2* rec) {
int i;
@@ -344,6 +409,7 @@ void CFX_CTTGSUBTable::ParseCoverageFormat2(FT_Bytes raw,
rec->RangeRecord[i].StartCoverageIndex = GetUInt16(sp);
}
}
+
void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec) {
FT_Bytes sp = raw;
uint16_t Format = GetUInt16(sp);
@@ -358,6 +424,7 @@ void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec) {
break;
}
}
+
void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw,
TSingleSubstFormat1* rec) {
FT_Bytes sp = raw;
@@ -366,6 +433,7 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw,
ParseCoverage(&raw[offset], &rec->Coverage);
rec->DeltaGlyphID = GetInt16(sp);
}
+
void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw,
TSingleSubstFormat2* rec) {
int i;
@@ -382,3 +450,72 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw,
rec->Substitute[i] = GetUInt16(sp);
}
}
+
+CFX_CTTGSUBTable::TCoverageFormat1::TCoverageFormat1()
+ : GlyphCount(0), GlyphArray(nullptr) {
+ CoverageFormat = 1;
+}
+
+CFX_CTTGSUBTable::TCoverageFormat1::~TCoverageFormat1() {
+ delete[] GlyphArray;
+}
+
+CFX_CTTGSUBTable::TRangeRecord::TRangeRecord()
+ : Start(0), End(0), StartCoverageIndex(0) {}
+
+CFX_CTTGSUBTable::TCoverageFormat2::TCoverageFormat2()
+ : RangeCount(0), RangeRecord(nullptr) {
+ CoverageFormat = 2;
+}
+
+CFX_CTTGSUBTable::TCoverageFormat2::~TCoverageFormat2() {
+ delete[] RangeRecord;
+}
+
+CFX_CTTGSUBTable::TClassDefFormat1::TClassDefFormat1()
+ : StartGlyph(0), GlyphCount(0), ClassValueArray(nullptr) {
+ ClassFormat = 1;
+}
+
+CFX_CTTGSUBTable::TClassDefFormat1::~TClassDefFormat1() {
+ delete[] ClassValueArray;
+}
+
+CFX_CTTGSUBTable::TClassDefFormat2::TClassDefFormat2()
+ : ClassRangeCount(0), ClassRangeRecord(nullptr) {
+ ClassFormat = 2;
+}
+
+CFX_CTTGSUBTable::TClassDefFormat2::~TClassDefFormat2() {
+ delete[] ClassRangeRecord;
+}
+
+CFX_CTTGSUBTable::TSingleSubstFormat1::TSingleSubstFormat1()
+ : Coverage(nullptr), DeltaGlyphID(0) {
+ SubstFormat = 1;
+}
+
+CFX_CTTGSUBTable::TSingleSubstFormat1::~TSingleSubstFormat1() {
+ delete Coverage;
+}
+
+CFX_CTTGSUBTable::TSingleSubstFormat2::TSingleSubstFormat2()
+ : Coverage(nullptr), GlyphCount(0), Substitute(nullptr) {
+ SubstFormat = 2;
+}
+
+CFX_CTTGSUBTable::TSingleSubstFormat2::~TSingleSubstFormat2() {
+ delete Coverage;
+ delete[] Substitute;
+}
+
+CFX_CTTGSUBTable::TLookup::TLookup()
+ : LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(nullptr) {}
+
+CFX_CTTGSUBTable::TLookup::~TLookup() {
+ if (SubTable) {
+ for (int i = 0; i < SubTableCount; ++i)
+ delete SubTable[i];
+ delete[] SubTable;
+ }
+}
diff --git a/core/fpdfapi/fpdf_font/ttgsubtable.h b/core/fpdfapi/fpdf_font/ttgsubtable.h
index 830e67af88..de7a4f03ec 100644
--- a/core/fpdfapi/fpdf_font/ttgsubtable.h
+++ b/core/fpdfapi/fpdf_font/ttgsubtable.h
@@ -19,6 +19,7 @@ class CFX_GlyphMap {
public:
CFX_GlyphMap();
~CFX_GlyphMap();
+
void SetAt(int key, int value);
FX_BOOL Lookup(int key, int& value);
@@ -28,12 +29,11 @@ class CFX_GlyphMap {
class CFX_CTTGSUBTable {
public:
- CFX_CTTGSUBTable(void) : m_bFeautureMapLoad(FALSE), loaded(false) {}
- CFX_CTTGSUBTable(FT_Bytes gsub) : m_bFeautureMapLoad(FALSE), loaded(false) {
- LoadGSUBTable(gsub);
- }
- virtual ~CFX_CTTGSUBTable() {}
- bool IsOk(void) const { return loaded; }
+ CFX_CTTGSUBTable();
+ explicit CFX_CTTGSUBTable(FT_Bytes gsub);
+ virtual ~CFX_CTTGSUBTable();
+
+ bool IsOk(void) const;
bool LoadGSUBTable(FT_Bytes gsub);
bool GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum);
@@ -45,10 +45,6 @@ class CFX_CTTGSUBTable {
uint16_t LookupList;
};
struct TLangSys {
- uint16_t LookupOrder;
- uint16_t ReqFeatureIndex;
- uint16_t FeatureCount;
- uint16_t* FeatureIndex;
TLangSys()
: LookupOrder(0),
ReqFeatureIndex(0),
@@ -56,75 +52,88 @@ class CFX_CTTGSUBTable {
FeatureIndex(nullptr) {}
~TLangSys() { delete[] FeatureIndex; }
+ uint16_t LookupOrder;
+ uint16_t ReqFeatureIndex;
+ uint16_t FeatureCount;
+ uint16_t* FeatureIndex;
+
private:
TLangSys(const TLangSys&);
TLangSys& operator=(const TLangSys&);
};
struct TLangSysRecord {
+ TLangSysRecord() : LangSysTag(0) {}
+
uint32_t LangSysTag;
struct TLangSys LangSys;
- TLangSysRecord() : LangSysTag(0) {}
private:
TLangSysRecord(const TLangSysRecord&);
TLangSysRecord& operator=(const TLangSysRecord&);
};
struct TScript {
+ TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(nullptr) {}
+ ~TScript() { delete[] LangSysRecord; }
+
uint16_t DefaultLangSys;
uint16_t LangSysCount;
+ // TODO(weili): Replace with a smart pointer type, pdfium:518.
struct TLangSysRecord* LangSysRecord;
- TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(nullptr) {}
- ~TScript() { delete[] LangSysRecord; }
private:
TScript(const TScript&);
TScript& operator=(const TScript&);
};
struct TScriptRecord {
+ TScriptRecord() : ScriptTag(0) {}
+
uint32_t ScriptTag;
struct TScript Script;
- TScriptRecord() : ScriptTag(0) {}
private:
TScriptRecord(const TScriptRecord&);
TScriptRecord& operator=(const TScriptRecord&);
};
struct TScriptList {
- uint16_t ScriptCount;
- struct TScriptRecord* ScriptRecord;
TScriptList() : ScriptCount(0), ScriptRecord(nullptr) {}
~TScriptList() { delete[] ScriptRecord; }
+ uint16_t ScriptCount;
+ struct TScriptRecord* ScriptRecord;
+
private:
TScriptList(const TScriptList&);
TScriptList& operator=(const TScriptList&);
};
struct TFeature {
+ TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(nullptr) {}
+ ~TFeature() { delete[] LookupListIndex; }
+
uint16_t FeatureParams;
int LookupCount;
uint16_t* LookupListIndex;
- TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(nullptr) {}
- ~TFeature() { delete[] LookupListIndex; }
private:
TFeature(const TFeature&);
TFeature& operator=(const TFeature&);
};
struct TFeatureRecord {
+ TFeatureRecord() : FeatureTag(0) {}
+
uint32_t FeatureTag;
struct TFeature Feature;
- TFeatureRecord() : FeatureTag(0) {}
private:
TFeatureRecord(const TFeatureRecord&);
TFeatureRecord& operator=(const TFeatureRecord&);
};
struct TFeatureList {
- int FeatureCount;
- struct TFeatureRecord* FeatureRecord;
TFeatureList() : FeatureCount(0), FeatureRecord(nullptr) {}
~TFeatureList() { delete[] FeatureRecord; }
+ int FeatureCount;
+ struct TFeatureRecord* FeatureRecord;
+
private:
TFeatureList(const TFeatureList&);
TFeatureList& operator=(const TFeatureList&);
@@ -138,173 +147,165 @@ class CFX_CTTGSUBTable {
LOOKUPFLAG_MarkAttachmentType = 0xFF00,
};
struct TCoverageFormatBase {
- uint16_t CoverageFormat;
- CFX_GlyphMap m_glyphMap;
TCoverageFormatBase() : CoverageFormat(0) {}
virtual ~TCoverageFormatBase() {}
+ uint16_t CoverageFormat;
+ CFX_GlyphMap m_glyphMap;
+
private:
TCoverageFormatBase(const TCoverageFormatBase&);
TCoverageFormatBase& operator=(const TCoverageFormatBase&);
};
struct TCoverageFormat1 : public TCoverageFormatBase {
+ TCoverageFormat1();
+ ~TCoverageFormat1() override;
+
uint16_t GlyphCount;
uint16_t* GlyphArray;
- TCoverageFormat1() : GlyphCount(0), GlyphArray(nullptr) {
- CoverageFormat = 1;
- }
- ~TCoverageFormat1() override { delete[] GlyphArray; }
private:
TCoverageFormat1(const TCoverageFormat1&);
TCoverageFormat1& operator=(const TCoverageFormat1&);
};
struct TRangeRecord {
- uint16_t Start;
- uint16_t End;
- uint16_t StartCoverageIndex;
- TRangeRecord() : Start(0), End(0), StartCoverageIndex(0) {}
+ TRangeRecord();
+
friend bool operator>(const TRangeRecord& r1, const TRangeRecord& r2) {
return r1.Start > r2.Start;
}
+ uint16_t Start;
+ uint16_t End;
+ uint16_t StartCoverageIndex;
+
private:
TRangeRecord(const TRangeRecord&);
};
struct TCoverageFormat2 : public TCoverageFormatBase {
+ TCoverageFormat2();
+ ~TCoverageFormat2() override;
+
uint16_t RangeCount;
struct TRangeRecord* RangeRecord;
- TCoverageFormat2() : RangeCount(0), RangeRecord(nullptr) {
- CoverageFormat = 2;
- }
- ~TCoverageFormat2() override { delete[] RangeRecord; }
private:
TCoverageFormat2(const TCoverageFormat2&);
TCoverageFormat2& operator=(const TCoverageFormat2&);
};
struct TClassDefFormatBase {
- uint16_t ClassFormat;
TClassDefFormatBase() : ClassFormat(0) {}
virtual ~TClassDefFormatBase() {}
+ uint16_t ClassFormat;
+
private:
TClassDefFormatBase(const TClassDefFormatBase&);
TClassDefFormatBase& operator=(const TClassDefFormatBase&);
};
struct TClassDefFormat1 : public TClassDefFormatBase {
+ TClassDefFormat1();
+ ~TClassDefFormat1() override;
+
uint16_t StartGlyph;
uint16_t GlyphCount;
uint16_t* ClassValueArray;
- TClassDefFormat1()
- : StartGlyph(0), GlyphCount(0), ClassValueArray(nullptr) {
- ClassFormat = 1;
- }
- ~TClassDefFormat1() override { delete[] ClassValueArray; }
private:
TClassDefFormat1(const TClassDefFormat1&);
TClassDefFormat1& operator=(const TClassDefFormat1&);
};
struct TClassRangeRecord {
+ TClassRangeRecord() : Start(0), End(0), Class(0) {}
+
uint16_t Start;
uint16_t End;
uint16_t Class;
- TClassRangeRecord() : Start(0), End(0), Class(0) {}
private:
TClassRangeRecord(const TClassRangeRecord&);
TClassRangeRecord& operator=(const TClassRangeRecord&);
};
struct TClassDefFormat2 : public TClassDefFormatBase {
+ TClassDefFormat2();
+ ~TClassDefFormat2() override;
+
uint16_t ClassRangeCount;
struct TClassRangeRecord* ClassRangeRecord;
- TClassDefFormat2() : ClassRangeCount(0), ClassRangeRecord(nullptr) {
- ClassFormat = 2;
- }
- ~TClassDefFormat2() override { delete[] ClassRangeRecord; }
private:
TClassDefFormat2(const TClassDefFormat2&);
TClassDefFormat2& operator=(const TClassDefFormat2&);
};
struct TDevice {
+ TDevice() : StartSize(0), EndSize(0), DeltaFormat(0) {}
+
uint16_t StartSize;
uint16_t EndSize;
uint16_t DeltaFormat;
- TDevice() : StartSize(0), EndSize(0), DeltaFormat(0) {}
private:
TDevice(const TDevice&);
TDevice& operator=(const TDevice&);
};
struct TSubTableBase {
- uint16_t SubstFormat;
TSubTableBase() : SubstFormat(0) {}
virtual ~TSubTableBase() {}
+ uint16_t SubstFormat;
+
private:
TSubTableBase(const TSubTableBase&);
TSubTableBase& operator=(const TSubTableBase&);
};
struct TSingleSubstFormat1 : public TSubTableBase {
+ TSingleSubstFormat1();
+ ~TSingleSubstFormat1() override;
+
TCoverageFormatBase* Coverage;
int16_t DeltaGlyphID;
- TSingleSubstFormat1() : Coverage(nullptr), DeltaGlyphID(0) {
- SubstFormat = 1;
- }
- ~TSingleSubstFormat1() override { delete Coverage; }
private:
TSingleSubstFormat1(const TSingleSubstFormat1&);
TSingleSubstFormat1& operator=(const TSingleSubstFormat1&);
};
struct TSingleSubstFormat2 : public TSubTableBase {
+ TSingleSubstFormat2();
+ ~TSingleSubstFormat2() override;
+
TCoverageFormatBase* Coverage;
uint16_t GlyphCount;
uint16_t* Substitute;
- TSingleSubstFormat2()
- : Coverage(nullptr), GlyphCount(0), Substitute(nullptr) {
- SubstFormat = 2;
- }
- ~TSingleSubstFormat2() override {
- delete Coverage;
- delete[] Substitute;
- }
private:
TSingleSubstFormat2(const TSingleSubstFormat2&);
TSingleSubstFormat2& operator=(const TSingleSubstFormat2&);
};
struct TLookup {
+ TLookup();
+ ~TLookup();
+
uint16_t LookupType;
uint16_t LookupFlag;
uint16_t SubTableCount;
struct TSubTableBase** SubTable;
- TLookup()
- : LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(nullptr) {}
- ~TLookup() {
- if (SubTable) {
- for (int i = 0; i < SubTableCount; ++i)
- delete SubTable[i];
- delete[] SubTable;
- }
- }
private:
TLookup(const TLookup&);
TLookup& operator=(const TLookup&);
};
struct TLookupList {
- int LookupCount;
- struct TLookup* Lookup;
TLookupList() : LookupCount(0), Lookup(nullptr) {}
~TLookupList() { delete[] Lookup; }
+ int LookupCount;
+ struct TLookup* Lookup;
+
private:
TLookupList(const TLookupList&);
TLookupList& operator=(const TLookupList&);
};
+
bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist);
void ParseScriptList(FT_Bytes raw, TScriptList* rec);
void ParseScript(FT_Bytes raw, TScript* rec);
@@ -319,38 +320,21 @@ class CFX_CTTGSUBTable {
void ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec);
void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1* rec);
void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec);
+
bool GetVerticalGlyphSub(uint32_t glyphnum,
uint32_t* vglyphnum,
- struct TFeature* Feature);
+ struct TFeature* Feature) const;
bool GetVerticalGlyphSub2(uint32_t glyphnum,
uint32_t* vglyphnum,
- struct TLookup* Lookup);
- int GetCoverageIndex(struct TCoverageFormatBase* Coverage, uint32_t g);
- uint8_t GetUInt8(FT_Bytes& p) const {
- uint8_t ret = p[0];
- p += 1;
- return ret;
- }
- int16_t GetInt16(FT_Bytes& p) const {
- uint16_t ret = p[0] << 8 | p[1];
- p += 2;
- return *(int16_t*)&ret;
- }
- uint16_t GetUInt16(FT_Bytes& p) const {
- uint16_t ret = p[0] << 8 | p[1];
- p += 2;
- return ret;
- }
- int32_t GetInt32(FT_Bytes& p) const {
- uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
- p += 4;
- return *(int32_t*)&ret;
- }
- uint32_t GetUInt32(FT_Bytes& p) const {
- uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
- p += 4;
- return ret;
- }
+ struct TLookup* Lookup) const;
+ int GetCoverageIndex(struct TCoverageFormatBase* Coverage, uint32_t g) const;
+
+ uint8_t GetUInt8(FT_Bytes& p) const;
+ int16_t GetInt16(FT_Bytes& p) const;
+ uint16_t GetUInt16(FT_Bytes& p) const;
+ int32_t GetInt32(FT_Bytes& p) const;
+ uint32_t GetUInt32(FT_Bytes& p) const;
+
std::map<uint32_t, uint32_t> m_featureMap;
FX_BOOL m_bFeautureMapLoad;
bool loaded;