Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: core/src/fxcrt/fx_unicode.cpp

Issue 1197643002: Cleanup IFX_BidiChar (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: add tests, similarity 20 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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]; 9 extern const FX_WCHAR gs_FX_TextLayout_VerticalMirror[64];
11 extern const FX_WCHAR gs_FX_TextLayout_BidiMirror[512]; 10 extern const FX_WCHAR gs_FX_TextLayout_BidiMirror[512];
11
12 FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch) { 12 FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch) {
13 return gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; 13 return kTextLayout_CodeProperties[(FX_WORD)wch];
14 } 14 }
15 FX_BOOL FX_IsCtrlCode(FX_WCHAR ch) { 15 FX_BOOL FX_IsCtrlCode(FX_WCHAR ch) {
16 FX_DWORD dwRet = 16 FX_DWORD dwRet = (FX_GetUnicodeProperties(ch) & FX_CHARTYPEBITSMASK);
17 (gs_FX_TextLayout_CodeProperties[(FX_WORD)ch] & FX_CHARTYPEBITSMASK);
18 return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control; 17 return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control;
19 } 18 }
20 FX_BOOL FX_IsRotationCode(FX_WCHAR ch) { 19 FX_BOOL FX_IsRotationCode(FX_WCHAR ch) {
21 return (gs_FX_TextLayout_CodeProperties[(FX_WORD)ch] & 0x8000) != 0; 20 return (FX_GetUnicodeProperties(ch) & 0x8000) != 0;
22 } 21 }
23 FX_BOOL FX_IsCombinationChar(FX_WCHAR wch) { 22 FX_BOOL FX_IsCombinationChar(FX_WCHAR wch) {
24 FX_DWORD dwProps = 23 FX_DWORD dwProps = (FX_GetUnicodeProperties(wch) & FX_CHARTYPEBITSMASK);
25 (gs_FX_TextLayout_CodeProperties[(FX_WORD)wch] & FX_CHARTYPEBITSMASK);
26 return dwProps == FX_CHARTYPE_Combination; 24 return dwProps == FX_CHARTYPE_Combination;
27 } 25 }
28 FX_BOOL FX_IsBidiChar(FX_WCHAR wch) { 26 FX_BOOL FX_IsBidiChar(FX_WCHAR wch) {
29 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; 27 FX_DWORD dwProps = FX_GetUnicodeProperties(wch);
30 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; 28 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS;
31 return (FX_BIDICLASS_R == iBidiCls || FX_BIDICLASS_AL == iBidiCls); 29 return (FX_BIDICLASS_R == iBidiCls || FX_BIDICLASS_AL == iBidiCls);
32 } 30 }
33 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical) { 31 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical) {
34 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; 32 FX_DWORD dwProps = FX_GetUnicodeProperties(wch);
35 FX_DWORD dwTemp = (dwProps & 0xFF800000); 33 FX_DWORD dwTemp = (dwProps & 0xFF800000);
36 if (bRTL && dwTemp < 0xFF800000) { 34 if (bRTL && dwTemp < 0xFF800000) {
37 wch = gs_FX_TextLayout_BidiMirror[dwTemp >> 23]; 35 wch = gs_FX_TextLayout_BidiMirror[dwTemp >> 23];
38 dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; 36 dwProps = FX_GetUnicodeProperties(wch);
39 } 37 }
40 if (bVertical) { 38 if (bVertical) {
41 dwTemp = (dwProps & 0x007E0000); 39 dwTemp = (dwProps & 0x007E0000);
42 if (dwTemp < 0x007E0000) { 40 if (dwTemp < 0x007E0000) {
43 wch = gs_FX_TextLayout_VerticalMirror[dwTemp >> 17]; 41 wch = gs_FX_TextLayout_VerticalMirror[dwTemp >> 17];
44 } 42 }
45 } 43 }
46 return wch; 44 return wch;
47 } 45 }
48 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, 46 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch,
49 FX_DWORD dwProps, 47 FX_DWORD dwProps,
50 FX_BOOL bRTL, 48 FX_BOOL bRTL,
51 FX_BOOL bVertical) { 49 FX_BOOL bVertical) {
52 FX_DWORD dwTemp = (dwProps & 0xFF800000); 50 FX_DWORD dwTemp = (dwProps & 0xFF800000);
53 if (bRTL && dwTemp < 0xFF800000) { 51 if (bRTL && dwTemp < 0xFF800000) {
54 wch = gs_FX_TextLayout_BidiMirror[dwTemp >> 23]; 52 wch = gs_FX_TextLayout_BidiMirror[dwTemp >> 23];
55 dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; 53 dwProps = FX_GetUnicodeProperties(wch);
56 } 54 }
57 if (bVertical) { 55 if (bVertical) {
58 dwTemp = (dwProps & 0x007E0000); 56 dwTemp = (dwProps & 0x007E0000);
59 if (dwTemp < 0x007E0000) { 57 if (dwTemp < 0x007E0000) {
60 wch = gs_FX_TextLayout_VerticalMirror[dwTemp >> 17]; 58 wch = gs_FX_TextLayout_VerticalMirror[dwTemp >> 17];
61 } 59 }
62 } 60 }
63 return wch; 61 return wch;
64 } 62 }
OLDNEW
« core/src/fxcrt/fx_ucddata.cpp ('K') | « core/src/fxcrt/fx_ucddata.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698