diff options
-rw-r--r-- | core/fpdfapi/font/cpdf_cidfont.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_font.cpp | 17 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_font.h | 11 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_simplefont.cpp | 24 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_truetypefont.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_type1font.cpp | 8 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_document.cpp | 14 | ||||
-rw-r--r-- | core/fxge/fx_font.h | 19 |
8 files changed, 44 insertions, 57 deletions
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index a9ffbbdf71..6d01538f54 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp @@ -608,7 +608,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) { #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ return cid; #else - if (m_Flags & PDFFONT_SYMBOLIC) + if (m_Flags & FXFONT_SYMBOLIC) return cid; CFX_WideString uni_str = UnicodeFromCharCode(charcode); diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp index 5563202455..36d7d6aeeb 100644 --- a/core/fpdfapi/font/cpdf_font.cpp +++ b/core/fpdfapi/font/cpdf_font.cpp @@ -161,7 +161,7 @@ uint32_t CPDF_Font::CharCodeFromUnicode(FX_WCHAR unicode) const { } void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { - m_Flags = pFontDesc->GetIntegerFor("Flags", PDFFONT_NONSYMBOLIC); + m_Flags = pFontDesc->GetIntegerFor("Flags", FXFONT_NONSYMBOLIC); int ItalicAngle = 0; bool bExistItalicAngle = false; if (pFontDesc->KeyExist("ItalicAngle")) { @@ -169,7 +169,7 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { bExistItalicAngle = true; } if (ItalicAngle < 0) { - m_Flags |= PDFFONT_ITALIC; + m_Flags |= FXFONT_ITALIC; m_ItalicAngle = ItalicAngle; } bool bExistStemV = false; @@ -188,16 +188,14 @@ void CPDF_Font::LoadFontDescriptor(CPDF_Dictionary* pFontDesc) { bExistDescent = true; } bool bExistCapHeight = false; - if (pFontDesc->KeyExist("CapHeight")) { + if (pFontDesc->KeyExist("CapHeight")) bExistCapHeight = true; - } if (bExistItalicAngle && bExistAscent && bExistCapHeight && bExistDescent && bExistStemV) { - m_Flags |= PDFFONT_USEEXTERNATTR; + m_Flags |= FXFONT_USEEXTERNATTR; } - if (m_Descent > 10) { + if (m_Descent > 10) m_Descent = -m_Descent; - } CPDF_Array* pBBox = pFontDesc->GetArrayFor("FontBBox"); if (pBBox) { m_FontBBox.left = pBBox->GetIntegerAt(0); @@ -372,10 +370,9 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, iBaseEncoding == PDFFONT_ENCODING_ZAPFDINGBATS) { return; } - if ((m_Flags & PDFFONT_SYMBOLIC) && m_BaseFont == "Symbol") { - if (!bTrueType) { + if ((m_Flags & FXFONT_SYMBOLIC) && m_BaseFont == "Symbol") { + if (!bTrueType) iBaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; - } return; } CFX_ByteString bsEncoding = pEncoding->GetString(); diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h index 0a46f65fe0..6025a82d7a 100644 --- a/core/fpdfapi/font/cpdf_font.h +++ b/core/fpdfapi/font/cpdf_font.h @@ -14,17 +14,6 @@ #include "core/fxcrt/fx_system.h" #include "core/fxge/fx_font.h" -#define PDFFONT_FIXEDPITCH 1 -#define PDFFONT_SERIF 2 -#define PDFFONT_SYMBOLIC 4 -#define PDFFONT_SCRIPT 8 -#define PDFFONT_NONSYMBOLIC 32 -#define PDFFONT_ITALIC 64 -#define PDFFONT_ALLCAP 0x10000 -#define PDFFONT_SMALLCAP 0x20000 -#define PDFFONT_FORCEBOLD 0x40000 -#define PDFFONT_USEEXTERNATTR 0x80000 - class CFX_SubstFont; class CPDF_CIDFont; class CPDF_Dictionary; diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp index ed9860970e..c414270068 100644 --- a/core/fpdfapi/font/cpdf_simplefont.cpp +++ b/core/fpdfapi/font/cpdf_simplefont.cpp @@ -127,15 +127,13 @@ bool CPDF_SimpleFont::LoadCommon() { } } if (m_pFontFile) { - if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+') { + if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+') m_BaseFont = m_BaseFont.Mid(8); - } } else { LoadSubstFont(); } - if (!(m_Flags & PDFFONT_SYMBOLIC)) { + if (!(m_Flags & FXFONT_SYMBOLIC)) m_BaseEncoding = PDFFONT_ENCODING_STANDARD; - } CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding"); LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, !!m_pFontFile, m_Font.IsTTFont()); @@ -144,7 +142,7 @@ bool CPDF_SimpleFont::LoadCommon() { if (!m_Font.GetFace()) return true; - if (m_Flags & PDFFONT_ALLCAP) { + if (m_Flags & FXFONT_ALLCAP) { unsigned char kLowercases[][2] = {{'a', 'z'}, {0xe0, 0xf6}, {0xf8, 0xfd}}; for (size_t range = 0; range < FX_ArraySize(kLowercases); ++range) { const auto& lower = kLowercases[range]; @@ -166,21 +164,19 @@ bool CPDF_SimpleFont::LoadCommon() { } void CPDF_SimpleFont::LoadSubstFont() { - if (!m_bUseFontWidth && !(m_Flags & PDFFONT_FIXEDPITCH)) { + if (!m_bUseFontWidth && !(m_Flags & FXFONT_FIXED_PITCH)) { int width = 0, i; for (i = 0; i < 256; i++) { - if (m_CharWidth[i] == 0 || m_CharWidth[i] == 0xffff) { + if (m_CharWidth[i] == 0 || m_CharWidth[i] == 0xffff) continue; - } - if (width == 0) { + + if (width == 0) width = m_CharWidth[i]; - } else if (width != m_CharWidth[i]) { + else if (width != m_CharWidth[i]) break; - } - } - if (i == 256 && width) { - m_Flags |= PDFFONT_FIXEDPITCH; } + if (i == 256 && width) + m_Flags |= FXFONT_FIXED_PITCH; } pdfium::base::CheckedNumeric<int> safeStemV(m_StemV); if (m_StemV < 140) diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp index a395e47112..b8bee2968e 100644 --- a/core/fpdfapi/font/cpdf_truetypefont.cpp +++ b/core/fpdfapi/font/cpdf_truetypefont.cpp @@ -42,7 +42,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { if (m_pFontFile && m_Font.GetFace()->num_charmaps > 0 && (baseEncoding == PDFFONT_ENCODING_MACROMAN || baseEncoding == PDFFONT_ENCODING_WINANSI) && - (m_Flags & PDFFONT_SYMBOLIC)) { + (m_Flags & FXFONT_SYMBOLIC)) { bool bSupportWin = false; bool bSupportMac = false; for (int i = 0; i < FXFT_Get_Face_CharmapCount(m_Font.GetFace()); i++) { @@ -65,7 +65,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { if (((baseEncoding == PDFFONT_ENCODING_MACROMAN || baseEncoding == PDFFONT_ENCODING_WINANSI) && m_CharNames.empty()) || - (m_Flags & PDFFONT_NONSYMBOLIC)) { + (m_Flags & FXFONT_NONSYMBOLIC)) { if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) && (!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) { int nStartChar = m_pFontDict->GetIntegerFor("FirstChar"); @@ -86,7 +86,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { bool bMacRoman = false; bool bMSSymbol = false; if (!bMSUnicode) { - if (m_Flags & PDFFONT_NONSYMBOLIC) { + if (m_Flags & FXFONT_NONSYMBOLIC) { bMacRoman = FT_UseTTCharmap(m_Font.GetFace(), 1, 0); bMSSymbol = !bMacRoman && FT_UseTTCharmap(m_Font.GetFace(), 3, 0); } else { diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp index 9ef45100d4..1a37555a50 100644 --- a/core/fpdfapi/font/cpdf_type1font.cpp +++ b/core/fpdfapi/font/cpdf_type1font.cpp @@ -84,7 +84,7 @@ bool CPDF_Type1Font::Load() { if (pFontDesc && pFontDesc->KeyExist("Flags")) m_Flags = pFontDesc->GetIntegerFor("Flags"); else - m_Flags = m_Base14Font >= 12 ? PDFFONT_SYMBOLIC : PDFFONT_NONSYMBOLIC; + m_Flags = m_Base14Font >= 12 ? FXFONT_SYMBOLIC : FXFONT_NONSYMBOLIC; if (m_Base14Font < 4) { for (int i = 0; i < 256; i++) @@ -94,7 +94,7 @@ bool CPDF_Type1Font::Load() { m_BaseEncoding = PDFFONT_ENCODING_ADOBE_SYMBOL; else if (m_Base14Font == 13) m_BaseEncoding = PDFFONT_ENCODING_ZAPFDINGBATS; - else if (m_Flags & PDFFONT_NONSYMBOLIC) + else if (m_Flags & FXFONT_NONSYMBOLIC) m_BaseEncoding = PDFFONT_ENCODING_STANDARD; } return LoadCommon(); @@ -189,7 +189,7 @@ void CPDF_Type1Font::LoadGlyphMap() { FT_UseType1Charmap(m_Font.GetFace()); #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (bCoreText) { - if (m_Flags & PDFFONT_SYMBOLIC) { + if (m_Flags & FXFONT_SYMBOLIC) { for (int charcode = 0; charcode < 256; charcode++) { const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode); @@ -257,7 +257,7 @@ void CPDF_Type1Font::LoadGlyphMap() { return; } #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - if (m_Flags & PDFFONT_SYMBOLIC) { + if (m_Flags & FXFONT_SYMBOLIC) { for (int charcode = 0; charcode < 256; charcode++) { const FX_CHAR* name = GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode); diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp index e425cfc328..21eb61a991 100644 --- a/core/fpdfapi/parser/cpdf_document.cpp +++ b/core/fpdfapi/parser/cpdf_document.cpp @@ -279,19 +279,19 @@ int CalculateFlags(bool bold, bool symbolic) { int flags = 0; if (bold) - flags |= PDFFONT_FORCEBOLD; + flags |= FXFONT_BOLD; if (italic) - flags |= PDFFONT_ITALIC; + flags |= FXFONT_ITALIC; if (fixedPitch) - flags |= PDFFONT_FIXEDPITCH; + flags |= FXFONT_FIXED_PITCH; if (serif) - flags |= PDFFONT_SERIF; + flags |= FXFONT_SERIF; if (script) - flags |= PDFFONT_SCRIPT; + flags |= FXFONT_SCRIPT; if (symbolic) - flags |= PDFFONT_SYMBOLIC; + flags |= FXFONT_SYMBOLIC; else - flags |= PDFFONT_NONSYMBOLIC; + flags |= FXFONT_NONSYMBOLIC; return flags; } diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h index 3c095d1976..07392fa07f 100644 --- a/core/fxge/fx_font.h +++ b/core/fxge/fx_font.h @@ -58,13 +58,18 @@ using CFX_TypeFace = SkTypeface; #define FXFONT_FW_NORMAL 400 #define FXFONT_FW_BOLD 700 -/* Font styles */ -#define FXFONT_FIXED_PITCH 0x01 -#define FXFONT_SERIF 0x02 -#define FXFONT_SYMBOLIC 0x04 -#define FXFONT_SCRIPT 0x08 -#define FXFONT_ITALIC 0x40 -#define FXFONT_BOLD 0x40000 +/* Font styles as defined in PDF 1.7 Table 5.20 */ +#define FXFONT_FIXED_PITCH (1 << 0) +#define FXFONT_SERIF (1 << 1) +#define FXFONT_SYMBOLIC (1 << 2) +#define FXFONT_SCRIPT (1 << 3) +#define FXFONT_NONSYMBOLIC (1 << 5) +#define FXFONT_ITALIC (1 << 6) +#define FXFONT_ALLCAP (1 << 16) +#define FXFONT_SMALLCAP (1 << 17) +#define FXFONT_BOLD (1 << 18) + +/* Other font flags */ #define FXFONT_USEEXTERNATTR 0x80000 #define FXFONT_CIDFONT 0x100000 #ifdef PDF_ENABLE_XFA |