summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fxcrt/fx_arabic.cpp74
-rw-r--r--core/fxcrt/include/fx_arabic.h27
2 files changed, 50 insertions, 51 deletions
diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp
index 191350e24d..01a1a2a15e 100644
--- a/core/fxcrt/fx_arabic.cpp
+++ b/core/fxcrt/fx_arabic.cpp
@@ -114,6 +114,23 @@ const FX_ARASHADDA gs_FX_ShaddaTable[] = {
{0x064F, 0xFC61}, {0x0650, 0xFC62},
};
+const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC,
+ FX_WCHAR& wChar,
+ FX_CHARTYPE& eType) {
+ if (!pTC) {
+ eType = FX_CHARTYPE_Unknown;
+ wChar = 0xFEFF;
+ return nullptr;
+ }
+ eType = (FX_CHARTYPE)pTC->GetCharType();
+ wChar = (FX_WCHAR)pTC->m_wCharCode;
+ const FX_ARBFORMTABLE* pFT = FX_GetArabicFormTable(wChar);
+ if (!pFT || eType >= FX_CHARTYPE_ArabicNormal)
+ eType = FX_CHARTYPE_Unknown;
+
+ return pFT;
+}
+
} // namespace
const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode) {
@@ -145,26 +162,30 @@ FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda) {
return shadda;
}
-FX_BOOL CFX_ArabicChar::IsArabicChar(FX_WCHAR wch) const {
+namespace pdfium {
+namespace arabic {
+
+bool IsArabicChar(FX_WCHAR wch) {
uint32_t dwRet =
kTextLayoutCodeProperties[(uint16_t)wch] & FX_CHARTYPEBITSMASK;
return dwRet >= FX_CHARTYPE_ArabicAlef;
}
-FX_BOOL CFX_ArabicChar::IsArabicFormChar(FX_WCHAR wch) const {
+
+bool IsArabicFormChar(FX_WCHAR wch) {
return (kTextLayoutCodeProperties[(uint16_t)wch] & FX_CHARTYPEBITSMASK) ==
FX_CHARTYPE_ArabicForm;
}
-FX_WCHAR CFX_ArabicChar::GetFormChar(FX_WCHAR wch,
- FX_WCHAR prev,
- FX_WCHAR next) const {
+
+FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev, FX_WCHAR next) {
CFX_Char c(wch, kTextLayoutCodeProperties[(uint16_t)wch]);
CFX_Char p(prev, kTextLayoutCodeProperties[(uint16_t)prev]);
CFX_Char n(next, kTextLayoutCodeProperties[(uint16_t)next]);
return GetFormChar(&c, &p, &n);
}
-FX_WCHAR CFX_ArabicChar::GetFormChar(const CFX_Char* cur,
- const CFX_Char* prev,
- const CFX_Char* next) const {
+
+FX_WCHAR GetFormChar(const CFX_Char* cur,
+ const CFX_Char* prev,
+ const CFX_Char* next) {
FX_CHARTYPE eCur;
FX_WCHAR wCur;
const FX_ARBFORMTABLE* ft = ParseChar(cur, wCur, eCur);
@@ -184,37 +205,22 @@ FX_WCHAR CFX_ArabicChar::GetFormChar(const CFX_Char* cur,
if (ePrev < FX_CHARTYPE_ArabicAlef) {
if (bAlef) {
return FX_GetArabicFromAlefTable(wNext);
- } else {
- return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
- }
- } else {
- if (bAlef) {
- wCur = FX_GetArabicFromAlefTable(wNext);
- return (ePrev != FX_CHARTYPE_ArabicDistortion) ? wCur : ++wCur;
- } else if (ePrev == FX_CHARTYPE_ArabicAlef ||
- ePrev == FX_CHARTYPE_ArabicSpecial) {
- return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
- } else {
- return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wFinal : ft->wMedial;
}
+ return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
}
-}
-const FX_ARBFORMTABLE* CFX_ArabicChar::ParseChar(const CFX_Char* pTC,
- FX_WCHAR& wChar,
- FX_CHARTYPE& eType) const {
- if (pTC == NULL) {
- eType = FX_CHARTYPE_Unknown;
- wChar = 0xFEFF;
- return NULL;
+ if (bAlef) {
+ wCur = FX_GetArabicFromAlefTable(wNext);
+ return (ePrev != FX_CHARTYPE_ArabicDistortion) ? wCur : ++wCur;
}
- eType = (FX_CHARTYPE)pTC->GetCharType();
- wChar = (FX_WCHAR)pTC->m_wCharCode;
- const FX_ARBFORMTABLE* pFT = FX_GetArabicFormTable(wChar);
- if (pFT == NULL || eType >= FX_CHARTYPE_ArabicNormal) {
- eType = FX_CHARTYPE_Unknown;
+ if (ePrev == FX_CHARTYPE_ArabicAlef || ePrev == FX_CHARTYPE_ArabicSpecial) {
+ return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
}
- return pFT;
+ return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wFinal : ft->wMedial;
}
+
+} // namespace arabic
+} // namespace pdfium
+
void FX_BidiReverseString(CFX_WideString& wsText,
int32_t iStart,
int32_t iCount) {
diff --git a/core/fxcrt/include/fx_arabic.h b/core/fxcrt/include/fx_arabic.h
index 96fa7954c3..2617d1897f 100644
--- a/core/fxcrt/include/fx_arabic.h
+++ b/core/fxcrt/include/fx_arabic.h
@@ -14,25 +14,18 @@
#define FX_BidiGetDeferredType(a) (((a) >> 4) & 0x0F)
#define FX_BidiGetResolvedType(a) ((a)&0x0F)
-class CFX_ArabicChar {
- public:
- void Release() { delete this; }
+namespace pdfium {
+namespace arabic {
- FX_BOOL IsArabicChar(FX_WCHAR wch) const;
- FX_BOOL IsArabicFormChar(FX_WCHAR wch) const;
+bool IsArabicChar(FX_WCHAR wch);
+bool IsArabicFormChar(FX_WCHAR wch);
+FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev = 0, FX_WCHAR next = 0);
+FX_WCHAR GetFormChar(const CFX_Char* cur,
+ const CFX_Char* prev,
+ const CFX_Char* next);
- FX_WCHAR GetFormChar(FX_WCHAR wch,
- FX_WCHAR prev = 0,
- FX_WCHAR next = 0) const;
- FX_WCHAR GetFormChar(const CFX_Char* cur,
- const CFX_Char* prev,
- const CFX_Char* next) const;
-
- protected:
- const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC,
- FX_WCHAR& wChar,
- FX_CHARTYPE& eType) const;
-};
+} // namespace arabic
+} // namespace pdfium
void FX_BidiReverseString(CFX_WideString& wsText,
int32_t iStart,