diff options
author | Lei Zhang <thestig@chromium.org> | 2015-10-19 12:07:32 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-10-19 12:07:32 -0700 |
commit | 184e4a189d1391bff014aa6ecc0f9b0d83081826 (patch) | |
tree | f7b84103102121d9e044558c92f9c248499e02fd /core/src/fpdfapi | |
parent | aa8ea6dbb4fc81c03fffe6a531106f64508c296d (diff) | |
download | pdfium-184e4a189d1391bff014aa6ecc0f9b0d83081826.tar.xz |
Merge to XFA: Unrevert commit a398ca6 and apply the proper fix.
TBR=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1401493002 .
(cherry picked from commit 894d1cd3f56b1c8c33c5a60ebfec14384e5002d0)
Review URL: https://codereview.chromium.org/1413213002 .
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r-- | core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp index b87ad18c02..5095f1a74c 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -588,6 +588,11 @@ const struct CIDTransform { {8819, 0, 129, 127, 0, 218, 108}, }; +int CompareCIDTransform(const void* key, const void* element) { + FX_WORD CID = *static_cast<const FX_WORD*>(key); + return CID - static_cast<const struct CIDTransform*>(element)->CID; +} + } // namespace CPDF_CMapManager::CPDF_CMapManager() { @@ -1745,18 +1750,8 @@ const uint8_t* CPDF_CIDFont::GetCIDTransform(FX_WORD CID) const { if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) return nullptr; - int begin = 0; - int end = FX_ArraySize(g_Japan1_VertCIDs) - 1; - while (begin <= end) { - int middle = (begin + end) / 2; - FX_WORD middlecode = g_Japan1_VertCIDs[middle].CID; - if (middlecode > CID) { - end = middle - 1; - } else if (middlecode < CID) { - begin = middle + 1; - } else { - return &g_Japan1_VertCIDs[middle].a; - } - } - return nullptr; + const struct CIDTransform* found = (const struct CIDTransform*)FXSYS_bsearch( + &CID, g_Japan1_VertCIDs, FX_ArraySize(g_Japan1_VertCIDs), + sizeof(g_Japan1_VertCIDs[0]), CompareCIDTransform); + return found ? &found->a : nullptr; } |