├── AssetStoreTools └── Editor │ ├── AssetStoreTools.dll │ ├── AssetStoreToolsExtra.dll │ └── DroidSansMono.ttf ├── Fonts └── BCompset.ttf ├── README.md ├── Scripts ├── Fa.cs └── SampleFa.cs ├── UnityFarsi.unity └── UnityFarsi.unitypackage /AssetStoreTools/Editor/AssetStoreTools.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Spitmaan/Unity3DFarsi/40d43369d0df332fb0f0932d6fb46c21d88ed0bb/AssetStoreTools/Editor/AssetStoreTools.dll -------------------------------------------------------------------------------- /AssetStoreTools/Editor/AssetStoreToolsExtra.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Spitmaan/Unity3DFarsi/40d43369d0df332fb0f0932d6fb46c21d88ed0bb/AssetStoreTools/Editor/AssetStoreToolsExtra.dll -------------------------------------------------------------------------------- /AssetStoreTools/Editor/DroidSansMono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Spitmaan/Unity3DFarsi/40d43369d0df332fb0f0932d6fb46c21d88ed0bb/AssetStoreTools/Editor/DroidSansMono.ttf -------------------------------------------------------------------------------- /Fonts/BCompset.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Spitmaan/Unity3DFarsi/40d43369d0df332fb0f0932d6fb46c21d88ed0bb/Fonts/BCompset.ttf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity3DFarsi 2 | Farsi support script for Unity3D 3 | 4 | You can download unity package and import it to your unity editor (Assets-> Import Package-> Custom Package) 5 | open UnityFarsi.unity scene it click play! Enjoy! 6 | 7 | #Hierarchy 8 | 9 | /AssetStoreTools => tools for editor 10 | 11 | /Fonts => needed fonts (you can add your font) 12 | 13 | /Scripts 14 | 15 | ./Fa.cs => Main Script (do not alter if you do not know how does it work!) 16 | 17 | ./Samples.cs => you can see you script works 18 | 19 | /UnityFarsi.unity => sample unity scene 20 | 21 | 22 | # Examples 23 | Here is Some Example of usage. 24 | 25 | Do not need to use any othe namespace. System.Collections is enough!! 26 | 27 | 28 | string sample = "این یک نمونه است!"; 29 | 30 | string faSample = sample.faConvert (); 31 | 32 | Debug.Log (sample.faConvert ()); 33 | 34 | Debug.Log(Fa.faConvert(sample)); 35 | 36 | Debug.Log ("این یک نمونه است!".faConvert ()); 37 | 38 | Debug.Log(Fa.faConvert("این یک نمونه است!")); 39 | 40 | 41 | Debug.Log (faSample.faConvert ()); // DO NOT CONVERT A CONVERTED STRING!!!!!!!! 42 | 43 | 44 | faSample = "این یک نمونه حاوی کلمات English است! همراه با پشتیبانی از حروف عربی - ي - ئ - ؤ - إ - أ - ة - ك"; 45 | 46 | faSample = "ك بك كب بكب - ة مة - ؤ مؤ - أذان - إذن - ي بي يب بيب - ئ بئ ئب بئب"; 47 | 48 | 49 | Debug.Log (faSample.faConvert ()); 50 | 51 | -------------------------------------------------------------------------------- /Scripts/Fa.cs: -------------------------------------------------------------------------------- 1 | //############################################################################## 2 | //# # 3 | //# Unity Farsi # 4 | //# # 5 | //# @Copyright (C) 2014 By Mehran M. Spitmaan # 6 | //# from Azdaa (mehran.m.spitman@gmail.com # 7 | //# # 8 | //# # 9 | //# This program is free software: you can redistribute it and/or modify # 10 | //# it under the terms of the GNU General Public License as published by # 11 | //# the Free Software Foundation, either version 3 of the License, or # 12 | //# (at your option) any later version. # 13 | //# # 14 | //# This program is distributed in the hope that it will be useful, # 15 | //# but WITHOUT ANY WARRANTY; without even the implied warranty of # 16 | //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 17 | //# GNU General Public License for more details. # 18 | //# # 19 | //############################################################################## 20 | 21 | using System.Collections; 22 | using System.Collections.Generic; 23 | using System; 24 | using System.IO; 25 | 26 | namespace System.Collections 27 | { 28 | public static class Fa { 29 | 30 | public static Dictionary charStorage = new Dictionary () 31 | { 32 | {65165, new int[] {65165, 65166, 65165, 65166}}, {65167, new int[] {65167, 65168, 65169, 65170}}, {64342, new int[] {64342, 64343, 64344, 64345}}, {65173, new int[] {65173, 65174, 65175, 65176}}, {65177, new int[] {65177, 65178, 65179, 65180}}, {65181, new int[] {65181, 65182, 65183, 65184}}, {64378, new int[] {64378, 64379, 64380, 64381}}, {65185, new int[] {65185, 65186, 65187, 65188}}, {65189, new int[] {65189, 65190, 65191, 65192}}, {65193, new int[] {65193, 65194, 65193, 65194}}, {65195, new int[] {65195, 65196, 65195, 65196}}, {65197, new int[] {65197, 65198, 65197, 65198}}, {65199, new int[] {65199, 65200, 65199, 65200}}, {64394, new int[] {64394, 64395, 64394, 64395}}, {65201, new int[] {65201, 65202, 65203, 65204}}, {65205, new int[] {65205, 65206, 65207, 65208}}, {65209, new int[] {65209, 65210, 65211, 65212}}, {65213, new int[] {65213, 65214, 65215, 65216}}, {65217, new int[] {65217, 65218, 65219, 65220}}, {65221, new int[] {65221, 65222, 65223, 65224}}, {65225, new int[] {65225, 65226, 65227, 65228}}, {65229, new int[] {65229, 65230, 65231, 65232}}, {65233, new int[] {65233, 65234, 65235, 65236}}, {65237, new int[] {65237, 65238, 65239, 65240}}, {64398, new int[] {64398, 64399, 64400, 64401}}, {64402, new int[] {64402, 64403, 64404, 64405}}, {65245, new int[] {65245, 65246, 65247, 65248}}, {65249, new int[] {65249, 65250, 65251, 65252}}, {65253, new int[] {65253, 65254, 65255, 65256}}, {65261, new int[] {65261, 65262, 65261, 65262}}, {65257, new int[] {65257, 65258, 65259, 65260}}, {64508, new int[] {64508, 64509, 64510, 64511}}, {65153, new int[] {65153, 65154, 65153, 65154}}, 33 | {1575, new int[] {1575, 65166, 65165, 65166}}, {1576, new int[] {1576, 65168, 65169, 65170}}, {1662, new int[] {1662, 64343, 64344, 64345}}, {1578, new int[] {1578, 65174, 65175, 65176}}, {1579, new int[] {1579, 65178, 65179, 65180}}, {1580, new int[] {1580, 65182, 65183, 65184}}, {1670, new int[] {1670, 64379, 64380, 64381}}, {1581, new int[] {1581, 65186, 65187, 65188}}, {1582, new int[] {1582, 65190, 65191, 65192}}, {1583, new int[] {1583, 65194, 65193, 65194}}, {1584, new int[] {1584, 65196, 65195, 65196}}, {1585, new int[] {1585, 65198, 65197, 65198}}, {1586, new int[] {1586, 65200, 65199, 65200}}, {1688, new int[] {1688, 64395, 64394, 64395}}, {1587, new int[] {1587, 65202, 65203, 65204}}, {1588, new int[] {1588, 65206, 65207, 65208}}, {1589, new int[] {1589, 65210, 65211, 65212}}, {1590, new int[] {1590, 65214, 65215, 65216}}, {1591, new int[] {1591, 65218, 65219, 65220}}, {1592, new int[] {1592, 65222, 65223, 65224}}, {1593, new int[] {1593, 65226, 65227, 65228}}, {1594, new int[] {1594, 65230, 65231, 65232}}, {1601, new int[] {1601, 65234, 65235, 65236}}, {1602, new int[] {1602, 65238, 65239, 65240}}, {1705, new int[] {1705, 64399, 64400, 64401}}, {1711, new int[] {1711, 64403, 64404, 64405}}, {1604, new int[] {1604, 65246, 65247, 65248}}, {1605, new int[] {1605, 65250, 65251, 65252}}, {1606, new int[] {1606, 65254, 65255, 65256}}, {1608, new int[] {1608, 65262, 65261, 65262}}, {1607, new int[] {1607, 65258, 65259, 65260}}, {1740, new int[] {1740, 64509, 64510, 64511}}, {1570, new int[] {1570, 65154, 65153, 65154}}, 34 | 35 | {65265, new int[] {65265, 65266, 65267, 65268}}, {65171, new int[] {65171, 65172, 65171, 65172}}, {65263, new int[] {65263, 65264, 65263, 65264}}, {65157, new int[] {65157, 65158, 65157, 65158}}, {65155, new int[] {65155, 65156, 65155, 65156}}, {65159, new int[] {65159, 65160, 65159, 65160}}, {65241, new int[] {65241, 65242, 65243, 65244}}, {65161, new int[] {65161, 65162, 65163, 65164}}, 36 | {1610, new int[] {65265, 65266, 65267, 65268}}, {1577, new int[] {65171, 65172, 65171, 65172}}, {1609, new int[] {65263, 65264, 65263, 65264}}, {1572, new int[] {65157, 65158, 65157, 65158}}, {1571, new int[] {65155, 65156, 65155, 65156}}, {1573, new int[] {65159, 65160, 65159, 65160}}, {1603, new int[] {65241, 65242, 65243, 65244}}, {1574, new int[] {65161, 65162, 65163, 65164}}, 37 | 38 | }; 39 | 40 | public static Dictionary boolStorage = new Dictionary () 41 | { 42 | {65165, new int[] {0, 1}}, {65167, new int[] {1, 1}}, {64342, new int[] {1, 1}}, {65173, new int[] {1, 1}}, {65177, new int[] {1, 1}}, {65181, new int[] {1, 1}}, {64378, new int[] {1, 1}}, {65185, new int[] {1, 1}}, {65189, new int[] {1, 1}}, {65193, new int[] {0, 1}}, {65195, new int[] {0, 1}}, {65197, new int[] {0, 1}}, {65199, new int[] {0, 1}}, {64394, new int[] {0, 1}}, {65201, new int[] {1, 1}}, {65205, new int[] {1, 1}}, {65209, new int[] {1, 1}}, {65213, new int[] {1, 1}}, {65217, new int[] {1, 1}}, {65221, new int[] {1, 1}}, {65225, new int[] {1, 1}}, {65229, new int[] {1, 1}}, {65233, new int[] {1, 1}}, {65237, new int[] {1, 1}}, {64398, new int[] {1, 1}}, {64402, new int[] {1, 1}}, {65245, new int[] {1, 1}}, {65249, new int[] {1, 1}}, {65253, new int[] {1, 1}}, {65261, new int[] {0, 1}}, {65257, new int[] {1, 1}}, {64508, new int[] {1, 1}}, {65153, new int[] {0, 1}}, 43 | {1575, new int[] {0, 1}}, {1576, new int[] {1, 1}}, {1662, new int[] {1, 1}}, {1578, new int[] {1, 1}}, {1579, new int[] {1, 1}}, {1580, new int[] {1, 1}}, {1670, new int[] {1, 1}}, {1581, new int[] {1, 1}}, {1582, new int[] {1, 1}}, {1583, new int[] {0, 1}}, {1584, new int[] {0, 1}}, {1585, new int[] {0, 1}}, {1586, new int[] {0, 1}}, {1688, new int[] {0, 1}}, {1587, new int[] {1, 1}}, {1588, new int[] {1, 1}}, {1589, new int[] {1, 1}}, {1590, new int[] {1, 1}}, {1591, new int[] {1, 1}}, {1592, new int[] {1, 1}}, {1593, new int[] {1, 1}}, {1594, new int[] {1, 1}}, {1601, new int[] {1, 1}}, {1602, new int[] {1, 1}}, {1705, new int[] {1, 1}}, {1711, new int[] {1, 1}}, {1604, new int[] {1, 1}}, {1605, new int[] {1, 1}}, {1606, new int[] {1, 1}}, {1608, new int[] {0, 1}}, {1607, new int[] {1, 1}}, {1740, new int[] {1, 1}}, {1570, new int[] {0, 1}}, 44 | 45 | {65265, new int[] {1, 1}}, {65171, new int[] {0, 1}}, {65263, new int[] {0, 1}}, {65157, new int[] {0, 1}}, {65155, new int[] {0, 1}}, {65159, new int[] {0, 1}}, {65241, new int[] {1, 1}}, {65161, new int[] {1, 1}}, 46 | {1610, new int[] {1, 1}}, {1577, new int[] {0, 1}}, {1609, new int[] {0, 1}}, {1572, new int[] {0, 1}}, {1571, new int[] {0, 1}}, {1573, new int[] {0, 1}}, {1603, new int[] {1, 1}}, {1574, new int[] {1, 1}}, 47 | 48 | }; 49 | 50 | public static string faConvert(this string input) 51 | { 52 | string outStr = ""; 53 | using (StringReader reader = new StringReader(input)) 54 | { 55 | string line; 56 | bool more = false; 57 | while ((line = reader.ReadLine()) != null) 58 | { 59 | if (more) outStr += "\n"; 60 | outStr += faConvertLine(line); 61 | more = true; 62 | } 63 | } 64 | return outStr; 65 | } 66 | 67 | public static string faConvertLine(string input) 68 | { 69 | char[] charTemp = input.ToCharArray (); 70 | 71 | char chT; 72 | List listT = new List(); 73 | List listF = new List(); 74 | for (int i=0; i < charTemp.Length; i++) 75 | { 76 | if (isFarsi(charTemp[i])) 77 | { 78 | chT = convertChar((i==0)?0:Convert.ToInt32(charTemp[i-1]), 79 | Convert.ToInt32(charTemp[i]), 80 | (i==charTemp.Length-1)?0:Convert.ToInt32(charTemp[i+1])); 81 | 82 | listT.Reverse(); 83 | listF.AddRange(listT); 84 | listF.Add(chT); 85 | 86 | listT.Clear(); 87 | } 88 | else 89 | { 90 | listT.Add(charTemp[i]); 91 | } 92 | } 93 | 94 | listT.Reverse(); 95 | listF.AddRange(listT); 96 | listF.Reverse(); 97 | return new string (listF.ToArray()); 98 | } 99 | 100 | public static char convertChar(int prev, int curr, int next) 101 | { 102 | 103 | int pr=0, ne=0; 104 | int[] tmp; int[] ctmp; 105 | 106 | if (boolStorage.TryGetValue (prev, out tmp)) 107 | pr = tmp[0]; 108 | else 109 | pr = 0; 110 | 111 | if (boolStorage.TryGetValue (next, out tmp)) 112 | ne = tmp[1]; 113 | else 114 | ne = 0; 115 | 116 | if (charStorage.TryGetValue(curr, out ctmp)) 117 | return Char.ConvertFromUtf32(ctmp [pr + (ne * 2)])[0]; 118 | else 119 | return Char.ConvertFromUtf32(curr)[0]; 120 | } 121 | 122 | public static bool isFarsi(char ch) 123 | { 124 | int ch16 = Convert.ToInt32(ch); 125 | if ((ch16 >= 1536 && ch16 <= 1791) || (ch16 >= 65136 && ch16 <= 65279)) 126 | return true; 127 | else 128 | return false; 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /Scripts/SampleFa.cs: -------------------------------------------------------------------------------- 1 | //############################################################################## 2 | //# # 3 | //# Unity Farsi # 4 | //# # 5 | //# @Copyright (C) 2014 By Mehran M. Spitmaan # 6 | //# from Azdaa (mehran.m.spitman@gmail.com) # 7 | //# # 8 | //# # 9 | //# This program is free software: you can redistribute it and/or modify # 10 | //# it under the terms of the GNU General Public License as published by # 11 | //# the Free Software Foundation, either version 3 of the License, or # 12 | //# (at your option) any later version. # 13 | //# # 14 | //# This program is distributed in the hope that it will be useful, # 15 | //# but WITHOUT ANY WARRANTY; without even the implied warranty of # 16 | //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 17 | //# GNU General Public License for more details. # 18 | //# # 19 | //############################################################################## 20 | 21 | using UnityEngine; 22 | using System.Collections; 23 | 24 | public class SampleFa : MonoBehaviour { 25 | 26 | public GUIText gTEXT; 27 | public string test; 28 | public GUISkin guiskinn; 29 | // 30 | void Awake() 31 | { 32 | gTEXT = GameObject.Find("GUI Text").GetComponent (); 33 | } 34 | void OnGUI() { 35 | test = GUI.TextField(new Rect(10, 10, 200, 20), test, 25); 36 | } 37 | public string sample; 38 | 39 | 40 | // Here is Some Example of usage 41 | // Do not need to use any othe namespace. System.Collections is enough!! 42 | // در اینجا مثال هایی از نحوه استفاده را مشاهده خواهید کرد 43 | // نیاز به افزودن namespace جدید نمی باشد. 44 | void Update () { 45 | 46 | if (Input.inputString != "") 47 | { 48 | int asciiCode = System.Convert.ToInt32(Input.inputString[0]); 49 | Debug.Log(asciiCode); 50 | } 51 | 52 | // string sample = "این یک نمونه است!"; 53 | // string faSample = sample.faConvert (); 54 | // Debug.Log (sample.faConvert ()); 55 | // Debug.Log(Fa.faConvert(sample)); 56 | // Debug.Log ("این یک نمونه است!".faConvert ()); 57 | // Debug.Log(Fa.faConvert("این یک نمونه است!")); 58 | // 59 | //// Debug.Log (faSample.faConvert ()); // DO NOT CONVERT A CONVERTED STRING!!!!!!!! 60 | // 61 | // faSample = "این یک نمونه حاوی کلمات English است! همراه با پشتیبانی از حروف عربی - ي - ئ - ؤ - إ - أ - ة - ك"; 62 | // //faSample = "ك بك كب بكب - ة مة - ؤ مؤ - أذان - إذن - ي بي يب بيب - ئ بئ ئب بئب"; 63 | // 64 | // Debug.Log (faSample.faConvert ()); 65 | // 66 | // gTEXT.text = faSample.faConvert(); 67 | 68 | sample = test.faConvert(); 69 | gTEXT.text = ""+sample; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /UnityFarsi.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Spitmaan/Unity3DFarsi/40d43369d0df332fb0f0932d6fb46c21d88ed0bb/UnityFarsi.unity -------------------------------------------------------------------------------- /UnityFarsi.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Spitmaan/Unity3DFarsi/40d43369d0df332fb0f0932d6fb46c21d88ed0bb/UnityFarsi.unitypackage --------------------------------------------------------------------------------