Beispiel #1
0
        public void Create()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition enWS = wsManager.Create("en-Latn-US-fonipa");

            Assert.That(enWS.Abbreviation, Is.EqualTo("Eng"));
            Assert.That(enWS.Language, Is.EqualTo((LanguageSubtag)"en"));
            Assert.That(enWS.Script, Is.EqualTo((ScriptSubtag)"Latn"));
            Assert.That(enWS.Region, Is.EqualTo((RegionSubtag)"US"));
            Assert.That(enWS.Variants, Is.EqualTo(new VariantSubtag[] { "fonipa" }));
            Assert.That(enWS.DefaultFontName, Is.EqualTo("Charis SIL"));
            Assert.That(enWS.DefaultCollation.ValueEquals(new IcuRulesCollationDefinition("standard")), Is.True);
            Assert.That(enWS.LanguageTag, Is.EqualTo("en-US-fonipa"));
            Assert.That(string.IsNullOrEmpty(enWS.WindowsLcid), Is.True);

            CoreWritingSystemDefinition chWS = wsManager.Create("zh-CN");

            Assert.That(chWS.Abbreviation, Is.EqualTo("Chi"));
            Assert.That(chWS.Language, Is.EqualTo((LanguageSubtag)"zh"));
            Assert.That(chWS.Script, Is.EqualTo((ScriptSubtag)"Hans"));
            Assert.That(chWS.Region, Is.EqualTo((RegionSubtag)"CN"));
            Assert.That(chWS.DefaultFontName, Is.EqualTo("Charis SIL"));
            Assert.That(chWS.DefaultCollation.ValueEquals(new SystemCollationDefinition {
                LanguageTag = "zh-CN"
            }), Is.True);
        }
Beispiel #2
0
        public void InterpretChrp()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition ws = wsManager.Create("en-US");
            var chrp = new LgCharRenderProps
            {
                ws         = ws.Handle,
                szFaceName = new ushort[32],
                dympHeight = 10000,
                ssv        = (int)FwSuperscriptVal.kssvSuper
            };

            MarshalEx.StringToUShort("<default font>", chrp.szFaceName);
            ws.InterpretChrp(ref chrp);

            Assert.AreEqual(ws.DefaultFontName, MarshalEx.UShortToString(chrp.szFaceName));
            Assert.AreEqual(10000 / 3, chrp.dympOffset);
            Assert.AreEqual((10000 * 2) / 3, chrp.dympHeight);
            Assert.AreEqual((int)FwSuperscriptVal.kssvOff, chrp.ssv);

            chrp.ssv        = (int)FwSuperscriptVal.kssvSub;
            chrp.dympHeight = 10000;
            chrp.dympOffset = 0;
            ws.InterpretChrp(ref chrp);

            Assert.AreEqual(-(10000 / 5), chrp.dympOffset);
            Assert.AreEqual((10000 * 2) / 3, chrp.dympHeight);
            Assert.AreEqual((int)FwSuperscriptVal.kssvOff, chrp.ssv);
            wsManager.Save();
        }
Beispiel #3
0
        public void CreateAudioWritingSystemVariantFirst()
        {
            var wsManager = new WritingSystemManager();

            CoreWritingSystemDefinition newWs = wsManager.Create(WellKnownSubtags.UnlistedLanguage, null, null, Enumerable.Empty <VariantSubtag>());

            Assert.DoesNotThrow(() =>
            {
                newWs.Variants.Add(WellKnownSubtags.AudioPrivateUse);
                newWs.Script = WellKnownSubtags.AudioScript;
            });
        }
Beispiel #4
0
        public void Load_Nonempty()
        {
            CoreWritingSystemDefinition ws1 = m_wsManager.Create("en");

            ws1.CharacterSets.Add(new CharacterSetDefinition("main")
            {
                Characters = { "e", "f", "g", "h" }
            });
            ws1.CharacterSets.Add(new CharacterSetDefinition("numeric")
            {
                Characters = { "4", "5" }
            });
            ws1.CharacterSets.Add(new CharacterSetDefinition("punctuation")
            {
                Characters = { ",", "!", "*" }
            });
            ValidCharacters validChars  = ValidCharacters.Load(ws1);
            var             validCharsW = new ValidCharsWrapper(validChars);

            Assert.AreEqual(4, validCharsW.WordFormingCharacters.Count);
            Assert.IsTrue(validCharsW.WordFormingCharacters.Contains("e"));
            Assert.IsTrue(validCharsW.WordFormingCharacters.Contains("f"));
            Assert.IsTrue(validCharsW.WordFormingCharacters.Contains("g"));
            Assert.IsTrue(validCharsW.WordFormingCharacters.Contains("h"));
            Assert.AreEqual(2, validCharsW.NumericCharacters.Count);
            Assert.IsTrue(validCharsW.NumericCharacters.Contains("4"));
            Assert.IsTrue(validCharsW.NumericCharacters.Contains("5"));
            Assert.AreEqual(3, validCharsW.OtherCharacters.Count);
            Assert.IsTrue(validCharsW.OtherCharacters.Contains(","));
            Assert.IsTrue(validCharsW.OtherCharacters.Contains("!"));
            Assert.IsTrue(validCharsW.OtherCharacters.Contains("*"));
            CoreWritingSystemDefinition ws2 = m_wsManager.Create("en");

            validChars.SaveTo(ws2);
            Assert.That(ws1.ValueEquals(ws2), Is.True);
        }