get_Engine() public method

Get the actual writing system object for a given ICU Locale string. The current implementation returns any existing writing system for that ICU Locale, or creates one with default settings if one is not already known. (Use get_EngineOrNull to avoid automatic creation of a new engine.)
public get_Engine ( string bstrIdentifier ) : ILgWritingSystem
bstrIdentifier string The identifier.
return ILgWritingSystem
		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);
			}
		}
        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();
        }
		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);
		}
		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();
		}
		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);
		}