ArabicShapingEngine.h
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:12k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * ArabicShapingEngine.h
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is header file for ArabicShapingEngine
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  *
  68.  *------------------------------------------------------------------------------
  69.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  70.  *============================================================================
  71.  ****************************************************************************/
  72. #include "MMI_features.h"
  73. #ifdef __MMI_ARSHAPING_ENGINE__
  74. #define UNICODE_ARABIC(ch)        (U16)((ch) - 0x620)
  75. #define UNICODE_ARABIC_FORM_B(ch)        (U16)((ch) - 0xFE70)
  76. #define UNICODE_ARABIC_FORM_A(ch)        (U16)((ch) - 0xFB50)
  77. #define UI_ARABIC_CHARACTER_RANGE(ch)      ((((U16)(ch) > 0x620)&&((U16)(ch) < 0x6FF))?(1) : (0) )
  78. extern const U8 g_arabic_base_char_array[];
  79. extern const U8 g_arabic_form_A_char_array[];
  80. extern const U8 g_arabic_form_B_char_array[];
  81. //#define WHETHER_JOIN_CHARACTER(ch)      (((ch>=0x622 && ch<=0x625)||(ch>=0x62f && ch<=0x632)||ch==0x627||ch==0x648)?(1) : (0))
  82. #define UI_ARABIC_FORM_A_RANGE(ch)      ((((U16)(ch) >= 0xFB50)&&((U16)(ch) <= 0xFDFD))?(1) : (0) )
  83. #define UI_ARABIC_FORM_B_RANGE(ch)      ((((U16)(ch) >= 0xFE70)&&((U16)(ch) <= 0xFEFF))?(1) : (0) )
  84. #define ARABIC_LIGATURE_LENGTH 5
  85. #define LANGUAGE_FOR_LIGATURE 0
  86. #define  WHETHER_JOIN_CHARACTER(ch)  (UI_ARABIC_CHARACTER_RANGE(ch) &&  g_arabic_base_char_array[UNICODE_ARABIC(ch)]) || (UI_ARABIC_FORM_B_RANGE(ch) &&  g_arabic_form_B_char_array[UNICODE_ARABIC_FORM_B(ch)])
  87. /* PMT END PERSIAN */
  88. #define NULL  0
  89. typedef struct
  90. {
  91.     U16 nominalForm;
  92.     U16 preForm;
  93.     U16 postForm;
  94.     U16 middleForm;
  95. } ARABIC_SHAPE_TABLE;
  96. typedef enum
  97. {
  98.     /* Nominal glyph Forms */
  99.     N_HAMZA = 0x0621,
  100.     N_MADDA_ON_ALEF = 0x622,
  101.     N_HAMZA_ON_ALEF = 0x623,
  102.     N_HAMZA_ON_WOW = 0x624,
  103.     N_HAMZA_UNDER_ALEF = 0x625,
  104.     N_HAMZA_ON_YEH = 0x626,
  105.     N_ALEF = 0x627,
  106.     N_BEH = 0x628,
  107.     N_TEH_MARBUTA = 0x629,
  108.     N_TEH = 0x62A,
  109.     N_THEH = 0x62B,
  110.     N_JEEM = 0x62C,
  111.     N_HAH = 0x62D,
  112.     N_KHAH = 0x62E,
  113.     N_DAL = 0x62F,
  114.     N_THAL = 0x630,
  115.     N_REH = 0x631,
  116.     N_ZAIN = 0x632,
  117.     N_SEEN = 0x633,
  118.     N_SHEEN = 0x634,
  119.     N_SAD = 0x635,
  120.     N_DAD = 0x636,
  121.     N_TAH = 0x637,
  122.     N_ZAH = 0x638,
  123.     N_AIN = 0x639,
  124.     N_GHAIN = 0x63A,
  125.     N_TATWEEL = 0x640,
  126.     N_FEH = 0x641,
  127.     N_QAF = 0x642,
  128.     N_KAF = 0x643,
  129.     N_LAM = 0x644,
  130.     N_MEEM = 0x645,
  131.     N_NOON = 0x646,
  132.     N_HEH = 0x647,
  133.     N_WAW = 0x648,
  134.     N_ALEF_MAKSURA = 0x649,
  135.     N_YEH = 0x64A,
  136.     N_PEH = 0x67E,
  137.     N_TCHEH = 0x686,
  138.     N_JEH = 0x698,
  139.     N_KHEHEH = 0x6A9,
  140.     N_GAF = 0x6AF,
  141.     N_FARSIYEH = 0x6CC,
  142.     /* Ligatures */
  143.     N_MADDA_ON_LAMALEF = 0xFEF5,
  144.     N_HAMZA_ON_LAMALEF = 0xFEF7,
  145.     N_HAMZA_UNDER_LAMALEF = 0xFEF9,
  146.     N_LAMALEF = 0xFEFB
  147.         /* PMT END PERSIAN */
  148. } NOMINAL_CHARACTERS_ENUM;
  149. typedef enum
  150. {
  151.     /* left joining Form */
  152.     L_MADDA_ON_ALEF = 0xFE81,
  153.     L_HAMZA_ON_ALEF = 0xFE83,
  154.     L_HAMZA_ON_WOW = 0xFE85,
  155.     L_HAMZA_UNDER_ALEF = 0xFE87,
  156.     L_HAMZA_ON_YEH = 0xFE8B,
  157.     L_ALEF = 0xFE8D,
  158.     L_BEH = 0xFE91,
  159.     L_TEH_MARBUTA = 0xFE93,
  160.     L_TEH = 0xFE97,
  161.     L_THEH = 0xFE9B,
  162.     L_JEEM = 0xFE9F,
  163.     L_HAH = 0xFEA3,
  164.     L_KHAH = 0xFEA7,
  165.     L_DAL = 0xFEA9,
  166.     L_THAL = 0xFEAB,
  167.     L_REH = 0xFEAD,
  168.     L_ZAIN = 0xFEAF,
  169.     L_SEEN = 0xFEB3,
  170.     L_SHEEN = 0xFEB7,
  171.     L_SAD = 0xFEBB,
  172.     L_DAD = 0xFEBF,
  173.     L_TAH = 0xFEC3,
  174.     L_ZAH = 0xFEC7,
  175.     L_AIN = 0xFECB,
  176.     L_GHAIN = 0xFECF,
  177.     /* L_TATWEEL=0x640, same for all forms. */
  178.     L_FEH = 0xFED3,
  179.     L_QAF = 0xFED7,
  180.     L_KAF = 0xFEDB,
  181.     L_LAM = 0xFEDF,
  182.     L_MEEM = 0xFEE3,
  183.     L_NOON = 0xFEE7,
  184.     L_HEH = 0xFEEB,
  185.     L_WAW = 0xFEED,
  186.     L_ALEF_MAKSURA = 0xFEEF,
  187.     L_YEH = 0xFEF3,
  188.     L_PEH = 0xFB58,
  189.     L_TCHEH = 0xFB7C,
  190.     L_JEH = 0xFB8A,
  191.     L_KHEHEH = 0xFB90,
  192.     L_GAF = 0xFB94,
  193.     L_FARSIYEH = 0xFBFE,
  194.     /* Ligatures */
  195.     L_MADDA_ON_LAMALEF = 0xFEF5,
  196.     L_HAMZA_ON_LAMALEF = 0xFEF7,
  197.     L_HAMZA_UNDER_LAMALEF = 0xFEF9,
  198.     L_LAMALEF = 0xFEFB
  199.         /* PMT END PERSIAN */
  200. } LEFT_JOINING_CHARACTERS_ENUM;
  201. typedef enum
  202. {
  203.     /* Right joining Form */
  204.     R_MADDA_ON_ALEF = 0xFE82,
  205.     R_HAMZA_ON_ALEF = 0xFE84,
  206.     R_HAMZA_ON_WOW = 0xFE86,
  207.     R_HAMZA_UNDER_ALEF = 0xFE88,
  208.     R_HAMZA_ON_YEH = 0xFE8A,
  209.     R_ALEF = 0xFE8E,
  210.     R_BEH = 0xFE90,
  211.     R_TEH_MARBUTA = 0xFE94,
  212.     R_TEH = 0xFE96,
  213.     R_THEH = 0xFE9A,
  214.     R_JEEM = 0xFE9E,
  215.     R_HAH = 0xFEA2,
  216.     R_KHAH = 0xFEA6,
  217.     R_DAL = 0xFEAA,
  218.     R_THAL = 0xFEAC,
  219.     R_REH = 0xFEAE,
  220.     R_ZAIN = 0xFEB0,
  221.     R_SEEN = 0xFEB2,
  222.     R_SHEEN = 0xFEB6,
  223.     R_SAD = 0xFEBA,
  224.     R_DAD = 0xFEBE,
  225.     R_TAH = 0xFEC2,
  226.     R_ZAH = 0xFEC6,
  227.     R_AIN = 0xFECA,
  228.     R_GHAIN = 0xFECE,
  229.     /* R_TATWEEL=0x640, same for all forms. */
  230.     R_FEH = 0xFED2,
  231.     R_QAF = 0xFED6,
  232.     R_KAF = 0xFEDA,
  233.     R_LAM = 0xFEDE,
  234.     R_MEEM = 0xFEE2,
  235.     R_NOON = 0xFEE6,
  236.     R_HEH = 0xFEEA,
  237.     R_WAW = 0xFEEE,
  238.     R_ALEF_MAKSURA = 0xFEF0,
  239.     R_YEH = 0xFEF2,
  240.     R_PEH = 0xFB57,
  241.     R_TCHEH = 0xFB7B,
  242.     R_JEH = 0xFB8B,
  243.     R_KHEHEH = 0xFB8F,
  244.     R_GAF = 0xFB93,
  245.     R_FARSIYEH = 0xFBFD,
  246.     /* Ligatures */
  247.     R_MADDA_ON_LAMALEF = 0xFEF6,
  248.     R_HAMZA_ON_LAMALEF = 0xFEF8,
  249.     R_HAMZA_UNDER_LAMALEF = 0xFEFA,
  250.     R_LAMALEF = 0xFEFC
  251.         /* PMT END PERSIAN */
  252. } RIGHT_JOINING_CHARACTERS_ENUM;
  253. typedef enum
  254. {
  255.     /* Middle joining Form */
  256.     M_MADDA_ON_ALEF = 0xFE82,
  257.     M_HAMZA_ON_ALEF = 0xFE84,
  258.     M_HAMZA_ON_WOW = 0xFE86,
  259.     M_HAMZA_UNDER_ALEF = 0xFE88,
  260.     M_HAMZA_ON_YEH = 0xFE8C,
  261.     M_ALEF = 0xFE8E,
  262.     M_BEH = 0xFE92,
  263.     M_TEH_MARBUTA = 0xFE94,
  264.     M_TEH = 0xFE98,
  265.     M_THEH = 0xFE9C,
  266.     M_JEEM = 0xFEA0,
  267.     M_HAH = 0xFEA4,
  268.     M_KHAH = 0xFEA8,
  269.     M_DAL = 0xFEAA,
  270.     M_THAL = 0xFEAC,
  271.     M_REH = 0xFEAE,
  272.     M_ZAIN = 0xFEB0,
  273.     M_SEEN = 0xFEB4,
  274.     M_SHEEN = 0xFEB8,
  275.     M_SAD = 0xFEBC,
  276.     M_DAD = 0xFEC0,
  277.     M_TAH = 0xFEC4,
  278.     M_ZAH = 0xFEC8,
  279.     M_AIN = 0xFECC,
  280.     M_GHAIN = 0xFED0,
  281.     /* M_TATWEEL=0x640, same for all forms. */
  282.     M_FEH = 0xFED4,
  283.     M_QAF = 0xFED8,
  284.     M_KAF = 0xFEDC,
  285.     M_LAM = 0xFEE0,
  286.     M_MEEM = 0xFEE4,
  287.     M_NOON = 0xFEE8,
  288.     M_HEH = 0xFEEC,
  289.     M_WAW = 0xFEEE,
  290.     M_ALEF_MAKSURA = 0xFEF0,
  291.     /* PMT START PERSIAN */
  292.     M_YEH = 0xFEF4,
  293.     M_PEH = 0xFB59,
  294.     M_TCHEH = 0xFB7D,
  295.     M_JEH = 0xFB8B,
  296.     M_KHEHEH = 0xFB91,
  297.     M_GAF = 0xFB95,
  298.     M_FARSIYEH = 0xFBFF,
  299.     /* Ligatures */
  300.     M_MADDA_ON_LAMALEF = 0xFEF6,
  301.     M_HAMZA_ON_LAMALEF = 0xFEF8,
  302.     M_HAMZA_UNDER_LAMALEF = 0xFEFA,
  303.     M_LAMALEF = 0xFEFC
  304.         /* PMT END PERSIAN */
  305. } MIDDLE_JOINING_CHARACTERS_ENUM;
  306. typedef enum
  307. {
  308.     /* Nominal glyph Forms */
  309.     N_HAMZA_FORM_B = 0xFE80,
  310.     N_MADDA_ON_ALEF_FORM_B = 0xFE81,
  311.     N_HAMZA_ON_ALEF_FORM_B = 0xFE83,
  312.     N_HAMZA_ON_WOW_FORM_B = 0xFE85,
  313.     N_HAMZA_UNDER_ALEF_FORM_B = 0xFE87,
  314.     N_HAMZA_ON_YEH_FORM_B = 0xFE89,
  315.     N_ALEF_FORM_B = 0xFE8D,
  316.     N_BEH_FORM_B = 0xFE8F,
  317.     N_TEH_MARBUTA_FORM_B = 0xFE93,
  318.     N_TEH_FORM_B = 0xFE95,
  319.     N_THEH_FORM_B = 0xFE99,
  320.     N_JEEM_FORM_B = 0xFE9D,
  321.     N_HAH_FORM_B = 0xFEA1,
  322.     N_KHAH_FORM_B = 0xFEA5,
  323.     N_DAL_FORM_B = 0xFEA9,
  324.     N_THAL_FORM_B = 0xFEAB,
  325.     N_REH_FORM_B = 0xFEAD,
  326.     N_ZAIN_FORM_B = 0xFEAF,
  327.     N_SEEN_FORM_B = 0xFEB1,
  328.     N_SHEEN_FORM_B = 0xFEB5,
  329.     N_SAD_FORM_B = 0xFEB9,
  330.     N_DAD_FORM_B = 0xFEBD,
  331.     N_TAH_FORM_B = 0xFEC1,
  332.     N_ZAH_FORM_B = 0xFEC5,
  333.     N_AIN_FORM_B = 0xFEC9,
  334.     N_GHAIN_FORM_B = 0xFECD,    
  335.     N_FEH_FORM_B = 0xFED1,
  336.     N_QAF_FORM_B = 0xFED5,
  337.     N_KAF_FORM_B = 0xFED9,
  338.     N_LAM_FORM_B = 0xFEDD,
  339.     N_MEEM_FORM_B = 0xFEE1,
  340.     N_NOON_FORM_B = 0xFEE5,
  341.     N_HEH_FORM_B = 0xFEE9,
  342.     N_WAW_FORM_B = 0xFEED,
  343.     N_ALEF_MAKSURA_FORM_B = 0xFEEF,
  344.     N_YEH_FORM_B = 0xFEF1
  345. } NOMINAL_CHARACTERS_FORM_B_ENUM;
  346. typedef enum
  347. {
  348.     /* Nominal glyph Forms */
  349.     N_PEH_FORM_A = 0xFB56,
  350.     N_TCHEH_FORM_A = 0xFB7A,
  351.     N_JEH_FORM_A = 0xFB8A,
  352.     N_KHEHEH_FORM_A = 0xFB8E,
  353.     N_GAF_FORM_A = 0xFB92,
  354.     N_FARSIYEH_FORM_A = 0xFBFC
  355. } NOMINAL_CHARACTERS_FORM_A_ENUM;
  356. typedef struct _ligature_glyph_info
  357. {    
  358.     U8 nInputLen;               /* no. of input unicode values */
  359.     U8 nOutputLen;              /* no, of output values */
  360.     U8 language_for_ligature;
  361.     U16 Input_glyph[ARABIC_LIGATURE_LENGTH];     /* no. of input glyph used to make conjunct */
  362.     U16 Output_glyph[ARABIC_LIGATURE_LENGTH];    /* no. of output glyph that has to be rendered */
  363. } LIGATURE_INFO_TABLE;
  364. typedef struct _arabic_main_table
  365. {
  366.     const LIGATURE_INFO_TABLE *glyphinfo;  /* pointer to individual table */
  367.     U16 nsize;                          /* size of individual character's array */
  368.     U8 maxInputGlyphSize;               /* max input of glyph it can handle */
  369. } ARABIC_MAIN_TABLE;
  370. extern void ArabicShapeEngine(PU16, PU16);
  371. extern void arabic_ligature_rules(PU16, PU16, PU16, PU16);
  372. extern void ArabicShapeEngine2(PU16 , PU16 , PU16 , PU16 );
  373. #endif /* __MMI_ARSHAPING_ENGINE__ */