Inheritance: IWritingSystemManager
コード例 #1
0
		public void SerializeDeserialize()
		{
			string storePath = PrepareTempStore("Store");

			// serialize
			var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
			var ws = wsManager.Set("en-US");
			ws.SpellCheckingId = "en-US";
			ws.MatchedPairs = "matched pairs";
			((ILegacyWritingSystemDefinition)ws).WindowsLcid = 0x409.ToString(CultureInfo.InvariantCulture);
			ws.ValidChars = "valid characters";
			ws.LegacyMapping = "legacy mapping";
			wsManager.Save();

			// deserialize
			wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
			Assert.IsTrue(wsManager.Exists("en-US"));
			ws = wsManager.Get("en-US");
			Assert.AreEqual("Eng", ws.Abbreviation);
			Assert.AreEqual("English", ws.LanguageSubtag.Name);
			Assert.AreEqual("en-US", ws.SpellCheckingId);
			Assert.AreEqual("United States", ws.RegionSubtag.Name);
			Assert.AreEqual("matched pairs", ws.MatchedPairs);
			Assert.AreEqual(0x409.ToString(CultureInfo.InvariantCulture), ((ILegacyWritingSystemDefinition)ws).WindowsLcid);
			Assert.AreEqual("valid characters", ws.ValidChars);
			Assert.AreEqual("legacy mapping", ws.LegacyMapping);
			Assert.AreEqual("eng", ws.ISO3);
			wsManager.Save();
		}
コード例 #2
0
        public void InterpretChrp()
        {
            var            wsManager = new PalasoWritingSystemManager();
            IWritingSystem 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();
        }
コード例 #3
0
        public void GlobalStore_WritingSystemsToIgnore()
        {
            string storePath1      = PrepareTempStore("Store1");
            string storePath2      = PrepareTempStore("Store2");
            string globalStorePath = PrepareTempStore("GlobalStore");

            var globalStore = new GlobalFileWritingSystemStore(globalStorePath);
            var wsManager   = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
            var ws = wsManager.Set("en-US");

            ws.SpellCheckingId = "id1";
            wsManager.Save();

            Thread.Sleep(1000);

            wsManager = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath2, globalStore), globalStore);
            ws = wsManager.Set("en-US");
            ws.SpellCheckingId = "id2";
            wsManager.Save();

            wsManager = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
            IEnumerable <IWritingSystem> sharedWss = wsManager.CheckForNewerGlobalWritingSystems();

            Assert.AreEqual(1, sharedWss.Count());
            Assert.AreEqual("en-US", sharedWss.First().Id);
            ws = wsManager.Get("en-US");
            Assert.AreEqual("id1", ws.SpellCheckingId);
            wsManager.Save();

            wsManager = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
            sharedWss = wsManager.CheckForNewerGlobalWritingSystems();
            Assert.AreEqual(0, sharedWss.Count());
            wsManager.Save();

            Thread.Sleep(1000);

            wsManager = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath2, globalStore), globalStore);
            ws = wsManager.Get("en-US");
            ws.LegacyMapping = "encoding converter";
            wsManager.Save();

            wsManager = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
            ws = wsManager.Get("en-US");
            Assert.IsNullOrEmpty(ws.LegacyMapping);
            sharedWss = wsManager.CheckForNewerGlobalWritingSystems();
            Assert.AreEqual(1, sharedWss.Count());
            IWritingSystem sharedWs = sharedWss.First();

            Assert.AreEqual("en-US", sharedWs.Id);
            wsManager.Replace(sharedWs);
            wsManager.Save();
            ws = wsManager.Get("en-US");
            Assert.AreEqual("encoding converter", ws.LegacyMapping);
        }
コード例 #4
0
        public void get_RendererFromChrp_Graphite()
        {
            using (GraphicsManager gm = new GraphicsManager(new Form()))
            {
                gm.Init(1.0f);
                try
                {
                    var wsManager = new PalasoWritingSystemManager();
                    // by default Graphite is disabled
                    IWritingSystem ws   = wsManager.Set("en-US");
                    var            chrp = new LgCharRenderProps {
                        ws = ws.Handle, szFaceName = new ushort[32]
                    };
                    MarshalEx.StringToUShort("Charis SIL", chrp.szFaceName);
                    IRenderEngine engine = wsManager.get_RendererFromChrp(gm.VwGraphics, ref chrp);
                    Assert.IsNotNull(engine);
                    Assert.AreSame(wsManager, engine.WritingSystemFactory);
                    Assert.IsInstanceOf(typeof(UniscribeEngine), engine);

                    ws.IsGraphiteEnabled = true;
                    engine = wsManager.get_RendererFromChrp(gm.VwGraphics, ref chrp);
                    Assert.IsNotNull(engine);
                    Assert.AreSame(wsManager, engine.WritingSystemFactory);
                    Assert.IsInstanceOf(typeof(FwGrEngine), engine);
                    wsManager.Save();
                }
                finally
                {
                    gm.Uninit();
                }
            }
        }
コード例 #5
0
        public void SerializeDeserialize()
        {
            string storePath = PrepareTempStore("Store");

            // serialize
            var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
            var ws        = wsManager.Set("en-US");

            ws.SpellCheckingId = "en-US";
            ws.MatchedPairs    = "matched pairs";
            ws.LCID            = 0x409;
            ws.ValidChars      = "valid characters";
            ws.LegacyMapping   = "legacy mapping";
            wsManager.Save();

            // deserialize
            wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
            Assert.IsTrue(wsManager.Exists("en-US"));
            ws = wsManager.Get("en-US");
            Assert.AreEqual("Eng", ws.Abbreviation);
            Assert.AreEqual("English", ws.LanguageSubtag.Name);
            Assert.AreEqual("en-US", ws.SpellCheckingId);
            Assert.AreEqual("United States", ws.RegionSubtag.Name);
            Assert.AreEqual("matched pairs", ws.MatchedPairs);
            Assert.AreEqual(0x409, ws.LCID);
            Assert.AreEqual("valid characters", ws.ValidChars);
            Assert.AreEqual("legacy mapping", ws.LegacyMapping);
            Assert.AreEqual("eng", ws.ISO3);
            wsManager.Save();
        }
コード例 #6
0
        public void get_CharPropEngine()
        {
            var            wsManager = new PalasoWritingSystemManager();
            IWritingSystem ws        = wsManager.Set("zh-CN");

            ws.ValidChars = "<?xml version=\"1.0\" encoding=\"utf-16\"?>"
                            + "<ValidCharacters><WordForming>e\uFFFCf\uFFFCg\uFFFCh\uFFFC'</WordForming>"
                            + "<Numeric>4\uFFFC5</Numeric>"
                            + "<Other>,\uFFFC!\uFFFC*</Other>"
                            + "</ValidCharacters>";
            ILgCharacterPropertyEngine cpe = wsManager.get_CharPropEngine(ws.Handle);

            Assert.IsNotNull(cpe);
            Assert.IsTrue(cpe.get_IsWordForming('\''));
            Assert.IsFalse(cpe.get_IsWordForming('"'));
            Assert.AreEqual(0x0804, cpe.Locale);

            ws.ValidChars = null;
            cpe           = wsManager.get_CharPropEngine(ws.Handle);
            Assert.IsNotNull(cpe);
            Assert.IsFalse(cpe.get_IsWordForming('\''));
            Assert.IsFalse(cpe.get_IsWordForming('"'));
            Assert.AreEqual(0x0804, cpe.Locale);
            wsManager.Save();
        }
コード例 #7
0
        public void GetValidLangCodeForNewLang()
        {
            string storePath       = PrepareTempStore("Store");
            string globalStorePath = PrepareTempStore("GlobalStore");

            EnsureDirectoryIsEmpty(storePath);
            EnsureDirectoryIsEmpty(globalStorePath);

            var globalStore = new GlobalFileWritingSystemStore(globalStorePath);
            var wsManager   = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath, globalStore), globalStore);

            Assert.AreEqual("qip", wsManager.GetValidLangTagForNewLang("Qipkey"));
            Assert.AreEqual("sn", wsManager.GetValidLangTagForNewLang("Sn"));
            Assert.AreEqual("eba", wsManager.GetValidLangTagForNewLang("\u00CBbashlish"));             // \u00CB == E with diacritic
            Assert.AreEqual("eee", wsManager.GetValidLangTagForNewLang("\u00CB\u00CB\u00CBlish"));
            // \u00CB == E with diacritic
            Assert.AreEqual("aaa", wsManager.GetValidLangTagForNewLang("U"));

            LanguageSubtag subtag = new LanguageSubtag("qip", "Qipkey", true, null);
            IWritingSystem newWs  = wsManager.Create(subtag, null, null, null);

            wsManager.Set(newWs);
            Assert.AreEqual("aaa", wsManager.GetValidLangTagForNewLang("Qipsing"), "code for 'qip' should already be taken");

            subtag = new LanguageSubtag("aaa", "Qipsing", true, null);
            newWs  = wsManager.Create(subtag, null, null, null);
            wsManager.Set(newWs);
            Assert.AreEqual("aab", wsManager.GetValidLangTagForNewLang("Qipwest"),
                            "code for 'qip' should already be taken twice");

            // ENHANCE: Ideally, we would want to test incrementing the middle and first character,
            // but that would require at least 677 (26^2 + 1) writing systems be created.
        }
コード例 #8
0
		public void TestTsStringWrapperRoundTrip(string str1, string namedStyle1, string str2, string namedStyle2)
		{
			var wsFact = new PalasoWritingSystemManager();
			ITsStrBldr bldr = TsStrBldrClass.Create();
			ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();
			try
			{
				wsFact.get_Engine("en");
				ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, wsFact.GetWsFromStr("en"));
				ttpBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, namedStyle1);
				bldr.Replace(bldr.Length, bldr.Length, str1, ttpBldr.GetTextProps());
				if (namedStyle2 != null && str2 != null)
				{
					ttpBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, namedStyle2);
					bldr.Replace(bldr.Length, bldr.Length, str2, ttpBldr.GetTextProps());
				}
				var tsString1 = bldr.GetString();

				var strWrapper = new TsStringWrapper(tsString1, wsFact);

				var tsString2 = strWrapper.GetTsString(wsFact);

				Assert.AreEqual(tsString1.Text, tsString2.Text);
			}
			finally
			{
				Marshal.ReleaseComObject(ttpBldr);
				Marshal.ReleaseComObject(bldr);
			}
		}
コード例 #9
0
        public void FieldWorksExtensionsAreNotDuplicatedOnRoundTrip()
        {
            var storePath = PrepareTempStore("Store");

            // serialize
            var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
            var ws        = wsManager.Set("en-US");

            ws.SpellCheckingId = "en-US";
            ws.MatchedPairs    = "matched pairs";
            ((ILegacyWritingSystemDefinition)ws).WindowsLcid = 0x409.ToString(CultureInfo.InvariantCulture);
            ws.ValidChars    = "valid characters";
            ws.LegacyMapping = "legacy mapping";
            wsManager.Save();

            // deserialize
            wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
            Assert.IsTrue(wsManager.Exists("en-US"), "broken before SUT.");
            ws = wsManager.Get("en-US");
            Assert.AreEqual("valid characters", ws.ValidChars, "broken before SUT");
            //change the valid chars data and save back out, this was duplicating in LT-15048
            ws.ValidChars = "more valid characters";
            wsManager.Save();

            var xmlDoc = new XmlDocument();

            xmlDoc.Load(Path.Combine(storePath, "en-US.ldml"));
            Assert.AreEqual(1, xmlDoc.SelectNodes("//special/*[local-name()='validChars']").Count, "Special fw elements were duplicated");
            Assert.AreEqual(1, xmlDoc.SelectNodes("//special/*[local-name()='validChars' and @value='more valid characters']").Count, "special fw changes not saved");
        }
コード例 #10
0
ファイル: IVwCacheDaTests.cs プロジェクト: bbriggs/FieldWorks
		public void TestSetup()
		{
			RegistryHelper.CompanyName = "SIL";
			m_ISilDataAccess = VwCacheDaClass.Create();
			ILgWritingSystemFactory wsf = new PalasoWritingSystemManager();
			m_ISilDataAccess.WritingSystemFactory = wsf;
			m_IVwCacheDa = (IVwCacheDa)m_ISilDataAccess;
		}
コード例 #11
0
        public void TestSetup()
        {
            RegistryHelper.CompanyName = "SIL";
            m_ISilDataAccess           = VwCacheDaClass.Create();
            ILgWritingSystemFactory wsf = new PalasoWritingSystemManager();

            m_ISilDataAccess.WritingSystemFactory = wsf;
            m_IVwCacheDa = (IVwCacheDa)m_ISilDataAccess;
        }
コード例 #12
0
        public void get_EngineOrNull()
        {
            var wsManager = new PalasoWritingSystemManager();

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

            Assert.AreSame(ws, wsManager.get_EngineOrNull(ws.Handle));
            wsManager.Save();
        }
コード例 #13
0
        public void GetWsFromStr()
        {
            var wsManager = new PalasoWritingSystemManager();

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

            Assert.AreEqual(ws.Handle, wsManager.GetWsFromStr("en-US"));
            wsManager.Save();
        }
コード例 #14
0
        public void GetStrFromWs()
        {
            var wsManager = new PalasoWritingSystemManager();

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

            Assert.AreEqual("en-US", wsManager.GetStrFromWs(ws.Handle));
            wsManager.Save();
        }
コード例 #15
0
        public void GetOrSetWorksRepeatedlyOnIdNeedingModification()
        {
            var            wsManager = new PalasoWritingSystemManager();
            IWritingSystem ws;

            Assert.That(wsManager.GetOrSet("x-kal", out ws), Is.False);
            Assert.That(ws.Id, Is.EqualTo("qaa-x-kal"));
            IWritingSystem ws2;

            Assert.That(wsManager.GetOrSet("x-kal", 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);
        }
コード例 #16
0
        public void GlobalStore()
        {
            string storePath1      = PrepareTempStore("Store1");
            string storePath2      = PrepareTempStore("Store2");
            string globalStorePath = PrepareTempStore("GlobalStore");

            var globalStore = new GlobalFileWritingSystemStore(globalStorePath);
            var wsManager   = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
            var ws = wsManager.Set("en-US");

            ws.SpellCheckingId = "id1";
            wsManager.Save();
            Assert.IsTrue(File.Exists(Path.Combine(storePath1, "en-US.ldml")));
            Assert.IsTrue(File.Exists(Path.Combine(globalStorePath, "en-US.ldml")));

            Thread.Sleep(1000);

            DateTime lastModified = File.GetLastWriteTime(Path.Combine(globalStorePath, "en-US.ldml"));

            wsManager = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath2, globalStore), globalStore);
            ws = wsManager.Set("en-US");
            ws.SpellCheckingId = "id2";
            wsManager.Save();
            Assert.Less(lastModified, File.GetLastWriteTime(Path.Combine(globalStorePath, "en-US.ldml")));

            lastModified = File.GetLastWriteTime(Path.Combine(storePath1, "en-US.ldml"));
            wsManager    = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
            ws = wsManager.Get("en-US");
            Assert.AreEqual("id1", ws.SpellCheckingId);
            IEnumerable <IWritingSystem> sharedWss = wsManager.CheckForNewerGlobalWritingSystems();

            Assert.AreEqual(1, sharedWss.Count());
            IWritingSystem sharedWs = sharedWss.First();

            Assert.AreEqual("en-US", sharedWs.Id);
            wsManager.Replace(sharedWs);
            wsManager.Save();

            ws = wsManager.Get("en-US");
            Assert.AreEqual("id2", ws.SpellCheckingId);
            Assert.Less(lastModified, File.GetLastWriteTime(Path.Combine(storePath1, "en-US.ldml")));
        }
コード例 #17
0
		public void LanguageSubtag_newWS()
		{
			var wsManager = new PalasoWritingSystemManager();
			using (var langSetup = new LanguageSetup())
			{
				langSetup.WritingSystemManager = wsManager;
				langSetup.StartedInModifyState = false;
				langSetup.LanguageName = "Monkey";
				LanguageSubtag subtag = langSetup.LanguageSubtag;
				Assert.AreEqual("mon", subtag.Code);

				LanguageSubtag newSubtag = new LanguageSubtag("mon", "Moniker", true, null);
				IWritingSystem newWs = wsManager.Create(newSubtag, null, null, null);
				wsManager.Set(newWs);
				subtag = langSetup.LanguageSubtag;
				Assert.AreEqual("aaa", subtag.Code, "Language code 'mon' should already be in use");
			}
		}
コード例 #18
0
        public void get_Engine()
        {
            var              wsManager = new PalasoWritingSystemManager();
            IWritingSystem   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-Latn-US");

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

            Assert.AreSame(enUsWs, enUsLgWs);
            wsManager.Save();
        }
コード例 #19
0
        public void CreateAudioWritingSystemVariantFirst()
        {
            string storePath       = PrepareTempStore("Store");
            string globalStorePath = PrepareTempStore("GlobalStore");

            EnsureDirectoryIsEmpty(storePath);
            EnsureDirectoryIsEmpty(globalStorePath);

            var globalStore = new GlobalFileWritingSystemStore(globalStorePath);
            var wsManager   = new PalasoWritingSystemManager(
                new LocalFileWritingSystemStore(storePath, globalStore), globalStore);

            IWritingSystem newWs = wsManager.Create(new LanguageSubtag("qaa", "Unknown", true, null), null, null, null);

            Assert.DoesNotThrow(() =>
            {
                newWs.VariantSubtag = new VariantSubtag("x-audio", "Audio", false, null);
                newWs.ScriptSubtag  = new ScriptSubtag("Zxxx", "Audio", false);
            });
        }
コード例 #20
0
        public void Create()
        {
            var            wsManager = new PalasoWritingSystemManager();
            IWritingSystem enWs      = wsManager.Create("en-Latn-US-fonipa");

            Assert.AreEqual("Eng", enWs.Abbreviation);
            Assert.AreEqual("English", enWs.LanguageSubtag.Name);
            Assert.AreEqual("Latin", enWs.ScriptSubtag.Name);
            Assert.AreEqual("United States", enWs.RegionSubtag.Name);
            Assert.AreEqual("International Phonetic Alphabet", enWs.VariantSubtag.Name);
            Assert.AreEqual(null, ((ILegacyWritingSystemDefinition)enWs).WindowsLcid);

            IWritingSystem chWs = wsManager.Create("zh-CN");

            Assert.AreEqual("Man", chWs.Abbreviation);
            Assert.AreEqual("Mandarin Chinese", chWs.LanguageSubtag.Name);
            Assert.AreEqual("China", chWs.RegionSubtag.Name);
            Assert.AreEqual("Charis SIL", chWs.DefaultFontName);
            Assert.AreEqual(WritingSystemDefinition.SortRulesType.OtherLanguage, chWs.SortUsing);
            Assert.AreEqual("zh-CN", chWs.SortRules);
            wsManager.Save();
        }
コード例 #21
0
        public void Create()
        {
            var            wsManager = new PalasoWritingSystemManager();
            IWritingSystem enWs      = wsManager.Create("en-Latn-US-fonipa");

            Assert.AreEqual("Eng", enWs.Abbreviation);
            Assert.AreEqual("English", enWs.LanguageSubtag.Name);
            Assert.AreEqual("Latin", enWs.ScriptSubtag.Name);
            Assert.AreEqual("United States", enWs.RegionSubtag.Name);
            Assert.AreEqual("International Phonetic Alphabet", enWs.VariantSubtag.Name);
            // On Linux InstalledInputLanguages or DefaultInputLanguage doesn't do anything sensible.
            // see: https://bugzilla.novell.com/show_bug.cgi?id=613014
            Assert.AreEqual(MiscUtils.IsUnix ? 0x409 : InputLanguage.DefaultInputLanguage.Culture.LCID, enWs.LCID);

            IWritingSystem chWs = wsManager.Create("zh-CN");

            Assert.AreEqual("Man", chWs.Abbreviation);
            Assert.AreEqual("Mandarin Chinese", chWs.LanguageSubtag.Name);
            Assert.AreEqual("China", chWs.RegionSubtag.Name);
            Assert.AreEqual("Charis SIL", chWs.DefaultFontName);
            Assert.AreEqual(WritingSystemDefinition.SortRulesType.OtherLanguage, chWs.SortUsing);
            Assert.AreEqual("zh-CN", chWs.SortRules);
            wsManager.Save();
        }
コード例 #22
0
ファイル: FwUtils.cs プロジェクト: bbriggs/FieldWorks
		/// <summary>
		/// Whenever possible use this in place of new PalasoWritingSystemManager.
		/// It sets the TemplateFolder, which unfortunately the constructor cannot do because
		/// the direction of our dependencies does not allow it to reference FwUtils and access FwDirectoryFinder.
		/// </summary>
		/// <returns></returns>
		public static PalasoWritingSystemManager CreateWritingSystemManager()
		{
			var result = new PalasoWritingSystemManager();
			result.TemplateFolder = FwDirectoryFinder.TemplateDirectory;
			return result;
		}
コード例 #23
0
		private static void RetrieveDefaultWritingSystemsFromLift(string liftPath, out IWritingSystem wsVern,
			out IWritingSystem wsAnalysis)
		{
			using (var liftReader = new StreamReader(liftPath, Encoding.UTF8))
			{
				string vernWsId, analysisWsId;
				using (var reader = XmlReader.Create(liftReader))
					RetrieveDefaultWritingSystemIdsFromLift(reader, out vernWsId, out analysisWsId);
				var wsManager = new PalasoWritingSystemManager(new GlobalFileWritingSystemStore());
				wsManager.GetOrSet(vernWsId, out wsVern);
				wsManager.GetOrSet(analysisWsId, out wsAnalysis);
			}
		}
コード例 #24
0
		public void Persistence()
		{
			var wsManager = new PalasoWritingSystemManager();
			IWritingSystem enWs;
			wsManager.GetOrSet("en", out enWs);
			int wsEng = enWs.Handle;

			IWritingSystem frWs;
			wsManager.GetOrSet("fr", out frWs);
			int wsFrn = frWs.Handle;

			IWritingSystem deWs;
			wsManager.GetOrSet("de", out deWs);
			int wsGer = deWs.Handle;

			InterlinLineChoices choices = new InterlinLineChoices(m_lp, wsFrn, wsEng);
			MakeStandardState(choices);
			string persist = choices.Persist(wsManager);
			choices = InterlinLineChoices.Restore(persist, wsManager, m_lp, wsFrn, wsEng);

			Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[4].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[5].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[6].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[7].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[8].Flid);

			// Check writing systems assigned by default.
			Assert.AreEqual(wsFrn, choices[0].WritingSystem);
			Assert.AreEqual(wsEng, choices[5].WritingSystem);
			Assert.AreEqual(wsFrn, choices[2].WritingSystem);

			choices = new EditableInterlinLineChoices(m_lp, 0, wsEng);
			MakeStandardState(choices);
			choices.Add(InterlinLineChoices.kflidLexGloss, wsGer);
			Assert.AreEqual(InterlinLineChoices.kflidWord, choices[0].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidMorphemes, choices[1].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexEntries, choices[2].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[3].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexGloss, choices[4].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLexPos, choices[5].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidWordGloss, choices[6].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidWordPos, choices[7].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidFreeTrans, choices[8].Flid);
			Assert.AreEqual(InterlinLineChoices.kflidLitTrans, choices[9].Flid);

			Assert.AreEqual(wsGer, choices[4].WritingSystem);
		}
コード例 #25
0
		public void FieldWorksExtensionsAreNotDuplicatedOnRoundTrip()
		{
			var storePath = PrepareTempStore("Store");

			// serialize
			var wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
			var ws = wsManager.Set("en-US");
			ws.SpellCheckingId = "en-US";
			ws.MatchedPairs = "matched pairs";
			((ILegacyWritingSystemDefinition)ws).WindowsLcid = 0x409.ToString(CultureInfo.InvariantCulture);
			ws.ValidChars = "valid characters";
			ws.LegacyMapping = "legacy mapping";
			wsManager.Save();

			// deserialize
			wsManager = new PalasoWritingSystemManager(new LocalFileWritingSystemStore(storePath));
			Assert.IsTrue(wsManager.Exists("en-US"), "broken before SUT.");
			ws = wsManager.Get("en-US");
			Assert.AreEqual("valid characters", ws.ValidChars, "broken before SUT");
			//change the valid chars data and save back out, this was duplicating in LT-15048
			ws.ValidChars = "more valid characters";
			wsManager.Save();

			var xmlDoc = new XmlDocument();
			xmlDoc.Load(Path.Combine(storePath, "en-US.ldml"));
			Assert.AreEqual(1, xmlDoc.SelectNodes("//special/*[local-name()='validChars']").Count, "Special fw elements were duplicated");
			Assert.AreEqual(1, xmlDoc.SelectNodes("//special/*[local-name()='validChars' and @value='more valid characters']").Count, "special fw changes not saved");
		}
コード例 #26
0
		public void GlobalStore()
		{
			string storePath1 = PrepareTempStore("Store1");
			string storePath2 = PrepareTempStore("Store2");
			string globalStorePath = PrepareTempStore("GlobalStore");

			var globalStore = new GlobalFileWritingSystemStore(globalStorePath);
			var wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
			var ws = wsManager.Set("en-US");
			ws.SpellCheckingId = "id1";
			wsManager.Save();
			Assert.IsTrue(File.Exists(Path.Combine(storePath1, "en-US.ldml")));
			Assert.IsTrue(File.Exists(Path.Combine(globalStorePath, "en-US.ldml")));

			Thread.Sleep(1000);

			DateTime lastModified = File.GetLastWriteTime(Path.Combine(globalStorePath, "en-US.ldml"));
			wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath2, globalStore), globalStore);
			ws = wsManager.Set("en-US");
			ws.SpellCheckingId = "id2";
			wsManager.Save();
			Assert.Less(lastModified, File.GetLastWriteTime(Path.Combine(globalStorePath, "en-US.ldml")));

			lastModified = File.GetLastWriteTime(Path.Combine(storePath1, "en-US.ldml"));
			wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
			ws = wsManager.Get("en-US");
			Assert.AreEqual("id1", ws.SpellCheckingId);
			IEnumerable<IWritingSystem> sharedWss = wsManager.CheckForNewerGlobalWritingSystems();
			Assert.AreEqual(1, sharedWss.Count());
			IWritingSystem sharedWs = sharedWss.First();
			Assert.AreEqual("en-US", sharedWs.Id);
			wsManager.Replace(sharedWs);
			wsManager.Save();

			ws = wsManager.Get("en-US");
			Assert.AreEqual("id2", ws.SpellCheckingId);
			Assert.Less(lastModified, File.GetLastWriteTime(Path.Combine(storePath1, "en-US.ldml")));
		}
コード例 #27
0
		public void InterpretChrp()
		{
			var wsManager = new PalasoWritingSystemManager();
			IWritingSystem 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();
		}
コード例 #28
0
		public void TestOverrideFontForWritingSystem_ForStyleWithNullProps()
		{
			var stylesheet = new TestFwStylesheet();
			int hvoNewStyle1 = stylesheet.MakeNewStyle();

			stylesheet.PutStyle("FirstStyle", "bla", hvoNewStyle1, 0, 0, 0, false, false, null);

			var wsf = new PalasoWritingSystemManager();
			ILgWritingSystem ws = wsf.get_Engine("de");
			int hvoGermanWs = ws.Handle;
			Assert.IsTrue(hvoGermanWs > 0, "Should have gotten an hvo for the German WS");

			// Array of 1 struct, contains writing system and font size to override
			List<FontOverride> fontOverrides = new List<FontOverride>(1);
			FontOverride aFontOverride;
			aFontOverride.writingSystem = hvoGermanWs;
			aFontOverride.fontSize = 48;
			fontOverrides.Add(aFontOverride);
			stylesheet.OverrideFontsForWritingSystems("FirstStyle", fontOverrides);

			//check results
			IVwPropertyStore vwps = VwPropertyStoreClass.Create();
			vwps.Stylesheet = stylesheet;
			vwps.WritingSystemFactory = wsf;

			ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();
			ttpBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "FirstStyle");
			ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, hvoGermanWs);
			ITsTextProps ttp = ttpBldr.GetTextProps();

			LgCharRenderProps chrps = vwps.get_ChrpFor(ttp);
			ws.InterpretChrp(ref chrps);

			Assert.AreEqual(48, chrps.dympHeight / 1000);
		}
コード例 #29
0
ファイル: SharpViewFdo.cs プロジェクト: sillsdev/FieldWorks
		public SharpViewFdo()
		{
			m_wsf = new PalasoWritingSystemManager();
			//m_wsf.get_CharPropEngine(m_wsf.UserWs); // This is a device for getting InitIcuDataDirectory called.
		}
コード例 #30
0
		public void GetWsFromStr()
		{
			var wsManager = new PalasoWritingSystemManager();
			Assert.AreEqual(0, wsManager.GetWsFromStr("en-US"));
			IWritingSystem ws = wsManager.Set("en-US");
			Assert.AreEqual(ws.Handle, wsManager.GetWsFromStr("en-US"));
			wsManager.Save();
		}
コード例 #31
0
		public void get_CharPropEngine()
		{
			var wsManager = new PalasoWritingSystemManager();
			IWritingSystem ws = wsManager.Set("zh-CN");
			ws.ValidChars = "<?xml version=\"1.0\" encoding=\"utf-16\"?>"
							+ "<ValidCharacters><WordForming>e\uFFFCf\uFFFCg\uFFFCh\uFFFC'</WordForming>"
							+ "<Numeric>4\uFFFC5</Numeric>"
							+ "<Other>,\uFFFC!\uFFFC*</Other>"
							+ "</ValidCharacters>";
			ILgCharacterPropertyEngine cpe = wsManager.get_CharPropEngine(ws.Handle);
			Assert.IsNotNull(cpe);
			Assert.IsTrue(cpe.get_IsWordForming('\''));
			Assert.IsFalse(cpe.get_IsWordForming('"'));
			Assert.AreEqual(0x0804, cpe.Locale);

			ws.ValidChars = null;
			cpe = wsManager.get_CharPropEngine(ws.Handle);
			Assert.IsNotNull(cpe);
			Assert.IsFalse(cpe.get_IsWordForming('\''));
			Assert.IsFalse(cpe.get_IsWordForming('"'));
			Assert.AreEqual(0x0804, cpe.Locale);
			wsManager.Save();
		}
コード例 #32
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Make a writing system factory that is based on the Languages folder (ICU-based).
		/// This is only used in Designer, tests, and momentarily (during construction) in
		/// production, until the client sets supplies a real one.
		/// </summary>
		/// -------------------------------------------------------------------------------------
		private void CreateTempWritingSystemFactory()
		{
			m_wsf = new PalasoWritingSystemManager();
			m_fUsingTempWsFactory = true;
		}
コード例 #33
0
		public void GetStrFromWs()
		{
			var wsManager = new PalasoWritingSystemManager();
			Assert.IsNull(wsManager.GetStrFromWs(1));
			IWritingSystem ws = wsManager.Set("en-US");
			Assert.AreEqual("en-US", wsManager.GetStrFromWs(ws.Handle));
			wsManager.Save();
		}
コード例 #34
0
		public void Create()
		{
			var wsManager = new PalasoWritingSystemManager();
			IWritingSystem enWs = wsManager.Create("en-Latn-US-fonipa");
			Assert.AreEqual("Eng", enWs.Abbreviation);
			Assert.AreEqual("English", enWs.LanguageSubtag.Name);
			Assert.AreEqual("Latin", enWs.ScriptSubtag.Name);
			Assert.AreEqual("United States", enWs.RegionSubtag.Name);
			Assert.AreEqual("International Phonetic Alphabet", enWs.VariantSubtag.Name);
			Assert.AreEqual(null, ((ILegacyWritingSystemDefinition)enWs).WindowsLcid);

			IWritingSystem chWs = wsManager.Create("zh-CN");
			Assert.AreEqual("Man", chWs.Abbreviation);
			Assert.AreEqual("Mandarin Chinese", chWs.LanguageSubtag.Name);
			Assert.AreEqual("China", chWs.RegionSubtag.Name);
			Assert.AreEqual("Charis SIL", chWs.DefaultFontName);
			Assert.AreEqual(WritingSystemDefinition.SortRulesType.OtherLanguage, chWs.SortUsing);
			Assert.AreEqual("zh-CN", chWs.SortRules);
			wsManager.Save();
		}
コード例 #35
0
		private PalasoWritingSystemManager GetWsf()
		{
			var wsf = new PalasoWritingSystemManager();
			IWritingSystem wsObj;
			wsf.GetOrSet("qaa-x-kal", out wsObj);
			EnsureQuoteAndHyphenWordForming(wsObj);
			return wsf;
		}
コード例 #36
0
		public void GetOrSetWorksRepeatedlyOnIdNeedingModification()
		{
			var wsManager = new PalasoWritingSystemManager();
			IWritingSystem ws;
			Assert.That(wsManager.GetOrSet("x-kal", out ws), Is.False);
			Assert.That(ws.Id, Is.EqualTo("qaa-x-kal"));
			IWritingSystem ws2;
			Assert.That(wsManager.GetOrSet("x-kal", 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);
		}
コード例 #37
0
		public void TestOverrideFontsForWritingSystems_ForStyleWithProps()
		{
			var stylesheet = new TestFwStylesheet();
			int hvoNewStyle1 = stylesheet.MakeNewStyle();

			ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
			propsBldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, "Arial");
			propsBldr.SetIntPropValues((int)FwTextPropType.ktptFontSize,
				(int)FwTextPropVar.ktpvMilliPoint, 23000);
			stylesheet.PutStyle("FirstStyle", "bla", hvoNewStyle1, 0, 0, 0, false, false,
				propsBldr.GetTextProps());

			var wsf = new PalasoWritingSystemManager();
			ILgWritingSystem wsIngles = wsf.get_Engine("en");
			int hvoInglesWs = wsIngles.Handle;
			Assert.IsTrue(hvoInglesWs > 0, "Should have gotten an HVO for the English WS");

			ILgWritingSystem wsFrench = wsf.get_Engine("fr");
			int hvoFrenchWs = wsFrench.Handle;
			Assert.IsTrue(hvoFrenchWs > 0, "Should have gotten an HVO for the French WS");

			ILgWritingSystem wsGerman = wsf.get_Engine("de");
			int hvoGermanWs = wsGerman.Handle;
			Assert.IsTrue(hvoGermanWs > 0, "Should have gotten an HVO for the German WS");

			Assert.IsTrue(hvoFrenchWs != hvoGermanWs, "Should have gotten different HVOs for each WS");
			Assert.IsTrue(hvoInglesWs != hvoGermanWs, "Should have gotten different HVOs for each WS");
			Assert.IsTrue(hvoFrenchWs != hvoInglesWs, "Should have gotten different HVOs for each WS");

			// Array of structs, containing writing systems and font sizes to override.
			var fontOverrides = new List<FontOverride>(2);
			FontOverride aFontOverride;
			aFontOverride.writingSystem = hvoInglesWs;
			aFontOverride.fontSize = 34;
			fontOverrides.Add(aFontOverride);
			aFontOverride.writingSystem = hvoGermanWs;
			aFontOverride.fontSize = 48;
			fontOverrides.Add(aFontOverride);
			stylesheet.OverrideFontsForWritingSystems("FirstStyle", fontOverrides);

			//check results
			IVwPropertyStore vwps = VwPropertyStoreClass.Create();
			vwps.Stylesheet = stylesheet;
			vwps.WritingSystemFactory = wsf;

			ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();
			ttpBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "FirstStyle");
			ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, hvoFrenchWs);
			ITsTextProps ttpFrench = ttpBldr.GetTextProps();
			ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, hvoGermanWs);
			ITsTextProps ttpGerman = ttpBldr.GetTextProps();
			ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, hvoInglesWs);
			ITsTextProps ttpIngles = ttpBldr.GetTextProps();

			LgCharRenderProps chrpsFrench = vwps.get_ChrpFor(ttpFrench);
			LgCharRenderProps chrpsGerman = vwps.get_ChrpFor(ttpGerman);
			LgCharRenderProps chrpsIngles = vwps.get_ChrpFor(ttpIngles);
			wsFrench.InterpretChrp(ref chrpsFrench);
			wsGerman.InterpretChrp(ref chrpsGerman);
			wsIngles.InterpretChrp(ref chrpsIngles);

			Assert.AreEqual(23, chrpsFrench.dympHeight / 1000);
			Assert.AreEqual(34, chrpsIngles.dympHeight / 1000);
			Assert.AreEqual(48, chrpsGerman.dympHeight / 1000);
		}
コード例 #38
0
		public void get_EngineOrNull()
		{
			var wsManager = new PalasoWritingSystemManager();
			Assert.IsNull(wsManager.get_EngineOrNull(1));
			IWritingSystem ws = wsManager.Set("en-US");
			Assert.AreSame(ws, wsManager.get_EngineOrNull(ws.Handle));
			wsManager.Save();
		}
コード例 #39
0
		public void get_Engine()
		{
			var wsManager = new PalasoWritingSystemManager();
			IWritingSystem 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-Latn-US");
			Assert.IsTrue(wsManager.Exists("en-Latn-US"));
			Assert.IsTrue(wsManager.Exists(enUsLgWs.Handle));
			IWritingSystem enUsWs = wsManager.Get("en-Latn-US");
			Assert.AreSame(enUsWs, enUsLgWs);
			wsManager.Save();
		}
コード例 #40
0
		public void GlobalStore_WritingSystemsToIgnore()
		{
			string storePath1 = PrepareTempStore("Store1");
			string storePath2 = PrepareTempStore("Store2");
			string globalStorePath = PrepareTempStore("GlobalStore");

			var globalStore = new GlobalFileWritingSystemStore(globalStorePath);
			var wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
			var ws = wsManager.Set("en-US");
			ws.SpellCheckingId = "id1";
			wsManager.Save();

			Thread.Sleep(1000);

			wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath2, globalStore), globalStore);
			ws = wsManager.Set("en-US");
			ws.SpellCheckingId = "id2";
			wsManager.Save();

			wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
			IEnumerable<IWritingSystem> sharedWss = wsManager.CheckForNewerGlobalWritingSystems();
			Assert.AreEqual(1, sharedWss.Count());
			Assert.AreEqual("en-US", sharedWss.First().Id);
			ws = wsManager.Get("en-US");
			Assert.AreEqual("id1", ws.SpellCheckingId);
			wsManager.Save();

			wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
			sharedWss = wsManager.CheckForNewerGlobalWritingSystems();
			Assert.AreEqual(0, sharedWss.Count());
			wsManager.Save();

			Thread.Sleep(1000);

			wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath2, globalStore), globalStore);
			ws = wsManager.Get("en-US");
			ws.LegacyMapping = "encoding converter";
			wsManager.Save();

			wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath1, globalStore), globalStore);
			ws = wsManager.Get("en-US");
			Assert.IsNullOrEmpty(ws.LegacyMapping);
			sharedWss = wsManager.CheckForNewerGlobalWritingSystems();
			Assert.AreEqual(1, sharedWss.Count());
			IWritingSystem sharedWs = sharedWss.First();
			Assert.AreEqual("en-US", sharedWs.Id);
			wsManager.Replace(sharedWs);
			wsManager.Save();
			ws = wsManager.Get("en-US");
			Assert.AreEqual("encoding converter", ws.LegacyMapping);
		}
コード例 #41
0
		public void GetValidLangCodeForNewLang()
		{
			string storePath = PrepareTempStore("Store");
			string globalStorePath = PrepareTempStore("GlobalStore");

			EnsureDirectoryIsEmpty(storePath);
			EnsureDirectoryIsEmpty(globalStorePath);

			var globalStore = new GlobalFileWritingSystemStore(globalStorePath);
			var wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath, globalStore), globalStore);

			Assert.AreEqual("qip", wsManager.GetValidLangTagForNewLang("Qipkey"));
			Assert.AreEqual("sn", wsManager.GetValidLangTagForNewLang("Sn"));
			Assert.AreEqual("eba", wsManager.GetValidLangTagForNewLang("\u00CBbashlish")); // \u00CB == E with diacritic
			Assert.AreEqual("eee", wsManager.GetValidLangTagForNewLang("\u00CB\u00CB\u00CBlish"));
			// \u00CB == E with diacritic
			Assert.AreEqual("aaa", wsManager.GetValidLangTagForNewLang("U"));

			LanguageSubtag subtag = new LanguageSubtag("qip", "Qipkey", true, null);
			IWritingSystem newWs = wsManager.Create(subtag, null, null, null);
			wsManager.Set(newWs);
			Assert.AreEqual("aaa", wsManager.GetValidLangTagForNewLang("Qipsing"), "code for 'qip' should already be taken");

			subtag = new LanguageSubtag("aaa", "Qipsing", true, null);
			newWs = wsManager.Create(subtag, null, null, null);
			wsManager.Set(newWs);
			Assert.AreEqual("aab", wsManager.GetValidLangTagForNewLang("Qipwest"),
				"code for 'qip' should already be taken twice");

			// ENHANCE: Ideally, we would want to test incrementing the middle and first character,
			// but that would require at least 677 (26^2 + 1) writing systems be created.
		}
コード例 #42
0
		public void get_RendererFromChrp_Graphite()
		{
			using (GraphicsManager gm = new GraphicsManager(new Form()))
			{
				gm.Init(1.0f);
				try
				{
					var wsManager = new PalasoWritingSystemManager();
					// by default Graphite is disabled
					IWritingSystem ws = wsManager.Set("en-US");
					var chrp = new LgCharRenderProps { ws = ws.Handle, szFaceName = new ushort[32] };
					MarshalEx.StringToUShort("Charis SIL", chrp.szFaceName);
					IRenderEngine engine = wsManager.get_RendererFromChrp(gm.VwGraphics, ref chrp);
					Assert.IsNotNull(engine);
					Assert.AreSame(wsManager, engine.WritingSystemFactory);
					Assert.IsInstanceOf(typeof(UniscribeEngine), engine);

					ws.IsGraphiteEnabled = true;
					engine = wsManager.get_RendererFromChrp(gm.VwGraphics, ref chrp);
					Assert.IsNotNull(engine);
					Assert.AreSame(wsManager, engine.WritingSystemFactory);
					Assert.IsInstanceOf(typeof(GraphiteEngine), engine);
					wsManager.Save();
				}
				finally
				{
					gm.Uninit();
				}
			}
		}
コード例 #43
0
		public DummySimpleRootSite()
		{
			m_rootb = new DummyRootBox(this);
			WritingSystemFactory = new PalasoWritingSystemManager();
		}
コード例 #44
0
		public void CreateAudioWritingSystemVariantFirst()
		{

			string storePath = PrepareTempStore("Store");
			string globalStorePath = PrepareTempStore("GlobalStore");

			EnsureDirectoryIsEmpty(storePath);
			EnsureDirectoryIsEmpty(globalStorePath);

			var globalStore = new GlobalFileWritingSystemStore(globalStorePath);
			var wsManager = new PalasoWritingSystemManager(
				new LocalFileWritingSystemStore(storePath, globalStore), globalStore);

			IWritingSystem newWs = wsManager.Create(new LanguageSubtag("qaa", "Unknown", true, null), null, null, null);

			Assert.DoesNotThrow(() =>
			{
				newWs.VariantSubtag = new VariantSubtag("x-audio", "Audio", false, null);
				newWs.ScriptSubtag = new ScriptSubtag("Zxxx", "Audio", false);
			});
		}