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]; | 9 extern const FX_DWORD gs_FX_TextLayout_CodeProperties[65536]; |
10 extern const FX_WCHAR gs_FX_TextLayout_VerticalMirror[64]; | 10 extern const FX_WCHAR gs_FX_TextLayout_VerticalMirror[64]; |
11 extern const FX_WCHAR gs_FX_TextLayout_BidiMirror[512]; | 11 extern const FX_WCHAR gs_FX_TextLayout_BidiMirror[512]; |
12 FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch) | 12 FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch) |
13 { | 13 { |
14 return gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 14 return gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; |
15 } | 15 } |
16 bool FX_IsCtrlCode(FX_WCHAR ch) | 16 FX_BOOL FX_IsCtrlCode(FX_WCHAR ch) |
17 { | 17 { |
18 FX_DWORD dwRet = (gs_FX_TextLayout_CodeProperties[(FX_WORD)ch] & FX_CHARTYPE
BITSMASK); | 18 FX_DWORD dwRet = (gs_FX_TextLayout_CodeProperties[(FX_WORD)ch] & FX_CHARTYPE
BITSMASK); |
19 return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control; | 19 return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control; |
20 } | 20 } |
21 bool FX_IsRotationCode(FX_WCHAR ch) | 21 FX_BOOL FX_IsRotationCode(FX_WCHAR ch) |
22 { | 22 { |
23 return (gs_FX_TextLayout_CodeProperties[(FX_WORD)ch] & 0x8000) != 0; | 23 return (gs_FX_TextLayout_CodeProperties[(FX_WORD)ch] & 0x8000) != 0; |
24 } | 24 } |
25 bool FX_IsCombinationChar(FX_WCHAR wch) | 25 FX_BOOL FX_IsCombinationChar(FX_WCHAR wch) |
26 { | 26 { |
27 FX_DWORD dwProps = (gs_FX_TextLayout_CodeProperties[(FX_WORD)wch] & FX_CHART
YPEBITSMASK); | 27 FX_DWORD dwProps = (gs_FX_TextLayout_CodeProperties[(FX_WORD)wch] & FX_CHART
YPEBITSMASK); |
28 return dwProps == FX_CHARTYPE_Combination; | 28 return dwProps == FX_CHARTYPE_Combination; |
29 } | 29 } |
30 bool» FX_IsBidiChar(FX_WCHAR wch) | 30 FX_BOOL»FX_IsBidiChar(FX_WCHAR wch) |
31 { | 31 { |
32 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 32 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; |
33 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; | 33 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; |
34 return (FX_BIDICLASS_R == iBidiCls || FX_BIDICLASS_AL == iBidiCls); | 34 return (FX_BIDICLASS_R == iBidiCls || FX_BIDICLASS_AL == iBidiCls); |
35 } | 35 } |
36 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, bool bRTL, bool bVertical) | 36 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical) |
37 { | 37 { |
38 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 38 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; |
39 FX_DWORD dwTemp = (dwProps & 0xFF800000); | 39 FX_DWORD dwTemp = (dwProps & 0xFF800000); |
40 if (bRTL && dwTemp < 0xFF800000) { | 40 if (bRTL && dwTemp < 0xFF800000) { |
41 wch = gs_FX_TextLayout_BidiMirror[dwTemp >> 23]; | 41 wch = gs_FX_TextLayout_BidiMirror[dwTemp >> 23]; |
42 dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 42 dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; |
43 } | 43 } |
44 if (bVertical) { | 44 if (bVertical) { |
45 dwTemp = (dwProps & 0x007E0000); | 45 dwTemp = (dwProps & 0x007E0000); |
46 if (dwTemp < 0x007E0000) { | 46 if (dwTemp < 0x007E0000) { |
47 wch = gs_FX_TextLayout_VerticalMirror[dwTemp >> 17]; | 47 wch = gs_FX_TextLayout_VerticalMirror[dwTemp >> 17]; |
48 } | 48 } |
49 } | 49 } |
50 return wch; | 50 return wch; |
51 } | 51 } |
52 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_DWORD dwProps, bool bRTL, bool bVerti
cal) | 52 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_DWORD dwProps, FX_BOOL bRTL, FX_BOOL
bVertical) |
53 { | 53 { |
54 FX_DWORD dwTemp = (dwProps & 0xFF800000); | 54 FX_DWORD dwTemp = (dwProps & 0xFF800000); |
55 if (bRTL && dwTemp < 0xFF800000) { | 55 if (bRTL && dwTemp < 0xFF800000) { |
56 wch = gs_FX_TextLayout_BidiMirror[dwTemp >> 23]; | 56 wch = gs_FX_TextLayout_BidiMirror[dwTemp >> 23]; |
57 dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 57 dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; |
58 } | 58 } |
59 if (bVertical) { | 59 if (bVertical) { |
60 dwTemp = (dwProps & 0x007E0000); | 60 dwTemp = (dwProps & 0x007E0000); |
61 if (dwTemp < 0x007E0000) { | 61 if (dwTemp < 0x007E0000) { |
62 wch = gs_FX_TextLayout_VerticalMirror[dwTemp >> 17]; | 62 wch = gs_FX_TextLayout_VerticalMirror[dwTemp >> 17]; |
63 } | 63 } |
64 } | 64 } |
65 return wch; | 65 return wch; |
66 } | 66 } |
OLD | NEW |