Home | History | Annotate | Download | only in fxcrt
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #ifndef CORE_INCLUDE_FXCRT_FX_UCD_H_
      8 #define CORE_INCLUDE_FXCRT_FX_UCD_H_
      9 
     10 #include "fx_basic.h"
     11 
     12 #define FX_BIDICLASSBITS 6
     13 #define FX_BIDICLASSBITSMASK (31 << FX_BIDICLASSBITS)
     14 enum FX_BIDICLASS {
     15   FX_BIDICLASS_ON = 0,    // Other Neutral
     16   FX_BIDICLASS_L = 1,     // Left Letter
     17   FX_BIDICLASS_R = 2,     // Right Letter
     18   FX_BIDICLASS_AN = 3,    // Arabic Number
     19   FX_BIDICLASS_EN = 4,    // European Number
     20   FX_BIDICLASS_AL = 5,    // Arabic Letter
     21   FX_BIDICLASS_NSM = 6,   // Non-spacing Mark
     22   FX_BIDICLASS_CS = 7,    // Common Number Separator
     23   FX_BIDICLASS_ES = 8,    // European Separator
     24   FX_BIDICLASS_ET = 9,    // European Number Terminator
     25   FX_BIDICLASS_BN = 10,   // Boundary Neutral
     26   FX_BIDICLASS_S = 11,    // Segment Separator
     27   FX_BIDICLASS_WS = 12,   // Whitespace
     28   FX_BIDICLASS_B = 13,    // Paragraph Separator
     29   FX_BIDICLASS_RLO = 14,  // Right-to-Left Override
     30   FX_BIDICLASS_RLE = 15,  // Right-to-Left Embedding
     31   FX_BIDICLASS_LRO = 16,  // Left-to-Right Override
     32   FX_BIDICLASS_LRE = 17,  // Left-to-Right Embedding
     33   FX_BIDICLASS_PDF = 18,  // Pop Directional Format
     34   FX_BIDICLASS_N = FX_BIDICLASS_ON,
     35 };
     36 
     37 extern const FX_DWORD kTextLayoutCodeProperties[];
     38 extern const size_t kTextLayoutCodePropertiesSize;
     39 
     40 extern const FX_WCHAR kFXTextLayoutVerticalMirror[];
     41 extern const size_t kFXTextLayoutVerticalMirrorSize;
     42 
     43 extern const FX_WCHAR kFXTextLayoutBidiMirror[];
     44 extern const size_t kFXTextLayoutBidiMirrorSize;
     45 
     46 FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch);
     47 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical);
     48 
     49 #ifdef PDF_ENABLE_XFA
     50 enum FX_CHARBREAKPROP {
     51   FX_CBP_OP = 0,
     52   FX_CBP_CL = 1,
     53   FX_CBP_QU = 2,
     54   FX_CBP_GL = 3,
     55   FX_CBP_NS = 4,
     56   FX_CBP_EX = 5,
     57   FX_CBP_SY = 6,
     58   FX_CBP_IS = 7,
     59   FX_CBP_PR = 8,
     60   FX_CBP_PO = 9,
     61   FX_CBP_NU = 10,
     62   FX_CBP_AL = 11,
     63   FX_CBP_ID = 12,
     64   FX_CBP_IN = 13,
     65   FX_CBP_HY = 14,
     66   FX_CBP_BA = 15,
     67   FX_CBP_BB = 16,
     68   FX_CBP_B2 = 17,
     69   FX_CBP_ZW = 18,
     70   FX_CBP_CM = 19,
     71   FX_CBP_WJ = 20,
     72   FX_CBP_H2 = 21,
     73   FX_CBP_H3 = 22,
     74   FX_CBP_JL = 23,
     75   FX_CBP_JV = 24,
     76   FX_CBP_JT = 25,
     77 
     78   FX_CBP_BK = 26,
     79   FX_CBP_CR = 27,
     80   FX_CBP_LF = 28,
     81   FX_CBP_NL = 29,
     82   FX_CBP_SA = 30,
     83   FX_CBP_SG = 31,
     84   FX_CBP_CB = 32,
     85   FX_CBP_XX = 33,
     86   FX_CBP_AI = 34,
     87   FX_CBP_SP = 35,
     88   FX_CBP_TB = 37,
     89   FX_CBP_NONE = 36,
     90 };
     91 
     92 #define FX_CHARTYPEBITS 11
     93 #define FX_CHARTYPEBITSMASK (15 << FX_CHARTYPEBITS)
     94 enum FX_CHARTYPE {
     95   FX_CHARTYPE_Unknown = 0,
     96   FX_CHARTYPE_Tab = (1 << FX_CHARTYPEBITS),
     97   FX_CHARTYPE_Space = (2 << FX_CHARTYPEBITS),
     98   FX_CHARTYPE_Control = (3 << FX_CHARTYPEBITS),
     99   FX_CHARTYPE_Combination = (4 << FX_CHARTYPEBITS),
    100   FX_CHARTYPE_Numeric = (5 << FX_CHARTYPEBITS),
    101   FX_CHARTYPE_Normal = (6 << FX_CHARTYPEBITS),
    102   FX_CHARTYPE_ArabicAlef = (7 << FX_CHARTYPEBITS),
    103   FX_CHARTYPE_ArabicSpecial = (8 << FX_CHARTYPEBITS),
    104   FX_CHARTYPE_ArabicDistortion = (9 << FX_CHARTYPEBITS),
    105   FX_CHARTYPE_ArabicNormal = (10 << FX_CHARTYPEBITS),
    106   FX_CHARTYPE_ArabicForm = (11 << FX_CHARTYPEBITS),
    107   FX_CHARTYPE_Arabic = (12 << FX_CHARTYPEBITS),
    108 };
    109 
    110 FX_BOOL FX_IsCtrlCode(FX_WCHAR ch);
    111 FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch,
    112                           FX_DWORD dwProps,
    113                           FX_BOOL bRTL,
    114                           FX_BOOL bVertical);
    115 class CFX_Char {
    116  public:
    117   CFX_Char()
    118       : m_wCharCode(0),
    119         m_nBreakType(0),
    120         m_nRotation(0),
    121         m_dwCharProps(0),
    122         m_dwCharStyles(0),
    123         m_iCharWidth(0),
    124         m_iHorizontalScale(100),
    125         m_iVertialScale(100) {}
    126   CFX_Char(FX_WORD wCharCode, FX_DWORD dwCharProps)
    127       : m_wCharCode(wCharCode),
    128         m_nBreakType(0),
    129         m_nRotation(0),
    130         m_dwCharProps(dwCharProps),
    131         m_dwCharStyles(0),
    132         m_iCharWidth(0),
    133         m_iHorizontalScale(100),
    134         m_iVertialScale(100) {}
    135   FX_DWORD GetCharType() const { return m_dwCharProps & FX_CHARTYPEBITSMASK; }
    136   FX_WORD m_wCharCode;
    137   uint8_t m_nBreakType;
    138   int8_t m_nRotation;
    139   FX_DWORD m_dwCharProps;
    140   FX_DWORD m_dwCharStyles;
    141   int32_t m_iCharWidth;
    142   int32_t m_iHorizontalScale;
    143   int32_t m_iVertialScale;
    144 };
    145 typedef CFX_ArrayTemplate<CFX_Char> CFX_CharArray;
    146 class CFX_TxtChar : public CFX_Char {
    147  public:
    148   CFX_TxtChar()
    149       : CFX_Char(),
    150         m_dwStatus(0),
    151         m_iBidiClass(0),
    152         m_iBidiLevel(0),
    153         m_iBidiPos(0),
    154         m_iBidiOrder(0),
    155         m_pUserData(NULL) {}
    156   FX_DWORD m_dwStatus;
    157   int16_t m_iBidiClass;
    158   int16_t m_iBidiLevel;
    159   int16_t m_iBidiPos;
    160   int16_t m_iBidiOrder;
    161   void* m_pUserData;
    162 };
    163 typedef CFX_ArrayTemplate<CFX_TxtChar> CFX_TxtCharArray;
    164 class CFX_RTFChar : public CFX_Char {
    165  public:
    166   CFX_RTFChar()
    167       : CFX_Char(),
    168         m_dwStatus(0),
    169         m_iFontSize(0),
    170         m_iFontHeight(0),
    171         m_iBidiClass(0),
    172         m_iBidiLevel(0),
    173         m_iBidiPos(0),
    174         m_dwLayoutStyles(0),
    175         m_dwIdentity(0),
    176         m_pUserData(NULL) {}
    177   FX_DWORD m_dwStatus;
    178   int32_t m_iFontSize;
    179   int32_t m_iFontHeight;
    180   int16_t m_iBidiClass;
    181   int16_t m_iBidiLevel;
    182   int16_t m_iBidiPos;
    183   int16_t m_iBidiOrder;
    184   FX_DWORD m_dwLayoutStyles;
    185   FX_DWORD m_dwIdentity;
    186   IFX_Unknown* m_pUserData;
    187 };
    188 typedef CFX_ArrayTemplate<CFX_RTFChar> CFX_RTFCharArray;
    189 #endif  // PDF_ENABLE_XFA
    190 
    191 #endif  // CORE_INCLUDE_FXCRT_FX_UCD_H_
    192