summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-19 11:46:02 -0700
committerLei Zhang <thestig@chromium.org>2015-10-19 11:46:02 -0700
commit894d1cd3f56b1c8c33c5a60ebfec14384e5002d0 (patch)
tree3a16b4da04006214ab030a205a65b60889848e96 /core/src
parentdb1eaae6aad2ab0ca775919bc53ee7f5e3fc67fb (diff)
downloadpdfium-894d1cd3f56b1c8c33c5a60ebfec14384e5002d0.tar.xz
Unrevert commit a398ca6 and apply the proper fix.
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1401493002 .
Diffstat (limited to 'core/src')
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp23
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 392b918b40..0f7d128786 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() {
@@ -1742,18 +1747,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;
}