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 #include "fx_arabic.h" | 8 #include "fx_arabic.h" |
9 | 9 |
10 extern const FX_DWORD gs_FX_TextLayout_CodeProperties[65536]; | |
11 #ifdef __cplusplus | 10 #ifdef __cplusplus |
12 extern "C" { | 11 extern "C" { |
13 #endif | 12 #endif |
14 static const FX_ARBFORMTABLE g_FX_ArabicFormTables[] = { | 13 static const FX_ARBFORMTABLE g_FX_ArabicFormTables[] = { |
15 {0xFE81, 0xFE82, 0xFE81, 0xFE82}, {0xFE83, 0xFE84, 0xFE83, 0xFE84}, | 14 {0xFE81, 0xFE82, 0xFE81, 0xFE82}, {0xFE83, 0xFE84, 0xFE83, 0xFE84}, |
16 {0xFE85, 0xFE86, 0xFE85, 0xFE86}, {0xFE87, 0xFE88, 0xFE87, 0xFE88}, | 15 {0xFE85, 0xFE86, 0xFE85, 0xFE86}, {0xFE87, 0xFE88, 0xFE87, 0xFE88}, |
17 {0xFE89, 0xFE8A, 0xFE8B, 0xFE8C}, {0xFE8D, 0xFE8E, 0xFE8D, 0xFE8E}, | 16 {0xFE89, 0xFE8A, 0xFE8B, 0xFE8C}, {0xFE8D, 0xFE8E, 0xFE8D, 0xFE8E}, |
18 {0xFE8F, 0xFE90, 0xFE91, 0xFE92}, {0xFE93, 0xFE94, 0xFE93, 0xFE94}, | 17 {0xFE8F, 0xFE90, 0xFE91, 0xFE92}, {0xFE93, 0xFE94, 0xFE93, 0xFE94}, |
19 {0xFE95, 0xFE96, 0xFE97, 0xFE98}, {0xFE99, 0xFE9A, 0xFE9B, 0xFE9C}, | 18 {0xFE95, 0xFE96, 0xFE97, 0xFE98}, {0xFE99, 0xFE9A, 0xFE9B, 0xFE9C}, |
20 {0xFE9D, 0xFE9E, 0xFE9F, 0xFEA0}, {0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4}, | 19 {0xFE9D, 0xFE9E, 0xFE9F, 0xFEA0}, {0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4}, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 return shadda; | 141 return shadda; |
143 } | 142 } |
144 #ifdef __cplusplus | 143 #ifdef __cplusplus |
145 }; | 144 }; |
146 #endif | 145 #endif |
147 IFX_ArabicChar* IFX_ArabicChar::Create() { | 146 IFX_ArabicChar* IFX_ArabicChar::Create() { |
148 return new CFX_ArabicChar; | 147 return new CFX_ArabicChar; |
149 } | 148 } |
150 FX_BOOL CFX_ArabicChar::IsArabicChar(FX_WCHAR wch) const { | 149 FX_BOOL CFX_ArabicChar::IsArabicChar(FX_WCHAR wch) const { |
151 FX_DWORD dwRet = | 150 FX_DWORD dwRet = |
152 (gs_FX_TextLayout_CodeProperties[(FX_WORD)wch] & FX_CHARTYPEBITSMASK); | 151 kTextLayoutCodeProperties[(FX_WORD)wch] & FX_CHARTYPEBITSMASK; |
153 return dwRet >= FX_CHARTYPE_ArabicAlef; | 152 return dwRet >= FX_CHARTYPE_ArabicAlef; |
154 } | 153 } |
155 FX_BOOL CFX_ArabicChar::IsArabicFormChar(FX_WCHAR wch) const { | 154 FX_BOOL CFX_ArabicChar::IsArabicFormChar(FX_WCHAR wch) const { |
156 return (gs_FX_TextLayout_CodeProperties[(FX_WORD)wch] & | 155 return (kTextLayoutCodeProperties[(FX_WORD)wch] & FX_CHARTYPEBITSMASK) == |
157 FX_CHARTYPEBITSMASK) == FX_CHARTYPE_ArabicForm; | 156 FX_CHARTYPE_ArabicForm; |
158 } | 157 } |
159 FX_WCHAR CFX_ArabicChar::GetFormChar(FX_WCHAR wch, | 158 FX_WCHAR CFX_ArabicChar::GetFormChar(FX_WCHAR wch, |
160 FX_WCHAR prev, | 159 FX_WCHAR prev, |
161 FX_WCHAR next) const { | 160 FX_WCHAR next) const { |
162 CFX_Char c(wch, gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]); | 161 CFX_Char c(wch, kTextLayoutCodeProperties[(FX_WORD)wch]); |
163 CFX_Char p(prev, gs_FX_TextLayout_CodeProperties[(FX_WORD)prev]); | 162 CFX_Char p(prev, kTextLayoutCodeProperties[(FX_WORD)prev]); |
164 CFX_Char n(next, gs_FX_TextLayout_CodeProperties[(FX_WORD)next]); | 163 CFX_Char n(next, kTextLayoutCodeProperties[(FX_WORD)next]); |
165 return GetFormChar(&c, &p, &n); | 164 return GetFormChar(&c, &p, &n); |
166 } | 165 } |
167 FX_WCHAR CFX_ArabicChar::GetFormChar(const CFX_Char* cur, | 166 FX_WCHAR CFX_ArabicChar::GetFormChar(const CFX_Char* cur, |
168 const CFX_Char* prev, | 167 const CFX_Char* prev, |
169 const CFX_Char* next) const { | 168 const CFX_Char* next) const { |
170 FX_CHARTYPE eCur; | 169 FX_CHARTYPE eCur; |
171 FX_WCHAR wCur; | 170 FX_WCHAR wCur; |
172 FX_LPCARBFORMTABLE ft = ParseChar(cur, wCur, eCur); | 171 FX_LPCARBFORMTABLE ft = ParseChar(cur, wCur, eCur); |
173 if (eCur < FX_CHARTYPE_ArabicAlef || eCur >= FX_CHARTYPE_ArabicNormal) { | 172 if (eCur < FX_CHARTYPE_ArabicAlef || eCur >= FX_CHARTYPE_ArabicNormal) { |
174 return wCur; | 173 return wCur; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 CFX_Int32Array& classes, | 252 CFX_Int32Array& classes, |
254 FX_BOOL bWS) { | 253 FX_BOOL bWS) { |
255 FXSYS_assert(wsText.GetLength() == classes.GetSize()); | 254 FXSYS_assert(wsText.GetLength() == classes.GetSize()); |
256 int32_t iCount = wsText.GetLength(); | 255 int32_t iCount = wsText.GetLength(); |
257 const FX_WCHAR* pwsStart = (const FX_WCHAR*)wsText; | 256 const FX_WCHAR* pwsStart = (const FX_WCHAR*)wsText; |
258 FX_WCHAR wch; | 257 FX_WCHAR wch; |
259 int32_t iCls; | 258 int32_t iCls; |
260 if (bWS) { | 259 if (bWS) { |
261 for (int32_t i = 0; i < iCount; i++) { | 260 for (int32_t i = 0; i < iCount; i++) { |
262 wch = *pwsStart++; | 261 wch = *pwsStart++; |
263 iCls = ((gs_FX_TextLayout_CodeProperties[(FX_WORD)wch] & | 262 iCls = |
264 FX_BIDICLASSBITSMASK) >> | 263 ((kTextLayoutCodeProperties[(FX_WORD)wch] & FX_BIDICLASSBITSMASK) >> |
265 FX_BIDICLASSBITS); | 264 FX_BIDICLASSBITS); |
266 classes.SetAt(i, iCls); | 265 classes.SetAt(i, iCls); |
267 } | 266 } |
268 } else { | 267 } else { |
269 for (int32_t i = 0; i < iCount; i++) { | 268 for (int32_t i = 0; i < iCount; i++) { |
270 wch = *pwsStart++; | 269 wch = *pwsStart++; |
271 iCls = ((gs_FX_TextLayout_CodeProperties[(FX_WORD)wch] & | 270 iCls = |
272 FX_BIDICLASSBITSMASK) >> | 271 ((kTextLayoutCodeProperties[(FX_WORD)wch] & FX_BIDICLASSBITSMASK) >> |
273 FX_BIDICLASSBITS); | 272 FX_BIDICLASSBITS); |
274 classes.SetAt(i, gc_FX_BidiNTypes[iCls]); | 273 classes.SetAt(i, gc_FX_BidiNTypes[iCls]); |
275 } | 274 } |
276 } | 275 } |
277 } | 276 } |
278 int32_t FX_BidiResolveExplicit(int32_t iBaseLevel, | 277 int32_t FX_BidiResolveExplicit(int32_t iBaseLevel, |
279 int32_t iDirection, | 278 int32_t iDirection, |
280 CFX_Int32Array& classes, | 279 CFX_Int32Array& classes, |
281 CFX_Int32Array& levels, | 280 CFX_Int32Array& levels, |
282 int32_t iStart, | 281 int32_t iStart, |
283 int32_t iCount, | 282 int32_t iCount, |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 m_iCurCount(0), | 1062 m_iCurCount(0), |
1064 m_iCurBidi(0), | 1063 m_iCurBidi(0), |
1065 m_iLastBidi(0), | 1064 m_iLastBidi(0), |
1066 m_iLastStart(0), | 1065 m_iLastStart(0), |
1067 m_iLastCount(0) {} | 1066 m_iLastCount(0) {} |
1068 void CFX_BidiChar::SetPolicy(FX_BOOL bSeparateNeutral) { | 1067 void CFX_BidiChar::SetPolicy(FX_BOOL bSeparateNeutral) { |
1069 m_bSeparateNeutral = bSeparateNeutral; | 1068 m_bSeparateNeutral = bSeparateNeutral; |
1070 } | 1069 } |
1071 | 1070 |
1072 FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch) { | 1071 FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch) { |
1073 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; | 1072 FX_DWORD dwProps = kTextLayoutCodeProperties[(FX_WORD)wch]; |
1074 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; | 1073 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; |
1075 int32_t iContext = 0; | 1074 int32_t iContext = 0; |
1076 switch (iBidiCls) { | 1075 switch (iBidiCls) { |
1077 case FX_BIDICLASS_L: | 1076 case FX_BIDICLASS_L: |
1078 case FX_BIDICLASS_AN: | 1077 case FX_BIDICLASS_AN: |
1079 case FX_BIDICLASS_EN: | 1078 case FX_BIDICLASS_EN: |
1080 iContext = 1; | 1079 iContext = 1; |
1081 break; | 1080 break; |
1082 case FX_BIDICLASS_R: | 1081 case FX_BIDICLASS_R: |
1083 case FX_BIDICLASS_AL: | 1082 case FX_BIDICLASS_AL: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 return m_iLastBidi; | 1120 return m_iLastBidi; |
1122 } | 1121 } |
1123 void CFX_BidiChar::Reset() { | 1122 void CFX_BidiChar::Reset() { |
1124 m_iCurStart = 0; | 1123 m_iCurStart = 0; |
1125 m_iCurCount = 0; | 1124 m_iCurCount = 0; |
1126 m_iCurBidi = 0; | 1125 m_iCurBidi = 0; |
1127 m_iLastBidi = 0; | 1126 m_iLastBidi = 0; |
1128 m_iLastStart = 0; | 1127 m_iLastStart = 0; |
1129 m_iLastCount = 0; | 1128 m_iLastCount = 0; |
1130 } | 1129 } |
OLD | NEW |