summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-08-17 12:20:05 -0700
committerLei Zhang <thestig@chromium.org>2015-08-17 12:20:05 -0700
commit9494421208674d2c57a9f864d342f017c0b20902 (patch)
tree7441d485f36011a697aa31fb78d706fb8ca211cd /core
parented7599b9042169f11b00f1126bfd3aff0f56b35f (diff)
downloadpdfium-9494421208674d2c57a9f864d342f017c0b20902.tar.xz
Fix more sign comparison errors.
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1290383003 .
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfapi/fpdf_resource.h2
-rw-r--r--core/src/fpdfdoc/doc_ap.cpp37
2 files changed, 22 insertions, 17 deletions
diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h
index 5b6f3498fe..d687c97b9c 100644
--- a/core/include/fpdfapi/fpdf_resource.h
+++ b/core/include/fpdfapi/fpdf_resource.h
@@ -21,7 +21,6 @@ class CPDF_CMap;
class CPDF_Color;
class CPDF_ColorSpace;
class CPDF_Face;
-class CPDF_Font;
class CPDF_FontEncoding;
class CPDF_Form;
class CPDF_Function;
@@ -101,6 +100,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);
virtual ~CPDF_Font();
diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp
index cffaad9900..f9bb3a7641 100644
--- a/core/src/fpdfdoc/doc_ap.cpp
+++ b/core/src/fpdfdoc/doc_ap.cpp
@@ -133,7 +133,7 @@ int32_t CPVT_Provider::GetCharWidth(int32_t nFontIndex,
int32_t nWordStyle) {
if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) {
FX_DWORD charcode = pPDFFont->CharCodeFromUnicode(word);
- if (charcode != -1) {
+ if (charcode != CPDF_Font::kInvalidCharCode) {
return pPDFFont->GetCharWidthF(charcode);
}
}
@@ -155,14 +155,15 @@ int32_t CPVT_Provider::GetWordFontIndex(FX_WORD word,
int32_t charset,
int32_t nFontIndex) {
if (CPDF_Font* pDefFont = m_pFontMap->GetPDFFont(0)) {
- if (pDefFont->CharCodeFromUnicode(word) != -1) {
+ if (pDefFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) {
return 0;
}
}
- if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1))
- if (pSysFont->CharCodeFromUnicode(word) != -1) {
+ if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) {
+ if (pSysFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) {
return 1;
}
+ }
return -1;
}
FX_BOOL CPVT_Provider::IsLatinWord(FX_WORD word) {
@@ -175,6 +176,7 @@ FX_BOOL CPVT_Provider::IsLatinWord(FX_WORD word) {
int32_t CPVT_Provider::GetDefaultFontIndex() {
return 0;
}
+
static CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap,
int32_t nFontIndex,
FX_WORD Word,
@@ -182,23 +184,26 @@ static CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap,
CFX_ByteString sWord;
if (SubWord > 0) {
sWord.Format("%c", SubWord);
- } else {
- if (pFontMap) {
- if (CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex)) {
- if (pPDFFont->GetBaseFont().Compare("Symbol") == 0 ||
- pPDFFont->GetBaseFont().Compare("ZapfDingbats") == 0) {
- sWord.Format("%c", Word);
- } else {
- FX_DWORD dwCharCode = pPDFFont->CharCodeFromUnicode(Word);
- if (dwCharCode != -1) {
- pPDFFont->AppendChar(sWord, dwCharCode);
- }
- }
+ return sWord;
+ }
+
+ if (!pFontMap)
+ return sWord;
+
+ if (CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex)) {
+ if (pPDFFont->GetBaseFont().Compare("Symbol") == 0 ||
+ pPDFFont->GetBaseFont().Compare("ZapfDingbats") == 0) {
+ sWord.Format("%c", Word);
+ } else {
+ FX_DWORD dwCharCode = pPDFFont->CharCodeFromUnicode(Word);
+ if (dwCharCode != CPDF_Font::kInvalidCharCode) {
+ pPDFFont->AppendChar(sWord, dwCharCode);
}
}
}
return sWord;
}
+
static CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) {
if (strWords.GetLength() > 0) {
return PDF_EncodeString(strWords) + " Tj\n";