Esempio n. 1
0
        static ScriptLang _(string fullname, string shortname, params UnicodeLangBits[] langBits)
        {
            if (s_registeredScriptTags.ContainsKey(shortname))
            {
                if (shortname == "kana")
                {
                    //***
                    //Hiragana and Katakana
                    //both have same short name "kana"
                    return(new ScriptLang(fullname, shortname, s_registerNames[shortname]));
                }
                else
                {
                    //errors
                    throw new System.NotSupportedException();
                }
            }
            else
            {
                int internalName = s_registerNames.Count;
                s_registerNames[shortname] = internalName;
                var scriptLang = new ScriptLang(fullname, shortname, internalName);
                s_registeredScriptTags.Add(shortname, scriptLang);
                //
                s_registerScriptFromFullNames[fullname] = scriptLang;

                //also register unicode langs with the script lang

                for (int i = langBits.Length - 1; i >= 0; --i)
                {
                    UnicodeRangeInfo unicodeRange = langBits[i].ToUnicodeRangeInfo();
                    if (!s_unicodeLangToScriptLang.ContainsKey(unicodeRange.StartAt))
                    {
                        s_unicodeLangToScriptLang.Add(unicodeRange.StartAt, new UnicodeRangeMapWithScriptLang(langBits[i], scriptLang));
                    }
                    else
                    {
                    }
                }


                if (langBits.Length > 0)
                {
                    s_registeredScriptTagsToUnicodeLangBits.Add(shortname, langBits);
                }


                return(scriptLang);
            }
        }
Esempio n. 2
0
        public static bool TryGetScriptLang(char c, out ScriptLang scLang)
        {
            foreach (var kp in s_unicodeLangToScriptLang)
            {
                if (kp.Key > c)
                {
                    scLang = null;
                    return(false);
                }
                else
                {
                    if (kp.Value.IsInRange(c))
                    {
                        //found
                        scLang = kp.Value.scLang;
                        return(true);
                    }
                }
            }

            scLang = null;
            return(false);
        }
Esempio n. 3
0
 public UnicodeRangeMapWithScriptLang(UnicodeLangBits unicodeRangeBits, ScriptLang scLang)
 {
     this.scLang           = scLang;
     this.unicodeRangeBits = unicodeRangeBits;
 }