/// ------------------------------------------------------------------------------------
        /// <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);
        }
Exemplo n.º 2
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);
        }