1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "core/fxcrt/fx_unicode.h" 8 9 #include "core/fxcrt/fx_ucddata.h" 10 11 namespace { 12 13 constexpr uint32_t kMirrorBits = 23; 14 constexpr uint32_t kMirrorMask = 0x1FFU << kMirrorBits; 15 GetMirrorChar(wchar_t wch,uint32_t dwProps)16wchar_t GetMirrorChar(wchar_t wch, uint32_t dwProps) { 17 uint32_t dwTemp = (dwProps & kMirrorMask); 18 if (dwTemp == kMirrorMask) 19 return wch; 20 size_t idx = dwTemp >> kMirrorBits; 21 return idx < kFXTextLayoutBidiMirrorSize ? kFXTextLayoutBidiMirror[idx] : wch; 22 } 23 24 } // namespace 25 FX_GetUnicodeProperties(wchar_t wch)26uint32_t FX_GetUnicodeProperties(wchar_t wch) { 27 size_t idx = static_cast<size_t>(wch); 28 if (idx < kTextLayoutCodePropertiesSize) 29 return kTextLayoutCodeProperties[idx]; 30 return 0; 31 } 32 FX_GetMirrorChar(wchar_t wch)33wchar_t FX_GetMirrorChar(wchar_t wch) { 34 return GetMirrorChar(wch, FX_GetUnicodeProperties(wch)); 35 } 36 37 #ifdef PDF_ENABLE_XFA FX_GetMirrorChar(wchar_t wch,uint32_t dwProps)38wchar_t FX_GetMirrorChar(wchar_t wch, uint32_t dwProps) { 39 return GetMirrorChar(wch, dwProps); 40 } 41 #endif // PDF_ENABLE_XFA 42