예제 #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set up some dummy styles for testing purposes
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void FixtureSetup()
		{
			base.FixtureSetup();

			m_stylesheet = new TestFwStylesheet();
			m_wsManager = new PalasoWritingSystemManager();

			// English
			IWritingSystem enWs;
			m_wsManager.GetOrSet("en", out enWs);
			m_hvoEnglishWs = enWs.Handle;
			Assert.IsTrue(m_hvoEnglishWs > 0, "Should have gotten an hvo for the English WS");
			// German
			IWritingSystem deWs;
			m_wsManager.GetOrSet("de", out deWs);
			m_hvoGermanWs = deWs.Handle;
			Assert.IsTrue(m_hvoGermanWs > 0, "Should have gotten an hvo for the German WS");
			Assert.IsTrue(m_hvoEnglishWs != m_hvoGermanWs, "Writing systems should have different IDs");

			// Create a couple of styles
			int hvoStyle = m_stylesheet.MakeNewStyle();
			ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
			propsBldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, "Arial");
			m_stylesheet.PutStyle("StyleA", "bla", hvoStyle, 0, hvoStyle, 1, false, false,
				propsBldr.GetTextProps());

			hvoStyle = m_stylesheet.MakeNewStyle();
			propsBldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, "Times New Roman");
			m_stylesheet.PutStyle("StyleB", "bla", hvoStyle, 0, hvoStyle, 1, false, false,
				propsBldr.GetTextProps());

			// Override the font size for each writing system and each style.
			List<FontOverride> fontOverrides = new List<FontOverride>(2);
			FontOverride fo;
			fo.writingSystem = m_hvoEnglishWs;
			fo.fontSize = 21;
			fontOverrides.Add(fo);
			fo.writingSystem = m_hvoGermanWs;
			fo.fontSize = 13;
			fontOverrides.Add(fo);
			m_stylesheet.OverrideFontsForWritingSystems("StyleA", fontOverrides);

			fontOverrides.Clear();
			fo.writingSystem = m_hvoEnglishWs;
			fo.fontSize = 20;
			fontOverrides.Add(fo);
			fo.writingSystem = m_hvoGermanWs;
			fo.fontSize = 56;
			fontOverrides.Add(fo);
			m_stylesheet.OverrideFontsForWritingSystems("StyleB", fontOverrides);
		}
예제 #2
0
        public void TestOverrideFontForWritingSystem_ForStyleWithNullProps()
        {
            TestFwStylesheet stylesheet = new TestFwStylesheet();
            int hvoNewStyle1            = stylesheet.MakeNewStyle();

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

            ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();

            try
            {
                wsf.BypassInstall = true;
                IWritingSystem ws          = wsf.get_Engine("de");
                int            hvoGermanWs = ws.WritingSystem;
                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);
            }
            finally
            {
                wsf.Shutdown();
            }
        }
예제 #3
0
		public void TestOverrideFontsForWritingSystems_ForStyleWithProps()
		{
			TestFwStylesheet 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());

			ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
			try
			{
				wsf.BypassInstall = true;

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

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

				IWritingSystem wsIngles = wsf.get_Engine("en");
				int hvoInglesWs = wsIngles.WritingSystem;
				Assert.IsTrue(hvoInglesWs > 0, "Should have gotten an HVO for the English 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.
				List<FontOverride> fontOverrides = new List<FontOverride>(2);
				FontOverride aFontOverride;
				aFontOverride.writingSystem = hvoGermanWs;
				aFontOverride.fontSize = 48;
				fontOverrides.Add(aFontOverride);
				aFontOverride.writingSystem = hvoInglesWs;
				aFontOverride.fontSize = 34;
				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);
			}
			finally
			{
				wsf.Shutdown();
			}
		}
예제 #4
0
		public void TestOverrideFontForWritingSystem_ForStyleWithNullProps()
		{
			TestFwStylesheet stylesheet = new TestFwStylesheet();
			int hvoNewStyle1 = stylesheet.MakeNewStyle();

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

			ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
			try
			{
				wsf.BypassInstall = true;
				IWritingSystem ws = wsf.get_Engine("de");
				int hvoGermanWs = ws.WritingSystem;
				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);
			}
			finally
			{
				wsf.Shutdown();
			}
		}
예제 #5
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);
        }
예제 #6
0
		public void SetupStyles()
		{
			m_stylesheet = new TestFwStylesheet();
			m_wsf = LgWritingSystemFactoryClass.Create();
			m_wsf.BypassInstall = true;

			// German
			IWritingSystem wsGerman = m_wsf.get_Engine("de");
			m_hvoGermanWs = wsGerman.WritingSystem;
			Assert.IsTrue(m_hvoGermanWs > 0, "Should have gotten an hvo for the German WS");
			// English
			IWritingSystem wsEnglish = m_wsf.get_Engine("en");
			m_hvoEnglishWs = wsEnglish.WritingSystem;
			Assert.IsTrue(m_hvoEnglishWs > 0, "Should have gotten an hvo for the English WS");
			Assert.IsTrue(m_hvoEnglishWs != m_hvoGermanWs, "Writing systems should have different IDs");

			// Create a couple of styles
			int hvoStyle = m_stylesheet.MakeNewStyle();
			ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
			propsBldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, "Arial");
			m_stylesheet.PutStyle("StyleA", "bla", hvoStyle, 0, hvoStyle, 1, false, false,
				propsBldr.GetTextProps());

			hvoStyle = m_stylesheet.MakeNewStyle();
			propsBldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, "Times New Roman");
			m_stylesheet.PutStyle("StyleB", "bla", hvoStyle, 0, hvoStyle, 1, false, false,
				propsBldr.GetTextProps());

			// Override the font size for each writing system and each style.
			List<FontOverride> fontOverrides = new List<FontOverride>(2);
			FontOverride fo;
			fo.writingSystem = m_hvoGermanWs;
			fo.fontSize = 13;
			fontOverrides.Add(fo);
			fo.writingSystem = m_hvoEnglishWs;
			fo.fontSize = 21;
			fontOverrides.Add(fo);
			m_stylesheet.OverrideFontsForWritingSystems("StyleA", fontOverrides);

			fontOverrides.Clear();
			fo.writingSystem = m_hvoGermanWs;
			fo.fontSize = 56;
			fontOverrides.Add(fo);
			fo.writingSystem = m_hvoEnglishWs;
			fo.fontSize = 20;
			fontOverrides.Add(fo);
			m_stylesheet.OverrideFontsForWritingSystems("StyleB", fontOverrides);
		}