diff options
Diffstat (limited to 'core/fpdfapi/fpdf_font')
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_cidfont.cpp | 70 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_cidfont.h | 30 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_font.cpp | 26 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp | 8 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_simplefont.cpp | 12 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_simplefont.h | 10 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_type1font.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_type1font.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_type3font.cpp | 10 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/cpdf_type3font.h | 8 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/font_int.h | 28 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/fpdf_font.cpp | 31 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 48 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/include/cpdf_font.h | 24 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/ttgsubtable.cpp | 12 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_font/ttgsubtable.h | 4 |
18 files changed, 165 insertions, 166 deletions
diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp index 956046c3be..9dd045ede9 100644 --- a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp @@ -124,7 +124,7 @@ bool IsValidEmbeddedCharcodeFromUnicodeCharset(CIDSet charset) { FX_WCHAR EmbeddedUnicodeFromCharcode(const FXCMAP_CMap* pEmbedMap, CIDSet charset, - FX_DWORD charcode) { + uint32_t charcode) { if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset)) return 0; @@ -143,7 +143,7 @@ FX_WCHAR EmbeddedUnicodeFromCharcode(const FXCMAP_CMap* pEmbedMap, return 0; } -FX_DWORD EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, +uint32_t EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, CIDSet charset, FX_WCHAR unicode) { if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset)) @@ -158,7 +158,7 @@ FX_DWORD EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, int nCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; for (int i = 0; i < nCodes; ++i) { if (pCodes[i] == unicode) { - FX_DWORD CharCode = FPDFAPI_CharCodeFromCID(pEmbedMap, i); + uint32_t CharCode = FPDFAPI_CharCodeFromCID(pEmbedMap, i); if (CharCode != 0) { return CharCode; } @@ -234,7 +234,7 @@ CPDF_CIDFont* CPDF_CIDFont::AsCIDFont() { return this; } -uint16_t CPDF_CIDFont::CIDFromCharCode(FX_DWORD charcode) const { +uint16_t CPDF_CIDFont::CIDFromCharCode(uint32_t charcode) const { if (!m_pCMap) { return (uint16_t)charcode; } @@ -245,7 +245,7 @@ FX_BOOL CPDF_CIDFont::IsVertWriting() const { return m_pCMap ? m_pCMap->IsVertWriting() : FALSE; } -CFX_WideString CPDF_CIDFont::UnicodeFromCharCode(FX_DWORD charcode) const { +CFX_WideString CPDF_CIDFont::UnicodeFromCharCode(uint32_t charcode) const { CFX_WideString str = CPDF_Font::UnicodeFromCharCode(charcode); if (!str.IsEmpty()) return str; @@ -255,7 +255,7 @@ CFX_WideString CPDF_CIDFont::UnicodeFromCharCode(FX_DWORD charcode) const { return ret; } -FX_WCHAR CPDF_CIDFont::GetUnicodeFromCharCode(FX_DWORD charcode) const { +FX_WCHAR CPDF_CIDFont::GetUnicodeFromCharCode(uint32_t charcode) const { switch (m_pCMap->m_Coding) { case CIDCODING_UCS2: case CIDCODING_UTF16: @@ -293,8 +293,8 @@ FX_WCHAR CPDF_CIDFont::GetUnicodeFromCharCode(FX_DWORD charcode) const { return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode)); } -FX_DWORD CPDF_CIDFont::CharCodeFromUnicode(FX_WCHAR unicode) const { - FX_DWORD charcode = CPDF_Font::CharCodeFromUnicode(unicode); +uint32_t CPDF_CIDFont::CharCodeFromUnicode(FX_WCHAR unicode) const { + uint32_t charcode = CPDF_Font::CharCodeFromUnicode(unicode); if (charcode) return charcode; switch (m_pCMap->m_Coding) { @@ -307,7 +307,7 @@ FX_DWORD CPDF_CIDFont::CharCodeFromUnicode(FX_WCHAR unicode) const { if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) { return 0; } - FX_DWORD CID = 0; + uint32_t CID = 0; while (CID < 65536) { FX_WCHAR this_unicode = m_pCID2UnicodeMap->UnicodeFromCID((uint16_t)CID); @@ -321,7 +321,7 @@ FX_DWORD CPDF_CIDFont::CharCodeFromUnicode(FX_WCHAR unicode) const { } if (unicode < 0x80) { - return static_cast<FX_DWORD>(unicode); + return static_cast<uint32_t>(unicode); } if (m_pCMap->m_Coding == CIDCODING_CID) { return 0; @@ -466,7 +466,7 @@ FX_BOOL CPDF_CIDFont::Load() { return TRUE; } -FX_RECT CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, int level) { +FX_RECT CPDF_CIDFont::GetCharBBox(uint32_t charcode, int level) { if (charcode < 256 && m_CharBBox[charcode].right != FX_SMALL_RECT::kInvalid) return FX_RECT(m_CharBBox[charcode]); @@ -538,13 +538,13 @@ FX_RECT CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, int level) { return rect; } -int CPDF_CIDFont::GetCharWidthF(FX_DWORD charcode, int level) { +int CPDF_CIDFont::GetCharWidthF(uint32_t charcode, int level) { if (m_pAnsiWidths && charcode < 0x80) { return m_pAnsiWidths[charcode]; } uint16_t cid = CIDFromCharCode(charcode); int size = m_WidthList.GetSize(); - FX_DWORD* list = m_WidthList.GetData(); + uint32_t* list = m_WidthList.GetData(); for (int i = 0; i < size; i += 3) { if (cid >= list[i] && cid <= list[i + 1]) { return (int)list[i + 2]; @@ -553,31 +553,31 @@ int CPDF_CIDFont::GetCharWidthF(FX_DWORD charcode, int level) { return m_DefaultWidth; } short CPDF_CIDFont::GetVertWidth(uint16_t CID) const { - FX_DWORD vertsize = m_VertMetrics.GetSize() / 5; + uint32_t vertsize = m_VertMetrics.GetSize() / 5; if (vertsize == 0) { return m_DefaultW1; } - const FX_DWORD* pTable = m_VertMetrics.GetData(); - for (FX_DWORD i = 0; i < vertsize; i++) + const uint32_t* pTable = m_VertMetrics.GetData(); + for (uint32_t i = 0; i < vertsize; i++) if (pTable[i * 5] <= CID && pTable[i * 5 + 1] >= CID) { return (short)(int)pTable[i * 5 + 2]; } return m_DefaultW1; } void CPDF_CIDFont::GetVertOrigin(uint16_t CID, short& vx, short& vy) const { - FX_DWORD vertsize = m_VertMetrics.GetSize() / 5; + uint32_t vertsize = m_VertMetrics.GetSize() / 5; if (vertsize) { - const FX_DWORD* pTable = m_VertMetrics.GetData(); - for (FX_DWORD i = 0; i < vertsize; i++) + const uint32_t* pTable = m_VertMetrics.GetData(); + for (uint32_t i = 0; i < vertsize; i++) if (pTable[i * 5] <= CID && pTable[i * 5 + 1] >= CID) { vx = (short)(int)pTable[i * 5 + 3]; vy = (short)(int)pTable[i * 5 + 4]; return; } } - FX_DWORD dwWidth = m_DefaultWidth; + uint32_t dwWidth = m_DefaultWidth; int size = m_WidthList.GetSize(); - const FX_DWORD* list = m_WidthList.GetData(); + const uint32_t* list = m_WidthList.GetData(); for (int i = 0; i < size; i += 3) { if (CID >= list[i] && CID <= list[i + 1]) { dwWidth = (uint16_t)list[i + 2]; @@ -587,7 +587,7 @@ void CPDF_CIDFont::GetVertOrigin(uint16_t CID, short& vx, short& vy) const { vx = (short)dwWidth / 2; vy = (short)m_DefaultVY; } -int CPDF_CIDFont::GetGlyphIndex(FX_DWORD unicode, FX_BOOL* pVertGlyph) { +int CPDF_CIDFont::GetGlyphIndex(uint32_t unicode, FX_BOOL* pVertGlyph) { if (pVertGlyph) { *pVertGlyph = FALSE; } @@ -637,7 +637,7 @@ int CPDF_CIDFont::GetGlyphIndex(FX_DWORD unicode, FX_BOOL* pVertGlyph) { } return index; } -int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { +int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph) { if (pVertGlyph) { *pVertGlyph = FALSE; } @@ -695,7 +695,7 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { if (bMSUnicode) { index = FXFT_Get_Char_Index(face, unicode); } else if (bMacRoman) { - FX_DWORD maccode = + uint32_t maccode = FT_CharCodeFromUnicode(FXFT_ENCODING_APPLE_ROMAN, unicode); index = !maccode ? FXFT_Get_Name_Index(face, (char*)name) : FXFT_Get_Char_Index(face, maccode); @@ -726,7 +726,7 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { if (err != 0) { int i; for (i = 0; i < FXFT_Get_Face_CharmapCount(face); i++) { - FX_DWORD ret = FT_CharCodeFromUnicode( + uint32_t ret = FT_CharCodeFromUnicode( FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i]), (FX_WCHAR)charcode); if (ret == 0) { @@ -776,25 +776,25 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { return GetGlyphIndex(charcode, pVertGlyph); } } - FX_DWORD byte_pos = cid * 2; + uint32_t byte_pos = cid * 2; if (byte_pos + 2 > m_pCIDToGIDMap->GetSize()) return -1; const uint8_t* pdata = m_pCIDToGIDMap->GetData() + byte_pos; return pdata[0] * 256 + pdata[1]; } -FX_DWORD CPDF_CIDFont::GetNextChar(const FX_CHAR* pString, +uint32_t CPDF_CIDFont::GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const { return m_pCMap->GetNextChar(pString, nStrLen, offset); } -int CPDF_CIDFont::GetCharSize(FX_DWORD charcode) const { +int CPDF_CIDFont::GetCharSize(uint32_t charcode) const { return m_pCMap->GetCharSize(charcode); } int CPDF_CIDFont::CountChar(const FX_CHAR* pString, int size) const { return m_pCMap->CountChar(pString, size); } -int CPDF_CIDFont::AppendChar(FX_CHAR* str, FX_DWORD charcode) const { +int CPDF_CIDFont::AppendChar(FX_CHAR* str, uint32_t charcode) const { return m_pCMap->AppendChar(str, charcode); } FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const { @@ -804,7 +804,7 @@ FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const { } return TRUE; } -FX_BOOL CPDF_CIDFont::IsFontStyleFromCharCode(FX_DWORD charcode) const { +FX_BOOL CPDF_CIDFont::IsFontStyleFromCharCode(uint32_t charcode) const { return TRUE; } void CPDF_CIDFont::LoadSubstFont() { @@ -812,14 +812,14 @@ void CPDF_CIDFont::LoadSubstFont() { g_CharsetCPs[m_Charset], IsVertWriting()); } void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, - CFX_ArrayTemplate<FX_DWORD>& result, + CFX_ArrayTemplate<uint32_t>& result, int nElements) { int width_status = 0; int iCurElement = 0; int first_code = 0; int last_code = 0; - FX_DWORD count = pArray->GetCount(); - for (FX_DWORD i = 0; i < count; i++) { + uint32_t count = pArray->GetCount(); + for (uint32_t i = 0; i < count; i++) { CPDF_Object* pObj = pArray->GetElementValue(i); if (!pObj) continue; @@ -828,8 +828,8 @@ void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, if (width_status != 1) return; - FX_DWORD count = pArray->GetCount(); - for (FX_DWORD j = 0; j < count; j += nElements) { + uint32_t count = pArray->GetCount(); + for (uint32_t j = 0; j < count; j += nElements) { result.Add(first_code); result.Add(first_code); for (int k = 0; k < nElements; k++) { diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.h b/core/fpdfapi/fpdf_font/cpdf_cidfont.h index 6405d2c342..9beb7cb107 100644 --- a/core/fpdfapi/fpdf_font/cpdf_cidfont.h +++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.h @@ -38,35 +38,35 @@ class CPDF_CIDFont : public CPDF_Font { bool IsCIDFont() const override; const CPDF_CIDFont* AsCIDFont() const override; CPDF_CIDFont* AsCIDFont() override; - int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph = NULL) override; - int GetCharWidthF(FX_DWORD charcode, int level = 0) override; - FX_RECT GetCharBBox(FX_DWORD charcode, int level = 0) override; - FX_DWORD GetNextChar(const FX_CHAR* pString, + int GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph = NULL) override; + int GetCharWidthF(uint32_t charcode, int level = 0) override; + FX_RECT GetCharBBox(uint32_t charcode, int level = 0) override; + uint32_t GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const override; int CountChar(const FX_CHAR* pString, int size) const override; - int AppendChar(FX_CHAR* str, FX_DWORD charcode) const override; - int GetCharSize(FX_DWORD charcode) const override; + int AppendChar(FX_CHAR* str, uint32_t charcode) const override; + int GetCharSize(uint32_t charcode) const override; FX_BOOL IsVertWriting() const override; FX_BOOL IsUnicodeCompatible() const override; FX_BOOL Load() override; - CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const override; - FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const override; + CFX_WideString UnicodeFromCharCode(uint32_t charcode) const override; + uint32_t CharCodeFromUnicode(FX_WCHAR Unicode) const override; FX_BOOL LoadGB2312(); - uint16_t CIDFromCharCode(FX_DWORD charcode) const; + uint16_t CIDFromCharCode(uint32_t charcode) const; const uint8_t* GetCIDTransform(uint16_t CID) const; short GetVertWidth(uint16_t CID) const; void GetVertOrigin(uint16_t CID, short& vx, short& vy) const; - virtual FX_BOOL IsFontStyleFromCharCode(FX_DWORD charcode) const; + virtual FX_BOOL IsFontStyleFromCharCode(uint32_t charcode) const; protected: - int GetGlyphIndex(FX_DWORD unicodeb, FX_BOOL* pVertGlyph); + int GetGlyphIndex(uint32_t unicodeb, FX_BOOL* pVertGlyph); void LoadMetricsArray(CPDF_Array* pArray, - CFX_ArrayTemplate<FX_DWORD>& result, + CFX_ArrayTemplate<uint32_t>& result, int nElements); void LoadSubstFont(); - FX_WCHAR GetUnicodeFromCharCode(FX_DWORD charcode) const; + FX_WCHAR GetUnicodeFromCharCode(uint32_t charcode) const; CPDF_CMap* m_pCMap; CPDF_CMap* m_pAllocatedCMap; @@ -78,10 +78,10 @@ class CPDF_CIDFont : public CPDF_Font { uint16_t m_DefaultWidth; uint16_t* m_pAnsiWidths; FX_SMALL_RECT m_CharBBox[256]; - CFX_ArrayTemplate<FX_DWORD> m_WidthList; + CFX_ArrayTemplate<uint32_t> m_WidthList; short m_DefaultVY; short m_DefaultW1; - CFX_ArrayTemplate<FX_DWORD> m_VertMetrics; + CFX_ArrayTemplate<uint32_t> m_VertMetrics; FX_BOOL m_bAdobeCourierStd; CFX_CTTGSUBTable* m_pTTGSUBTable; }; diff --git a/core/fpdfapi/fpdf_font/cpdf_font.cpp b/core/fpdfapi/fpdf_font/cpdf_font.cpp index bb63966161..c52ce8ff93 100644 --- a/core/fpdfapi/fpdf_font/cpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_font.cpp @@ -121,16 +121,16 @@ int CPDF_Font::CountChar(const FX_CHAR* pString, int size) const { return size; } -int CPDF_Font::GetCharSize(FX_DWORD charcode) const { +int CPDF_Font::GetCharSize(uint32_t charcode) const { return 1; } -int CPDF_Font::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { +int CPDF_Font::GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph) { ASSERT(false); return 0; } -int CPDF_Font::GlyphFromCharCodeExt(FX_DWORD charcode) { +int CPDF_Font::GlyphFromCharCodeExt(uint32_t charcode) { return GlyphFromCharCode(charcode); } @@ -145,12 +145,12 @@ FX_BOOL CPDF_Font::IsVertWriting() const { return bVertWriting; } -int CPDF_Font::AppendChar(FX_CHAR* buf, FX_DWORD charcode) const { +int CPDF_Font::AppendChar(FX_CHAR* buf, uint32_t charcode) const { *buf = (FX_CHAR)charcode; return 1; } -void CPDF_Font::AppendChar(CFX_ByteString& str, FX_DWORD charcode) const { +void CPDF_Font::AppendChar(CFX_ByteString& str, uint32_t charcode) const { char buf[4]; int len = AppendChar(buf, charcode); if (len == 1) { @@ -160,7 +160,7 @@ void CPDF_Font::AppendChar(CFX_ByteString& str, FX_DWORD charcode) const { } } -CFX_WideString CPDF_Font::UnicodeFromCharCode(FX_DWORD charcode) const { +CFX_WideString CPDF_Font::UnicodeFromCharCode(uint32_t charcode) const { if (!m_bToUnicodeLoaded) ((CPDF_Font*)this)->LoadUnicodeMap(); @@ -169,7 +169,7 @@ CFX_WideString CPDF_Font::UnicodeFromCharCode(FX_DWORD charcode) const { return CFX_WideString(); } -FX_DWORD CPDF_Font::CharCodeFromUnicode(FX_WCHAR unicode) const { +uint32_t CPDF_Font::CharCodeFromUnicode(FX_WCHAR unicode) const { if (!m_bToUnicodeLoaded) ((CPDF_Font*)this)->LoadUnicodeMap(); @@ -237,7 +237,7 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { return; const uint8_t* pFontData = m_pFontFile->GetData(); - FX_DWORD dwFontSize = m_pFontFile->GetSize(); + uint32_t dwFontSize = m_pFontFile->GetSize(); if (!m_Font.LoadEmbedded(pFontData, dwFontSize)) { m_pDocument->GetPageData()->ReleaseFontFileStreamAcc( const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream())); @@ -305,7 +305,7 @@ int CPDF_Font::GetStringWidth(const FX_CHAR* pString, int size) { int offset = 0; int width = 0; while (offset < size) { - FX_DWORD charcode = GetNextChar(pString, size, offset); + uint32_t charcode = GetNextChar(pString, size, offset); width += GetCharWidthF(charcode); } return width; @@ -387,14 +387,14 @@ CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc, return pFont; } -FX_DWORD CPDF_Font::GetNextChar(const FX_CHAR* pString, +uint32_t CPDF_Font::GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const { if (offset < 0 || nStrLen < 1) { return 0; } uint8_t ch = offset < nStrLen ? pString[offset++] : pString[nStrLen - 1]; - return static_cast<FX_DWORD>(ch); + return static_cast<uint32_t>(ch); } void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, @@ -450,8 +450,8 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, return; } pCharNames = new CFX_ByteString[256]; - FX_DWORD cur_code = 0; - for (FX_DWORD i = 0; i < pDiffs->GetCount(); i++) { + uint32_t cur_code = 0; + for (uint32_t i = 0; i < pDiffs->GetCount(); i++) { CPDF_Object* pElement = pDiffs->GetElementValue(i); if (!pElement) continue; diff --git a/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp b/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp index 64e11e09de..3fc16a2c43 100644 --- a/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp @@ -1631,8 +1631,8 @@ const FX_CHAR* const ZapfEncodingNames[224] = { "a182", NULL, "a201", "a183", "a184", "a197", "a185", "a194", "a198", "a186", "a195", "a187", "a188", "a189", "a190", "a191", NULL}; -FX_DWORD PDF_FindCode(const uint16_t* pCodes, uint16_t unicode) { - for (FX_DWORD i = 0; i < 256; i++) +uint32_t PDF_FindCode(const uint16_t* pCodes, uint16_t unicode) { + for (uint32_t i = 0; i < 256; i++) if (pCodes[i] == unicode) return i; return 0; @@ -1713,7 +1713,7 @@ CPDF_Object* CPDF_FontEncoding::Realize() { return pDict; } -FX_DWORD FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode) { +uint32_t FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode) { switch (encoding) { case FXFT_ENCODING_UNICODE: return unicode; @@ -1796,7 +1796,7 @@ const FX_CHAR* PDF_CharNameFromPredefinedCharSet(int encoding, return nullptr; } -FX_WCHAR FT_UnicodeFromCharCode(int encoding, FX_DWORD charcode) { +FX_WCHAR FT_UnicodeFromCharCode(int encoding, uint32_t charcode) { switch (encoding) { case FXFT_ENCODING_UNICODE: return (uint16_t)charcode; diff --git a/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp b/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp index d7057e1894..baac366e2a 100644 --- a/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp @@ -22,7 +22,7 @@ CPDF_SimpleFont::~CPDF_SimpleFont() { delete[] m_pCharNames; } -int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph) { +int CPDF_SimpleFont::GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph) { if (pVertGlyph) { *pVertGlyph = FALSE; } @@ -82,7 +82,7 @@ void CPDF_SimpleFont::LoadCharMetrics(int charcode) { } } -int CPDF_SimpleFont::GetCharWidthF(FX_DWORD charcode, int level) { +int CPDF_SimpleFont::GetCharWidthF(uint32_t charcode, int level) { if (charcode > 0xff) { charcode = 0; } @@ -95,7 +95,7 @@ int CPDF_SimpleFont::GetCharWidthF(FX_DWORD charcode, int level) { return (int16_t)m_CharWidth[charcode]; } -FX_RECT CPDF_SimpleFont::GetCharBBox(FX_DWORD charcode, int level) { +FX_RECT CPDF_SimpleFont::GetCharBBox(uint32_t charcode, int level) { if (charcode > 0xff) charcode = 0; @@ -204,7 +204,7 @@ FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const { m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; } -CFX_WideString CPDF_SimpleFont::UnicodeFromCharCode(FX_DWORD charcode) const { +CFX_WideString CPDF_SimpleFont::UnicodeFromCharCode(uint32_t charcode) const { CFX_WideString unicode = CPDF_Font::UnicodeFromCharCode(charcode); if (!unicode.IsEmpty()) return unicode; @@ -214,8 +214,8 @@ CFX_WideString CPDF_SimpleFont::UnicodeFromCharCode(FX_DWORD charcode) const { return ret; } -FX_DWORD CPDF_SimpleFont::CharCodeFromUnicode(FX_WCHAR unicode) const { - FX_DWORD ret = CPDF_Font::CharCodeFromUnicode(unicode); +uint32_t CPDF_SimpleFont::CharCodeFromUnicode(FX_WCHAR unicode) const { + uint32_t ret = CPDF_Font::CharCodeFromUnicode(unicode); if (ret) return ret; return m_Encoding.CharCodeFromUnicode(unicode); diff --git a/core/fpdfapi/fpdf_font/cpdf_simplefont.h b/core/fpdfapi/fpdf_font/cpdf_simplefont.h index 19d6816c9f..7b07c9971e 100644 --- a/core/fpdfapi/fpdf_font/cpdf_simplefont.h +++ b/core/fpdfapi/fpdf_font/cpdf_simplefont.h @@ -18,12 +18,12 @@ class CPDF_SimpleFont : public CPDF_Font { virtual ~CPDF_SimpleFont(); // CPDF_Font: - int GetCharWidthF(FX_DWORD charcode, int level = 0) override; - FX_RECT GetCharBBox(FX_DWORD charcode, int level = 0) override; - int GlyphFromCharCode(FX_DWORD charcode, FX_BOOL* pVertGlyph = NULL) override; + int GetCharWidthF(uint32_t charcode, int level = 0) override; + FX_RECT GetCharBBox(uint32_t charcode, int level = 0) override; + int GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph = NULL) override; FX_BOOL IsUnicodeCompatible() const override; - CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const override; - FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const override; + CFX_WideString UnicodeFromCharCode(uint32_t charcode) const override; + uint32_t CharCodeFromUnicode(FX_WCHAR Unicode) const override; CPDF_FontEncoding* GetEncoding() { return &m_Encoding; } diff --git a/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp b/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp index 13e031808e..032fa00e96 100644 --- a/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp @@ -112,7 +112,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { m_GlyphIndex[charcode] = FXFT_Get_Char_Index( m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]); } else if (bMacRoman) { - FX_DWORD maccode = FT_CharCodeFromUnicode( + uint32_t maccode = FT_CharCodeFromUnicode( FXFT_ENCODING_APPLE_ROMAN, m_Encoding.m_Unicodes[charcode]); if (!maccode) { m_GlyphIndex[charcode] = diff --git a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp index 5a6ee34362..b2f3ec898b 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type1font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_type1font.cpp @@ -102,7 +102,7 @@ FX_BOOL CPDF_Type1Font::Load() { return LoadCommon(); } -int CPDF_Type1Font::GlyphFromCharCodeExt(FX_DWORD charcode) { +int CPDF_Type1Font::GlyphFromCharCodeExt(uint32_t charcode) { if (charcode > 0xff) { return -1; } diff --git a/core/fpdfapi/fpdf_font/cpdf_type1font.h b/core/fpdfapi/fpdf_font/cpdf_type1font.h index da82cd4417..188b766c8a 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type1font.h +++ b/core/fpdfapi/fpdf_font/cpdf_type1font.h @@ -18,7 +18,7 @@ class CPDF_Type1Font : public CPDF_SimpleFont { bool IsType1Font() const override; const CPDF_Type1Font* AsType1Font() const override; CPDF_Type1Font* AsType1Font() override; - int GlyphFromCharCodeExt(FX_DWORD charcode) override; + int GlyphFromCharCodeExt(uint32_t charcode) override; int GetBase14Font() const { return m_Base14Font; } diff --git a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp index 91a03a9830..8591b87be4 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type3font.cpp +++ b/core/fpdfapi/fpdf_font/cpdf_type3font.cpp @@ -57,14 +57,14 @@ FX_BOOL CPDF_Type3Font::Load() { int StartChar = m_pFontDict->GetIntegerBy("FirstChar"); CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths"); if (pWidthArray && (StartChar >= 0 && StartChar < 256)) { - FX_DWORD count = pWidthArray->GetCount(); + uint32_t count = pWidthArray->GetCount(); if (count > 256) { count = 256; } if (StartChar + count > 256) { count = 256 - StartChar; } - for (FX_DWORD i = 0; i < count; i++) { + for (uint32_t i = 0; i < count; i++) { m_CharWidthL[StartChar + i] = FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000); } @@ -89,7 +89,7 @@ void CPDF_Type3Font::CheckType3FontMetrics() { CheckFontMetrics(); } -CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) { +CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) { if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) return nullptr; @@ -145,7 +145,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) { return pCachedChar; } -int CPDF_Type3Font::GetCharWidthF(FX_DWORD charcode, int level) { +int CPDF_Type3Font::GetCharWidthF(uint32_t charcode, int level) { if (charcode >= FX_ArraySize(m_CharWidthL)) charcode = 0; @@ -156,7 +156,7 @@ int CPDF_Type3Font::GetCharWidthF(FX_DWORD charcode, int level) { return pChar ? pChar->m_Width : 0; } -FX_RECT CPDF_Type3Font::GetCharBBox(FX_DWORD charcode, int level) { +FX_RECT CPDF_Type3Font::GetCharBBox(uint32_t charcode, int level) { const CPDF_Type3Char* pChar = LoadChar(charcode, level); return pChar ? pChar->m_BBox : FX_RECT(); } diff --git a/core/fpdfapi/fpdf_font/cpdf_type3font.h b/core/fpdfapi/fpdf_font/cpdf_type3font.h index 554556934e..70992c9c8c 100644 --- a/core/fpdfapi/fpdf_font/cpdf_type3font.h +++ b/core/fpdfapi/fpdf_font/cpdf_type3font.h @@ -25,13 +25,13 @@ class CPDF_Type3Font : public CPDF_SimpleFont { bool IsType3Font() const override; const CPDF_Type3Font* AsType3Font() const override; CPDF_Type3Font* AsType3Font() override; - int GetCharWidthF(FX_DWORD charcode, int level = 0) override; - FX_RECT GetCharBBox(FX_DWORD charcode, int level = 0) override; + int GetCharWidthF(uint32_t charcode, int level = 0) override; + FX_RECT GetCharBBox(uint32_t charcode, int level = 0) override; void SetPageResources(CPDF_Dictionary* pResources) { m_pPageResources = pResources; } - CPDF_Type3Char* LoadChar(FX_DWORD charcode, int level = 0); + CPDF_Type3Char* LoadChar(uint32_t charcode, int level = 0); void CheckType3FontMetrics(); CFX_Matrix& GetFontMatrix() { return m_FontMatrix; } @@ -50,7 +50,7 @@ class CPDF_Type3Font : public CPDF_SimpleFont { CPDF_Dictionary* m_pCharProcs; CPDF_Dictionary* m_pPageResources; CPDF_Dictionary* m_pFontResources; - std::map<FX_DWORD, CPDF_Type3Char*> m_CacheMap; + std::map<uint32_t, CPDF_Type3Char*> m_CacheMap; }; #endif // CORE_FPDFAPI_FPDF_FONT_CPDF_TYPE3FONT_H_ diff --git a/core/fpdfapi/fpdf_font/font_int.h b/core/fpdfapi/fpdf_font/font_int.h index b9b5b5327d..3ee4068d7d 100644 --- a/core/fpdfapi/fpdf_font/font_int.h +++ b/core/fpdfapi/fpdf_font/font_int.h @@ -98,7 +98,7 @@ class CPDF_CMapParser { friend class fpdf_font_cid_CMap_GetCode_Test; friend class fpdf_font_cid_CMap_GetCodeRange_Test; - static FX_DWORD CMap_GetCode(const CFX_ByteStringC& word); + static uint32_t CMap_GetCode(const CFX_ByteStringC& word); static bool CMap_GetCodeRange(CMap_CodeRange& range, const CFX_ByteStringC& first, const CFX_ByteStringC& second); @@ -106,7 +106,7 @@ class CPDF_CMapParser { CPDF_CMap* m_pCMap; int m_Status; int m_CodeSeq; - FX_DWORD m_CodePoints[4]; + uint32_t m_CodePoints[4]; CFX_ArrayTemplate<CMap_CodeRange> m_CodeRanges; CFX_ByteString m_Registry, m_Ordering, m_Supplement; CFX_ByteString m_LastWord; @@ -136,16 +136,16 @@ class CPDF_CMap { FX_BOOL LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* name, FX_BOOL bPromptCJK); - FX_BOOL LoadEmbedded(const uint8_t* pData, FX_DWORD dwSize); + 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; } - uint16_t CIDFromCharCode(FX_DWORD charcode) const; - FX_DWORD CharCodeFromCID(uint16_t CID) const; - int GetCharSize(FX_DWORD charcode) const; - FX_DWORD GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const; + uint16_t CIDFromCharCode(uint32_t charcode) const; + uint32_t CharCodeFromCID(uint16_t CID) const; + int GetCharSize(uint32_t charcode) const; + uint32_t GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const; int CountChar(const FX_CHAR* pString, int size) const; - int AppendChar(FX_CHAR* str, FX_DWORD charcode) const; + int AppendChar(FX_CHAR* str, uint32_t charcode) const; protected: ~CPDF_CMap(); @@ -179,17 +179,17 @@ class CPDF_CID2UnicodeMap { protected: CIDSet m_Charset; const uint16_t* m_pEmbeddedMap; - FX_DWORD m_EmbeddedCount; + uint32_t m_EmbeddedCount; }; class CPDF_ToUnicodeMap { public: void Load(CPDF_Stream* pStream); - CFX_WideString Lookup(FX_DWORD charcode); - FX_DWORD ReverseLookup(FX_WCHAR unicode); + CFX_WideString Lookup(uint32_t charcode); + uint32_t ReverseLookup(FX_WCHAR unicode); protected: - std::map<FX_DWORD, FX_DWORD> m_Map; + std::map<uint32_t, uint32_t> m_Map; CPDF_CID2UnicodeMap* m_pBaseMap; CFX_WideTextBuf m_MultiCharBuf; @@ -197,12 +197,12 @@ class CPDF_ToUnicodeMap { friend class fpdf_font_StringToCode_Test; friend class fpdf_font_StringToWideString_Test; - static FX_DWORD StringToCode(const CFX_ByteStringC& str); + static uint32_t StringToCode(const CFX_ByteStringC& str); static CFX_WideString StringToWideString(const CFX_ByteStringC& str); }; void FPDFAPI_LoadCID2UnicodeMap(CIDSet charset, const uint16_t*& pMap, - FX_DWORD& count); + uint32_t& count); #endif // CORE_FPDFAPI_FPDF_FONT_FONT_INT_H_ diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp index c0c6f520f4..b0659b4a52 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp @@ -90,25 +90,24 @@ short TT2PDF(int m, FXFT_Face face) { return (m * 1000 + upm / 2) / upm; } - -CFX_WideString CPDF_ToUnicodeMap::Lookup(FX_DWORD charcode) { +CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) { auto it = m_Map.find(charcode); if (it != m_Map.end()) { - FX_DWORD value = it->second; + uint32_t value = it->second; FX_WCHAR unicode = (FX_WCHAR)(value & 0xffff); if (unicode != 0xffff) { return unicode; } const FX_WCHAR* buf = m_MultiCharBuf.GetBuffer(); - FX_DWORD buf_len = m_MultiCharBuf.GetLength(); + uint32_t buf_len = m_MultiCharBuf.GetLength(); if (!buf || buf_len == 0) { return CFX_WideString(); } - FX_DWORD index = value >> 16; + uint32_t index = value >> 16; if (index >= buf_len) { return CFX_WideString(); } - FX_DWORD len = buf[index]; + uint32_t len = buf[index]; if (index + len < index || index + len >= buf_len) { return CFX_WideString(); } @@ -120,7 +119,7 @@ CFX_WideString CPDF_ToUnicodeMap::Lookup(FX_DWORD charcode) { return CFX_WideString(); } -FX_DWORD CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) { +uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) { for (const auto& pair : m_Map) { if (pair.second == unicode) return pair.first; @@ -129,7 +128,7 @@ FX_DWORD CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) { } // Static. -FX_DWORD CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) { +uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) { const FX_CHAR* buf = str.GetCStr(); int len = str.GetLength(); if (len == 0) @@ -209,7 +208,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { if (word.IsEmpty() || word == "endbfchar") { break; } - FX_DWORD srccode = StringToCode(word); + uint32_t srccode = StringToCode(word); word = parser.GetWord(); CFX_WideString destcode = StringToWideString(word); int len = destcode.GetLength(); @@ -232,15 +231,15 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { break; } high = parser.GetWord(); - FX_DWORD lowcode = StringToCode(low); - FX_DWORD highcode = + uint32_t lowcode = StringToCode(low); + uint32_t highcode = (lowcode & 0xffffff00) | (StringToCode(high) & 0xff); - if (highcode == (FX_DWORD)-1) { + if (highcode == (uint32_t)-1) { break; } CFX_ByteString start = parser.GetWord(); if (start == "[") { - for (FX_DWORD code = lowcode; code <= highcode; code++) { + for (uint32_t code = lowcode; code <= highcode; code++) { CFX_ByteString dest = parser.GetWord(); CFX_WideString destcode = StringToWideString(dest); int len = destcode.GetLength(); @@ -259,14 +258,14 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { } else { CFX_WideString destcode = StringToWideString(start); int len = destcode.GetLength(); - FX_DWORD value = 0; + uint32_t value = 0; if (len == 1) { value = StringToCode(start); - for (FX_DWORD code = lowcode; code <= highcode; code++) { + for (uint32_t code = lowcode; code <= highcode; code++) { m_Map[code] = value++; } } else { - for (FX_DWORD code = lowcode; code <= highcode; code++) { + for (uint32_t code = lowcode; code <= highcode; code++) { CFX_WideString retcode; if (code == lowcode) { retcode = destcode; diff --git a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp index 95452a7227..2552a3c0a6 100644 --- a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -195,15 +195,15 @@ CFX_ByteString CMap_GetString(const CFX_ByteStringC& word) { } int CompareDWORD(const void* data1, const void* data2) { - return (*(FX_DWORD*)data1) - (*(FX_DWORD*)data2); + return (*(uint32_t*)data1) - (*(uint32_t*)data2); } int CompareCID(const void* key, const void* element) { - if ((*(FX_DWORD*)key) < (*(FX_DWORD*)element)) { + if ((*(uint32_t*)key) < (*(uint32_t*)element)) { return -1; } - if ((*(FX_DWORD*)key) > - (*(FX_DWORD*)element) + ((FX_DWORD*)element)[1] / 65536) { + if ((*(uint32_t*)key) > + (*(uint32_t*)element) + ((uint32_t*)element)[1] / 65536) { return 1; } return 0; @@ -237,7 +237,7 @@ int CheckCodeRange(uint8_t* codes, return 0; } -int GetCharSizeImpl(FX_DWORD charcode, +int GetCharSizeImpl(uint32_t charcode, CMap_CodeRange* pRanges, int iRangesSize) { if (!iRangesSize) @@ -379,7 +379,7 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { } else if (m_Status == 1 || m_Status == 2) { m_CodePoints[m_CodeSeq] = CMap_GetCode(word); m_CodeSeq++; - FX_DWORD StartCode, EndCode; + uint32_t StartCode, EndCode; uint16_t StartCID; if (m_Status == 1) { if (m_CodeSeq < 2) { @@ -396,11 +396,11 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { StartCID = (uint16_t)m_CodePoints[2]; } if (EndCode < 0x10000) { - for (FX_DWORD code = StartCode; code <= EndCode; code++) { + for (uint32_t code = StartCode; code <= EndCode; code++) { m_pCMap->m_pMapping[code] = (uint16_t)(StartCID + code - StartCode); } } else { - FX_DWORD buf[2]; + uint32_t buf[2]; buf[0] = StartCode; buf[1] = ((EndCode - StartCode) << 16) + StartCID; m_AddMaps.AppendBlock(buf, sizeof buf); @@ -451,7 +451,7 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { } // Static. -FX_DWORD CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) { +uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) { int num = 0; if (word.GetAt(0) == '<') { for (int i = 1; i < word.GetLength() && std::isxdigit(word.GetAt(i)); ++i) @@ -487,12 +487,12 @@ bool CPDF_CMapParser::CMap_GetCodeRange(CMap_CodeRange& range, range.m_Lower[i] = FXSYS_toHexDigit(digit1) * 16 + FXSYS_toHexDigit(digit2); } - FX_DWORD size = second.GetLength(); + uint32_t size = second.GetLength(); for (i = 0; i < range.m_CharSize; ++i) { - uint8_t digit1 = ((FX_DWORD)i * 2 + 1 < size) + uint8_t digit1 = ((uint32_t)i * 2 + 1 < size) ? second.GetAt((FX_STRSIZE)i * 2 + 1) : '0'; - uint8_t digit2 = ((FX_DWORD)i * 2 + 2 < size) + uint8_t digit2 = ((uint32_t)i * 2 + 2 < size) ? second.GetAt((FX_STRSIZE)i * 2 + 2) : '0'; range.m_Upper[i] = FXSYS_toHexDigit(digit1) * 16 + FXSYS_toHexDigit(digit2); @@ -555,7 +555,7 @@ FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, m_CodingScheme = map->m_CodingScheme; if (m_CodingScheme == MixedTwoBytes) { m_pLeadingBytes = FX_Alloc(uint8_t, 256); - for (FX_DWORD i = 0; i < map->m_LeadingSegCount; ++i) { + for (uint32_t i = 0; i < map->m_LeadingSegCount; ++i) { const uint8_t* segs = map->m_LeadingSegs; for (int b = segs[i * 2]; b <= segs[i * 2 + 1]; ++b) { m_pLeadingBytes[b] = 1; @@ -569,7 +569,7 @@ FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, } return FALSE; } -FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, FX_DWORD size) { +FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, uint32_t size) { m_pMapping = FX_Alloc(uint16_t, 65536); CPDF_CMapParser parser; parser.Initialize(this); @@ -583,7 +583,7 @@ FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, FX_DWORD size) { } if (m_CodingScheme == MixedFourBytes && parser.m_AddMaps.GetSize()) { m_pAddMapping = FX_Alloc(uint8_t, parser.m_AddMaps.GetSize() + 4); - *(FX_DWORD*)m_pAddMapping = parser.m_AddMaps.GetSize() / 8; + *(uint32_t*)m_pAddMapping = parser.m_AddMaps.GetSize() / 8; FXSYS_memcpy(m_pAddMapping + 4, parser.m_AddMaps.GetBuffer(), parser.m_AddMaps.GetSize()); FXSYS_qsort(m_pAddMapping + 4, parser.m_AddMaps.GetSize() / 8, 8, @@ -592,7 +592,7 @@ FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, FX_DWORD size) { return TRUE; } -uint16_t CPDF_CMap::CIDFromCharCode(FX_DWORD charcode) const { +uint16_t CPDF_CMap::CIDFromCharCode(uint32_t charcode) const { if (m_Coding == CIDCODING_CID) { return (uint16_t)charcode; } @@ -605,27 +605,27 @@ uint16_t CPDF_CMap::CIDFromCharCode(FX_DWORD charcode) const { if (charcode >> 16) { if (m_pAddMapping) { void* found = FXSYS_bsearch(&charcode, m_pAddMapping + 4, - *(FX_DWORD*)m_pAddMapping, 8, CompareCID); + *(uint32_t*)m_pAddMapping, 8, CompareCID); if (!found) { if (m_pUseMap) { return m_pUseMap->CIDFromCharCode(charcode); } return 0; } - return (uint16_t)(((FX_DWORD*)found)[1] % 65536 + charcode - - *(FX_DWORD*)found); + return (uint16_t)(((uint32_t*)found)[1] % 65536 + charcode - + *(uint32_t*)found); } if (m_pUseMap) return m_pUseMap->CIDFromCharCode(charcode); return 0; } - FX_DWORD CID = m_pMapping[charcode]; + uint32_t CID = m_pMapping[charcode]; if (!CID && m_pUseMap) return m_pUseMap->CIDFromCharCode(charcode); return (uint16_t)CID; } -FX_DWORD CPDF_CMap::GetNextChar(const FX_CHAR* pString, +uint32_t CPDF_CMap::GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const { switch (m_CodingScheme) { @@ -654,7 +654,7 @@ FX_DWORD CPDF_CMap::GetNextChar(const FX_CHAR* pString, return 0; } if (ret == 2) { - FX_DWORD charcode = 0; + uint32_t charcode = 0; for (int i = 0; i < char_size; i++) { charcode = (charcode << 8) + codes[i]; } @@ -670,7 +670,7 @@ FX_DWORD CPDF_CMap::GetNextChar(const FX_CHAR* pString, } return 0; } -int CPDF_CMap::GetCharSize(FX_DWORD charcode) const { +int CPDF_CMap::GetCharSize(uint32_t charcode) const { switch (m_CodingScheme) { case OneByte: return 1; @@ -719,7 +719,7 @@ int CPDF_CMap::CountChar(const FX_CHAR* pString, int size) const { return size; } -int CPDF_CMap::AppendChar(FX_CHAR* str, FX_DWORD charcode) const { +int CPDF_CMap::AppendChar(FX_CHAR* str, uint32_t charcode) const { switch (m_CodingScheme) { case OneByte: str[0] = (uint8_t)charcode; diff --git a/core/fpdfapi/fpdf_font/include/cpdf_font.h b/core/fpdfapi/fpdf_font/include/cpdf_font.h index 1931c245de..79456aa7a5 100644 --- a/core/fpdfapi/fpdf_font/include/cpdf_font.h +++ b/core/fpdfapi/fpdf_font/include/cpdf_font.h @@ -39,7 +39,7 @@ class CPDF_Font { CPDF_Dictionary* pFontDict); static CPDF_Font* GetStockFont(CPDF_Document* pDoc, const CFX_ByteStringC& fontname); - static const FX_DWORD kInvalidCharCode = static_cast<FX_DWORD>(-1); + static const uint32_t kInvalidCharCode = static_cast<uint32_t>(-1); virtual ~CPDF_Font(); @@ -58,27 +58,27 @@ class CPDF_Font { virtual FX_BOOL IsVertWriting() const; virtual FX_BOOL IsUnicodeCompatible() const; - virtual FX_DWORD GetNextChar(const FX_CHAR* pString, + virtual uint32_t GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const; virtual int CountChar(const FX_CHAR* pString, int size) const; - virtual int AppendChar(FX_CHAR* buf, FX_DWORD charcode) const; - virtual int GetCharSize(FX_DWORD charcode) const; - virtual int GlyphFromCharCode(FX_DWORD charcode, + virtual int AppendChar(FX_CHAR* buf, uint32_t charcode) const; + virtual int GetCharSize(uint32_t charcode) const; + virtual int GlyphFromCharCode(uint32_t charcode, FX_BOOL* pVertGlyph = nullptr); - virtual int GlyphFromCharCodeExt(FX_DWORD charcode); - virtual CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const; - virtual FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const; + virtual int GlyphFromCharCodeExt(uint32_t charcode); + virtual CFX_WideString UnicodeFromCharCode(uint32_t charcode) const; + virtual uint32_t CharCodeFromUnicode(FX_WCHAR Unicode) const; const CFX_ByteString& GetBaseFont() const { return m_BaseFont; } const CFX_SubstFont* GetSubstFont() const { return m_Font.GetSubstFont(); } - FX_DWORD GetFlags() const { return m_Flags; } + uint32_t GetFlags() const { return m_Flags; } FX_BOOL IsEmbedded() const { return IsType3Font() || m_pFontFile != nullptr; } CPDF_StreamAcc* GetFontFile() const { return m_pFontFile; } CPDF_Dictionary* GetFontDict() const { return m_pFontDict; } FX_BOOL IsStandardFont() const; FXFT_Face GetFace() const { return m_Font.GetFace(); } - void AppendChar(CFX_ByteString& str, FX_DWORD charcode) const; + void AppendChar(CFX_ByteString& str, uint32_t charcode) const; void GetFontBBox(FX_RECT& rect) const { rect = m_FontBBox; } int GetTypeAscent() const { return m_Ascent; } @@ -87,8 +87,8 @@ class CPDF_Font { int GetStemV() const { return m_StemV; } int GetStringWidth(const FX_CHAR* pString, int size); - virtual int GetCharWidthF(FX_DWORD charcode, int level = 0) = 0; - virtual FX_RECT GetCharBBox(FX_DWORD charcode, int level = 0) = 0; + virtual int GetCharWidthF(uint32_t charcode, int level = 0) = 0; + virtual FX_RECT GetCharBBox(uint32_t charcode, int level = 0) = 0; CPDF_Document* m_pDocument; CFX_Font m_Font; diff --git a/core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h b/core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h index a64687cd0e..6d6ff43814 100644 --- a/core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h +++ b/core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h @@ -20,8 +20,8 @@ #define PDFFONT_ENCODING_MS_SYMBOL 8 #define PDFFONT_ENCODING_UNICODE 9 -FX_DWORD FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode); -FX_WCHAR FT_UnicodeFromCharCode(int encoding, FX_DWORD charcode); +uint32_t FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode); +FX_WCHAR FT_UnicodeFromCharCode(int encoding, uint32_t charcode); FX_WCHAR PDF_UnicodeFromAdobeName(const FX_CHAR* name); CFX_ByteString PDF_AdobeNameFromUnicode(FX_WCHAR unicode); diff --git a/core/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/fpdfapi/fpdf_font/ttgsubtable.cpp index 24825ec14e..bb1a6f9f22 100644 --- a/core/fpdfapi/fpdf_font/ttgsubtable.cpp +++ b/core/fpdfapi/fpdf_font/ttgsubtable.cpp @@ -16,7 +16,7 @@ CFX_GlyphMap::CFX_GlyphMap() {} CFX_GlyphMap::~CFX_GlyphMap() {} extern "C" { static int _CompareInt(const void* p1, const void* p2) { - return (*(FX_DWORD*)p1) - (*(FX_DWORD*)p2); + return (*(uint32_t*)p1) - (*(uint32_t*)p2); } }; struct _IntPair { @@ -24,7 +24,7 @@ struct _IntPair { int32_t value; }; void CFX_GlyphMap::SetAt(int key, int value) { - FX_DWORD count = m_Buffer.GetSize() / sizeof(_IntPair); + uint32_t count = m_Buffer.GetSize() / sizeof(_IntPair); _IntPair* buf = (_IntPair*)m_Buffer.GetBuffer(); _IntPair pair = {key, value}; if (count == 0 || key > buf[count - 1].key) { @@ -52,7 +52,7 @@ FX_BOOL CFX_GlyphMap::Lookup(int key, int& value) { if (!pResult) { return FALSE; } - value = ((FX_DWORD*)pResult)[1]; + value = ((uint32_t*)pResult)[1]; return TRUE; } bool CFX_CTTGSUBTable::LoadGSUBTable(FT_Bytes gsub) { @@ -82,7 +82,7 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum, k < ((ScriptList.ScriptRecord + i)->Script.LangSysRecord + j) ->LangSys.FeatureCount; ++k) { - FX_DWORD index = + uint32_t index = *(((ScriptList.ScriptRecord + i)->Script.LangSysRecord + j) ->LangSys.FeatureIndex + k); @@ -382,8 +382,8 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw, rec->Substitute[i] = GetUInt16(sp); } } -FX_BOOL CFX_GSUBTable::GetVerticalGlyph(FX_DWORD glyphnum, - FX_DWORD* vglyphnum) { +FX_BOOL CFX_GSUBTable::GetVerticalGlyph(uint32_t glyphnum, + uint32_t* vglyphnum) { return m_GsubImp.GetVerticalGlyph(glyphnum, vglyphnum); } // static diff --git a/core/fpdfapi/fpdf_font/ttgsubtable.h b/core/fpdfapi/fpdf_font/ttgsubtable.h index e0bdcc75e2..56f3fc01ea 100644 --- a/core/fpdfapi/fpdf_font/ttgsubtable.h +++ b/core/fpdfapi/fpdf_font/ttgsubtable.h @@ -344,7 +344,7 @@ class CFX_CTTGSUBTable { p += 4; return ret; } - std::map<FX_DWORD, FX_DWORD> m_featureMap; + std::map<uint32_t, uint32_t> m_featureMap; FX_BOOL m_bFeautureMapLoad; bool loaded; struct tt_gsub_header header; @@ -355,7 +355,7 @@ class CFX_CTTGSUBTable { class CFX_GSUBTable final : public IFX_GSUBTable { public: ~CFX_GSUBTable() override {} - FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) override; + FX_BOOL GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum) override; CFX_CTTGSUBTable m_GsubImp; }; |