| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../include/fxcrt/fx_ucd.h" | 7 #include "../../include/fxcrt/fx_ucd.h" |
| 8 | 8 |
| 9 extern const FX_DWORD gs_FX_TextLayout_CodeProperties[65536]; | |
| 10 extern const FX_WCHAR gs_FX_TextLayout_VerticalMirror[64]; | |
| 11 extern const FX_WCHAR gs_FX_TextLayout_BidiMirror[512]; | |
| 12 FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch) { | 9 FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch) { |
| 13 return gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 10 return kTextLayoutCodeProperties[(FX_WORD)wch]; |
| 14 } | 11 } |
| 15 FX_BOOL FX_IsCtrlCode(FX_WCHAR ch) { | 12 FX_BOOL FX_IsCtrlCode(FX_WCHAR ch) { |
| 16 FX_DWORD dwRet = | 13 FX_DWORD dwRet = |
| 17 (gs_FX_TextLayout_CodeProperties[(FX_WORD)ch] & FX_CHARTYPEBITSMASK); | 14 (kTextLayoutCodeProperties[(FX_WORD)ch] & FX_CHARTYPEBITSMASK); |
| 18 return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control; | 15 return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control; |
| 19 } | 16 } |
| 20 FX_BOOL FX_IsRotationCode(FX_WCHAR ch) { | 17 FX_BOOL FX_IsRotationCode(FX_WCHAR ch) { |
| 21 return (gs_FX_TextLayout_CodeProperties[(FX_WORD)ch] & 0x8000) != 0; | 18 return (kTextLayoutCodeProperties[(FX_WORD)ch] & 0x8000) != 0; |
| 22 } | 19 } |
| 23 FX_BOOL FX_IsCombinationChar(FX_WCHAR wch) { | 20 FX_BOOL FX_IsCombinationChar(FX_WCHAR wch) { |
| 24 FX_DWORD dwProps = | 21 FX_DWORD dwProps = |
| 25 (gs_FX_TextLayout_CodeProperties[(FX_WORD)wch] & FX_CHARTYPEBITSMASK); | 22 (kTextLayoutCodeProperties[(FX_WORD)wch] & FX_CHARTYPEBITSMASK); |
| 26 return dwProps == FX_CHARTYPE_Combination; | 23 return dwProps == FX_CHARTYPE_Combination; |
| 27 } | 24 } |
| 28 FX_BOOL FX_IsBidiChar(FX_WCHAR wch) { | 25 FX_BOOL FX_IsBidiChar(FX_WCHAR wch) { |
| 29 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 26 FX_DWORD dwProps = kTextLayoutCodeProperties[(FX_WORD)wch]; |
| 30 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; | 27 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; |
| 31 return (FX_BIDICLASS_R == iBidiCls || FX_BIDICLASS_AL == iBidiCls); | 28 return (FX_BIDICLASS_R == iBidiCls || FX_BIDICLASS_AL == iBidiCls); |
| 32 } | 29 } |
| 33 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical) { | 30 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical) { |
| 34 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 31 FX_DWORD dwProps = kTextLayoutCodeProperties[(FX_WORD)wch]; |
| 35 FX_DWORD dwTemp = (dwProps & 0xFF800000); | 32 FX_DWORD dwTemp = (dwProps & 0xFF800000); |
| 36 if (bRTL && dwTemp < 0xFF800000) { | 33 if (bRTL && dwTemp < 0xFF800000) { |
| 37 wch = gs_FX_TextLayout_BidiMirror[dwTemp >> 23]; | 34 wch = kFXTextLayoutBidiMirror[dwTemp >> 23]; |
| 38 dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 35 dwProps = kTextLayoutCodeProperties[(FX_WORD)wch]; |
| 39 } | 36 } |
| 40 if (bVertical) { | 37 if (bVertical) { |
| 41 dwTemp = (dwProps & 0x007E0000); | 38 dwTemp = (dwProps & 0x007E0000); |
| 42 if (dwTemp < 0x007E0000) { | 39 if (dwTemp < 0x007E0000) { |
| 43 wch = gs_FX_TextLayout_VerticalMirror[dwTemp >> 17]; | 40 wch = kFXTextLayoutVerticalMirror[dwTemp >> 17]; |
| 44 } | 41 } |
| 45 } | 42 } |
| 46 return wch; | 43 return wch; |
| 47 } | 44 } |
| 48 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, | 45 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, |
| 49 FX_DWORD dwProps, | 46 FX_DWORD dwProps, |
| 50 FX_BOOL bRTL, | 47 FX_BOOL bRTL, |
| 51 FX_BOOL bVertical) { | 48 FX_BOOL bVertical) { |
| 52 FX_DWORD dwTemp = (dwProps & 0xFF800000); | 49 FX_DWORD dwTemp = (dwProps & 0xFF800000); |
| 53 if (bRTL && dwTemp < 0xFF800000) { | 50 if (bRTL && dwTemp < 0xFF800000) { |
| 54 wch = gs_FX_TextLayout_BidiMirror[dwTemp >> 23]; | 51 wch = kFXTextLayoutBidiMirror[dwTemp >> 23]; |
| 55 dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 52 dwProps = kTextLayoutCodeProperties[(FX_WORD)wch]; |
| 56 } | 53 } |
| 57 if (bVertical) { | 54 if (bVertical) { |
| 58 dwTemp = (dwProps & 0x007E0000); | 55 dwTemp = (dwProps & 0x007E0000); |
| 59 if (dwTemp < 0x007E0000) { | 56 if (dwTemp < 0x007E0000) { |
| 60 wch = gs_FX_TextLayout_VerticalMirror[dwTemp >> 17]; | 57 wch = kFXTextLayoutVerticalMirror[dwTemp >> 17]; |
| 61 } | 58 } |
| 62 } | 59 } |
| 63 return wch; | 60 return wch; |
| 64 } | 61 } |
| OLD | NEW |