Esempio n. 1
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();
        }
Esempio n. 2
0
        public void get_IsWordForming()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition ws = wsManager.Set("zh-CN");

            ws.CharacterSets.Add(new CharacterSetDefinition("main")
            {
                Characters = { "e", "f", "g", "h", "'" }
            });
            ws.CharacterSets.Add(new CharacterSetDefinition("numeric")
            {
                Characters = { "4", "5" }
            });
            ws.CharacterSets.Add(new CharacterSetDefinition("punctuation")
            {
                Characters = { ",", "!", "*" }
            });
            Assert.IsTrue(ws.get_IsWordForming('\''));
            Assert.IsFalse(ws.get_IsWordForming('"'));

            ws.CharacterSets.Clear();
            Assert.IsFalse(ws.get_IsWordForming('\''));
            Assert.IsFalse(ws.get_IsWordForming('"'));
            wsManager.Save();
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public void GetStrFromWs()
        {
            var wsManager = new WritingSystemManager();

            Assert.IsNull(wsManager.GetStrFromWs(1));
            CoreWritingSystemDefinition ws = wsManager.Set("en-US");

            Assert.AreEqual("en-US", wsManager.GetStrFromWs(ws.Handle));
            wsManager.Save();
        }
Esempio n. 5
0
        public void GetWsFromStr()
        {
            var wsManager = new WritingSystemManager();

            Assert.AreEqual(0, wsManager.GetWsFromStr("en-US"));
            CoreWritingSystemDefinition ws = wsManager.Set("en-US");

            Assert.AreEqual(ws.Handle, wsManager.GetWsFromStr("en-US"));
            wsManager.Save();
        }
Esempio n. 6
0
        public void get_EngineOrNull()
        {
            var wsManager = new WritingSystemManager();

            Assert.IsNull(wsManager.get_EngineOrNull(1));
            CoreWritingSystemDefinition ws = wsManager.Set("en-US");

            Assert.AreSame(ws, wsManager.get_EngineOrNull(ws.Handle));
            wsManager.Save();
        }
Esempio n. 7
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;
            });
        }
Esempio n. 8
0
        public void GetOrSetWorksRepeatedlyOnIdNeedingModification()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition ws;

            Assert.That(wsManager.GetOrSet("en-Latn", out ws), Is.False);
            Assert.That(ws.Id, Is.EqualTo("en"));
            CoreWritingSystemDefinition ws2;

            Assert.That(wsManager.GetOrSet("en-Latn", out ws2), Is.True);
            Assert.That(ws2, Is.EqualTo(ws));

            // By the way it should work the same for one where it does not have to modify the ID.
            Assert.That(wsManager.GetOrSet("fr", out ws), Is.False);
            Assert.That(wsManager.GetOrSet("fr", out ws), Is.True);
        }
Esempio n. 9
0
        public void get_Engine()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition enWs   = wsManager.Set("en-US");
            ILgWritingSystem            enLgWs = wsManager.get_Engine("en-US");

            Assert.AreSame(enWs, enLgWs);

            Assert.IsFalse(wsManager.Exists("en-Latn-US"));
            // this should create a new writing system, since it doesn't exist
            ILgWritingSystem enUsLgWs = wsManager.get_Engine("en-US-fonipa");

            Assert.IsTrue(wsManager.Exists("en-US-fonipa"));
            Assert.IsTrue(wsManager.Exists(enUsLgWs.Handle));
            CoreWritingSystemDefinition enUsWs = wsManager.Get("en-US-fonipa");

            Assert.AreSame(enUsWs, enUsLgWs);
            wsManager.Save();
        }
Esempio n. 10
0
        public void SerializeDeserialize()
        {
            string storePath = PrepareTempStore("Store");

            var projectSettingsStore = new TestSettingsStore();
            var userSettingsStore    = new TestSettingsStore();
            // serialize
            var wsManager = new WritingSystemManager(new TestCoreLdmlInFolderWritingSystemRepository(storePath, projectSettingsStore, userSettingsStore));
            CoreWritingSystemDefinition ws = wsManager.Set("en-US");

            ws.SpellCheckingId = "en_US";
            ws.MatchedPairs.Add(new MatchedPair("(", ")", true));
            ws.WindowsLcid = 0x409.ToString(CultureInfo.InvariantCulture);
            ws.CharacterSets.Add(new CharacterSetDefinition("main")
            {
                Characters = { "a", "b", "c" }
            });
            ws.LegacyMapping = "legacy mapping";
            wsManager.Save();

            // deserialize
            wsManager = new WritingSystemManager(new TestCoreLdmlInFolderWritingSystemRepository(storePath, projectSettingsStore, userSettingsStore));
            Assert.IsTrue(wsManager.Exists("en-US"));
            ws = wsManager.Get("en-US");
            Assert.AreEqual("Eng", ws.Abbreviation);
            Assert.AreEqual("English", ws.Language.Name);
            Assert.AreEqual("en_US", ws.SpellCheckingId);
            Assert.AreEqual("United States", ws.Region.Name);
            Assert.That(ws.MatchedPairs, Is.EqualTo(new[] { new MatchedPair("(", ")", true) }));
            Assert.AreEqual(0x409.ToString(CultureInfo.InvariantCulture), ws.WindowsLcid);
            Assert.That(ws.CharacterSets.Count, Is.EqualTo(1));
            Assert.That(ws.CharacterSets[0].ValueEquals(new CharacterSetDefinition("main")
            {
                Characters = { "a", "b", "c" }
            }), Is.True);
            Assert.AreEqual("legacy mapping", ws.LegacyMapping);
            wsManager.Save();
        }
Esempio n. 11
0
 public void FixtureSetup()
 {
     m_wsManager = new WritingSystemManager();
 }