summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_unicode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/fx_unicode.cpp')
-rw-r--r--core/fxcrt/fx_unicode.cpp59
1 files changed, 19 insertions, 40 deletions
diff --git a/core/fxcrt/fx_unicode.cpp b/core/fxcrt/fx_unicode.cpp
index fce826dac8..595bb65a63 100644
--- a/core/fxcrt/fx_unicode.cpp
+++ b/core/fxcrt/fx_unicode.cpp
@@ -6,6 +6,21 @@
#include "core/fxcrt/fx_ucd.h"
+namespace {
+
+constexpr uint32_t kMirrorBits = 23;
+constexpr uint32_t kMirrorMask = 0x1FFU << kMirrorBits;
+
+wchar_t GetMirrorChar(wchar_t wch, uint32_t dwProps) {
+ uint32_t dwTemp = (dwProps & kMirrorMask);
+ if (dwTemp == kMirrorMask)
+ return wch;
+ size_t idx = dwTemp >> kMirrorBits;
+ return idx < kFXTextLayoutBidiMirrorSize ? kFXTextLayoutBidiMirror[idx] : wch;
+}
+
+} // namespace
+
uint32_t FX_GetUnicodeProperties(wchar_t wch) {
size_t idx = static_cast<size_t>(wch);
if (idx < kTextLayoutCodePropertiesSize)
@@ -13,48 +28,12 @@ uint32_t FX_GetUnicodeProperties(wchar_t wch) {
return 0;
}
-wchar_t FX_GetMirrorChar(wchar_t wch, bool bRTL, bool bVertical) {
- uint32_t dwProps = FX_GetUnicodeProperties(wch);
- uint32_t dwTemp = (dwProps & 0xFF800000);
- if (bRTL && dwTemp < 0xFF800000) {
- size_t idx = dwTemp >> 23;
- if (idx < kFXTextLayoutBidiMirrorSize) {
- wch = kFXTextLayoutBidiMirror[idx];
- dwProps = FX_GetUnicodeProperties(wch);
- }
- }
- if (bVertical) {
- dwTemp = (dwProps & 0x007E0000);
- if (dwTemp < 0x007E0000) {
- size_t idx = dwTemp >> 17;
- if (idx < kFXTextLayoutVerticalMirrorSize)
- wch = kFXTextLayoutVerticalMirror[idx];
- }
- }
- return wch;
+wchar_t FX_GetMirrorChar(wchar_t wch) {
+ return GetMirrorChar(wch, FX_GetUnicodeProperties(wch));
}
#ifdef PDF_ENABLE_XFA
-wchar_t FX_GetMirrorChar(wchar_t wch,
- uint32_t dwProps,
- bool bRTL,
- bool bVertical) {
- uint32_t dwTemp = (dwProps & 0xFF800000);
- if (bRTL && dwTemp < 0xFF800000) {
- size_t idx = dwTemp >> 23;
- if (idx < kFXTextLayoutBidiMirrorSize) {
- wch = kFXTextLayoutBidiMirror[idx];
- dwProps = FX_GetUnicodeProperties(wch);
- }
- }
- if (bVertical) {
- dwTemp = (dwProps & 0x007E0000);
- if (dwTemp < 0x007E0000) {
- size_t idx = dwTemp >> 17;
- if (idx < kFXTextLayoutVerticalMirrorSize)
- wch = kFXTextLayoutVerticalMirror[idx];
- }
- }
- return wch;
+wchar_t FX_GetMirrorChar(wchar_t wch, uint32_t dwProps) {
+ return GetMirrorChar(wch, dwProps);
}
#endif // PDF_ENABLE_XFA