summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-08-13 19:28:39 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-13 19:28:39 +0000
commit1a99f200c59a89fe297ac79658d2fe11b13b1553 (patch)
tree12202f250b102a1a7a7d3fb1bea087f91df67439 /core
parentb850c987d141c5578535faba64d14782dbfc13da (diff)
downloadpdfium-1a99f200c59a89fe297ac79658d2fe11b13b1553.tar.xz
Mark CPDF_Font::GlyphFromCharCodeExt() and friends Mac only.
Change-Id: I4906351a6e21fb8480670a6daf15bd7cb9e441c5 Reviewed-on: https://pdfium-review.googlesource.com/39911 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp2
-rw-r--r--core/fpdfapi/font/cpdf_font.h2
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.cpp1
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.h1
-rw-r--r--core/fpdfapi/font/cpdf_type1font.cpp19
-rw-r--r--core/fpdfapi/font/cpdf_type1font.h4
6 files changed, 19 insertions, 10 deletions
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index f75f696035..f2aa4da052 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -112,9 +112,11 @@ size_t CPDF_Font::CountChar(const ByteStringView& pString) const {
return pString.GetLength();
}
+#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
int CPDF_Font::GlyphFromCharCodeExt(uint32_t charcode) {
return GlyphFromCharCode(charcode, nullptr);
}
+#endif
bool CPDF_Font::IsVertWriting() const {
const CPDF_CIDFont* pCIDFont = AsCIDFont();
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index f5d0bacfba..53e5b7b697 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -58,7 +58,9 @@ class CPDF_Font {
virtual size_t CountChar(const ByteStringView& pString) const;
virtual int AppendChar(char* buf, uint32_t charcode) const;
virtual int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) = 0;
+#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
virtual int GlyphFromCharCodeExt(uint32_t charcode);
+#endif
virtual WideString UnicodeFromCharCode(uint32_t charcode) const;
virtual uint32_t CharCodeFromUnicode(wchar_t Unicode) const;
virtual bool HasFontWidths() const;
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index f1bbf69b4f..dd1a1f33f3 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -32,7 +32,6 @@ CPDF_SimpleFont::CPDF_SimpleFont(CPDF_Document* pDocument,
: CPDF_Font(pDocument, pFontDict) {
memset(m_CharWidth, 0xff, sizeof(m_CharWidth));
memset(m_GlyphIndex, 0xff, sizeof(m_GlyphIndex));
- memset(m_ExtGID, 0xff, sizeof(m_ExtGID));
for (size_t i = 0; i < FX_ArraySize(m_CharBBox); ++i)
m_CharBBox[i] = FX_RECT(-1, -1, -1, -1);
}
diff --git a/core/fpdfapi/font/cpdf_simplefont.h b/core/fpdfapi/font/cpdf_simplefont.h
index 4c813a280e..290016bc49 100644
--- a/core/fpdfapi/font/cpdf_simplefont.h
+++ b/core/fpdfapi/font/cpdf_simplefont.h
@@ -44,7 +44,6 @@ class CPDF_SimpleFont : public CPDF_Font {
bool m_bUseFontWidth;
std::vector<ByteString> m_CharNames;
uint16_t m_GlyphIndex[256];
- uint16_t m_ExtGID[256];
uint16_t m_CharWidth[256];
FX_RECT m_CharBBox[256];
};
diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp
index 8d0eafcc97..9e2f4eff58 100644
--- a/core/fpdfapi/font/cpdf_type1font.cpp
+++ b/core/fpdfapi/font/cpdf_type1font.cpp
@@ -62,7 +62,11 @@ bool FT_UseType1Charmap(FXFT_Face face) {
CPDF_Type1Font::CPDF_Type1Font(CPDF_Document* pDocument,
CPDF_Dictionary* pFontDict)
- : CPDF_SimpleFont(pDocument, pFontDict) {}
+ : CPDF_SimpleFont(pDocument, pFontDict) {
+#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
+ memset(m_ExtGID, 0xff, sizeof(m_ExtGID));
+#endif
+}
CPDF_Type1Font::~CPDF_Type1Font() = default;
@@ -102,16 +106,15 @@ bool CPDF_Type1Font::Load() {
return LoadCommon();
}
+#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
int CPDF_Type1Font::GlyphFromCharCodeExt(uint32_t charcode) {
- if (charcode > 0xff) {
+ if (charcode > 0xff)
return -1;
- }
- int index = m_ExtGID[(uint8_t)charcode];
- if (index == 0xffff) {
- return -1;
- }
- return index;
+
+ int index = m_ExtGID[static_cast<uint8_t>(charcode)];
+ return index != 0xffff ? index : -1;
}
+#endif
void CPDF_Type1Font::LoadGlyphMap() {
if (!m_Font.GetFace())
diff --git a/core/fpdfapi/font/cpdf_type1font.h b/core/fpdfapi/font/cpdf_type1font.h
index 688346175b..eaabaaeb88 100644
--- a/core/fpdfapi/font/cpdf_type1font.h
+++ b/core/fpdfapi/font/cpdf_type1font.h
@@ -19,7 +19,9 @@ class CPDF_Type1Font : public CPDF_SimpleFont {
bool IsType1Font() const override;
const CPDF_Type1Font* AsType1Font() const override;
CPDF_Type1Font* AsType1Font() override;
+#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
int GlyphFromCharCodeExt(uint32_t charcode) override;
+#endif
int GetBase14Font() const { return m_Base14Font; }
@@ -33,6 +35,8 @@ class CPDF_Type1Font : public CPDF_SimpleFont {
#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
void SetExtGID(const char* name, int charcode);
void CalcExtGID(int charcode);
+
+ uint16_t m_ExtGID[256];
#endif
int m_Base14Font = -1;