{"action":"created","issue":{"url":"https://api.github.com/repos/eloraiby/arabtype/issues/2","repository_url":"https://api.github.com/repos/eloraiby/arabtype","labels_url":"https://api.github.com/repos/eloraiby/arabtype/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/eloraiby/arabtype/issues/2/comments","events_url":"https://api.github.com/repos/eloraiby/arabtype/issues/2/events","html_url":"https://github.com/eloraiby/arabtype/issues/2","id":149823611,"number":2,"title":"Correct Rendering of all kind of texts?","user":{"login":"noblemaster","id":2363626,"avatar_url":"https://avatars.githubusercontent.com/u/2363626?v=3","gravatar_id":"","url":"https://api.github.com/users/noblemaster","html_url":"https://github.com/noblemaster","followers_url":"https://api.github.com/users/noblemaster/followers","following_url":"https://api.github.com/users/noblemaster/following{/other_user}","gists_url":"https://api.github.com/users/noblemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/noblemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noblemaster/subscriptions","organizations_url":"https://api.github.com/users/noblemaster/orgs","repos_url":"https://api.github.com/users/noblemaster/repos","events_url":"https://api.github.com/users/noblemaster/events{/privacy}","received_events_url":"https://api.github.com/users/noblemaster/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-20T16:42:52Z","updated_at":"2016-04-21T01:39:32Z","closed_at":"2016-04-21T01:39:32Z","body":"I adapted my algorithm to Java. It works great, but letters that don't need to be transformed don't seem to work:\r\n\r\nThis is the text:\r\nمستوى صعوبة الحاسوب\r\n\r\nThis is how it is rendered:\r\nمستو صعوبة الحاسوب\r\n\r\nBasically, the 'ى' is missing!\r\n\r\nIs that a bug in my code? \r\n\r\n    public static char correct(char prev, char next, char ch) {\r\n      if ((ch >= ARABIC_LETTER_START) && (ch <= ARABIC_LETTER_FINAL)) {\r\n        // covert Arabic letter - https://github.com/eloraiby/arabtype/blob/master/arabtype.c\r\n        boolean isLa  = isLamAlef(ch, next);\r\n        boolean isApl = isAlefPrevLam(prev, ch);\r\n\r\n        boolean isLapl = isLa | isApl;\r\n\r\n        // determine char to return\r\n        if(isLapl) {\r\n          int index\t= ((isLinkingType(ch) ? 1 : 0) << 1) | (isLinkingType(prev) ? 1 : 0);\r\n          return (char)ARABIC_FORMS_B[next -  ARABIC_LETTER_START][1][index];\r\n        }\r\n        else {\r\n          if (isApl) {\r\n            return ch;\t// skip previously processed lam alef\r\n          }\r\n          else {\r\n            int index\t= (((isArabicLetter(next) ? 1 : 0) & (isLinkingType(ch) ? 1 : 0)) << 1) | (isLinkingType(prev) ? 1 : 0);\r\n            return (char)ARABIC_FORMS_B[ch -  ARABIC_LETTER_START][0][index];\r\n          }\r\n        }\r\n\r\n        // NOTE: compact form of the above...\r\n        // int index = ((((isLapl | isArabicLetter(next)) & isLinkingType(ch)) ? 1 : 0) << 1) | (isLinkingType(prev) ? 1 : 0);\r\n        // int ref = (next * (isLa ? 1 : 0)) + (ch * (isLa ? 0 : 1)) - ARABIC_LETTER_START;\r\n        // return (char)ARABIC_FORMS_B[ref][isLapl ? 1 : 0][index];\r\n      }\r\n      else {\r\n        // not an Arabic letter to be converted!\r\n        return ch;\r\n      }\r\n    }\r\n\r\n    private static final char ARABIC_LETTER_START = 0x0621;\r\n    private static final char ARABIC_LETTER_FINAL = 0x064A;\r\n  \r\n    // private static final int ENDING = 1;\r\n    private static final int INITIAL = 2;\r\n    private static final int MEDIAL = 3;\r\n  \r\n    private static final int UNICODE_LAM = 0x644;\r\n  \r\n    private static boolean isArabicLetter(char cp)    {\r\n      return ( cp >= ARABIC_LETTER_START && cp <=  ARABIC_LETTER_FINAL );\r\n    }\r\n  \r\n    private static boolean isLamAlef(char cp, char next)  {\r\n      return cp == UNICODE_LAM && isArabicLetter(next) && ARABIC_FORMS_B[next - ARABIC_LETTER_START][1][INITIAL] != 0;\r\n    }\r\n  \r\n    private static boolean isAlefPrevLam(char prev, char cp)  {\r\n      return prev == UNICODE_LAM && isArabicLetter(cp) && ARABIC_FORMS_B[cp - ARABIC_LETTER_START][1][INITIAL] != 0;\r\n    }\r\n  \r\n    private static boolean isLinkingType(char cp) {\r\n      return isArabicLetter(cp) && ARABIC_FORMS_B[cp - ARABIC_LETTER_START][0][MEDIAL] != 0;\r\n    }\r\n  \r\n    /** Table to convert to Arabic presentation form B. */\r\n    private static final int[][][] ARABIC_FORMS_B = {\r\n        { {0xFE80, 0xFE80,      0,      0}, {-1, -1, 0, 0} },    // hamza  (0)\r\n        { {0xFE81, 0xFE82,      0,      0}, {-1, -1, 0xFEF5, 0xFEF6} },  // 2alif madda  (1)\r\n        { {0xFE83, 0xFE84,      0,      0}, {-1, -1, 0xFEF7, 0xFEF8} },  // 2alif hamza  (2)\r\n        { {0xFE85, 0xFE86,      0,      0}, {-1, -1, 0, 0} },    // waw hamza  (3)\r\n        { {0xFE87, 0xFE88,      0,      0}, {-1, -1, 0xFEF9, 0xFEFA} },  // 2alif hamza maksoura  (4)\r\n        { {0xFE89, 0xFE8A, 0xFE8B, 0xFE8C}, {-1, -1, 0, 0} },    // 2alif maqsoura hamza  (5)\r\n        { {0xFE8D, 0xFE8E,      0,      0}, {-1, -1, 0xFEFB, 0xFEFC} },  // 2alif  (6)\r\n        { {0xFE8F, 0xFE90, 0xFE91, 0xFE92}, {-1, -1, 0, 0} },    // ba2    (7)\r\n        { {0xFE93, 0xFE94,      0,      0}, {-1, -1, 0, 0} },    // ta2 marbouta  (8)\r\n        { {0xFE95, 0xFE96, 0xFE97, 0xFE98}, {-1, -1, 0, 0} },    // ta2    (9)\r\n        { {0xFE99, 0xFE9A, 0xFE9B, 0xFE9C}, {-1, -1, 0, 0} },    // tha2    (10)\r\n        { {0xFE9D, 0xFE9E, 0xFE9F, 0xFEA0}, {-1, -1, 0, 0} },    // jim    (11)\r\n        { {0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4}, {-1, -1, 0, 0} },    // 7a2    (12)\r\n        { {0xFEA5, 0xFEA6, 0xFEA7, 0xFEA8}, {-1, -1, 0, 0} },    // kha2    (13)\r\n        { {0xFEA9, 0xFEAA,      0,      0}, {-1, -1, 0, 0} },    // dal    (14)\r\n        { {0xFEAB, 0xFEAC,      0,      0}, {-1, -1, 0, 0} },    // dhal    (15)\r\n        { {0xFEAD, 0xFEAE,      0,      0}, {-1, -1, 0, 0} },    // ra2    (16)\r\n        { {0xFEAF, 0xFEB0,      0,      0}, {-1, -1, 0, 0} },    // zayn    (17)\r\n        { {0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4}, {-1, -1, 0, 0} },    // syn    (18)\r\n        { {0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8}, {-1, -1, 0, 0} },    // shin    (19)\r\n        { {0xFEB9, 0xFEBA, 0xFEBB, 0xFEBC}, {-1, -1, 0, 0} },    // sad    (20)\r\n        { {0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0}, {-1, -1, 0, 0} },    // dad    (21)\r\n        { {0xFEC1, 0xFEC2, 0xFEC3, 0xFEC4}, {-1, -1, 0, 0} },    // tah    (22)\r\n        { {0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8}, {-1, -1, 0, 0} },    // thah    (23)\r\n        { {0xFEC9, 0xFECA, 0xFECB, 0xFECC}, {-1, -1, 0, 0} },    // 3ayn    (24)\r\n        { {0xFECD, 0xFECE, 0xFECF, 0xFED0}, {-1, -1, 0, 0} },    // ghayn  (25)\r\n        { {     0,      0,      0,      0}, {-1, -1, 0, 0} },    //    (26)\r\n        { {     0,      0,      0,      0}, {-1, -1, 0, 0} },    //    (27)\r\n        { {     0,      0,      0,      0}, {-1, -1, 0, 0} },    //    (28)\r\n        { {     0,      0,      0,      0}, {-1, -1, 0, 0} },    //    (29)\r\n        { {     0,      0,      0,      0}, {-1, -1, 0, 0} },    //    (30)\r\n        { {0x0640, 0x0640, 0x0640, 0x0640}, {-1, -1, 0, 0} },    // wasla  (31)\r\n        { {0xFED1, 0xFED2, 0xFED3, 0xFED4}, {-1, -1, 0, 0} },    // fa2    (32)\r\n        { {0xFED5, 0xFED6, 0xFED7, 0xFED8}, {-1, -1, 0, 0} },    // qaf    (33)\r\n        { {0xFED9, 0xFEDA, 0xFEDB, 0xFEDC}, {-1, -1, 0, 0} },    // kaf    (34)\r\n        { {0xFEDD, 0xFEDE, 0xFEDF, 0xFEE0}, {-1, -1, 0, 0} },    // lam    (35)\r\n        { {0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4}, {-1, -1, 0, 0} },    // mim    (36)\r\n        { {0xFEE5, 0xFEE6, 0xFEE7, 0xFEE8}, {-1, -1, 0, 0} },    // noon    (37)\r\n        { {0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC}, {-1, -1, 0, 0} },    // ha2    (38)\r\n        { {0xFEED, 0xFEEE,      0,      0}, {-1, -1, 0, 0} },    // waw    (39)\r\n        { {0xFEFF, 0xFEF0,      0,      0}, {-1, -1, 0, 0} },    // 2alif maksoura  (40)\r\n        { {0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4}, {-1, -1, 0, 0} },    // ya2    (41)\r\n    };\r\n"},"comment":{"url":"https://api.github.com/repos/eloraiby/arabtype/issues/comments/212689017","html_url":"https://github.com/eloraiby/arabtype/issues/2#issuecomment-212689017","issue_url":"https://api.github.com/repos/eloraiby/arabtype/issues/2","id":212689017,"user":{"login":"noblemaster","id":2363626,"avatar_url":"https://avatars.githubusercontent.com/u/2363626?v=3","gravatar_id":"","url":"https://api.github.com/users/noblemaster","html_url":"https://github.com/noblemaster","followers_url":"https://api.github.com/users/noblemaster/followers","following_url":"https://api.github.com/users/noblemaster/following{/other_user}","gists_url":"https://api.github.com/users/noblemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/noblemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noblemaster/subscriptions","organizations_url":"https://api.github.com/users/noblemaster/orgs","repos_url":"https://api.github.com/users/noblemaster/repos","events_url":"https://api.github.com/users/noblemaster/events{/privacy}","received_events_url":"https://api.github.com/users/noblemaster/received_events","type":"User","site_admin":false},"created_at":"2016-04-21T01:39:32Z","updated_at":"2016-04-21T01:39:32Z","body":"Perfect! From what I can tell it works now. Thanks :-D"}}