public void CategoryPath_Level1() { ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); XmlNoteCategory noteCategory = new XmlNoteCategory(m_possList.PossibilitiesOS[0], wsf); Assert.AreEqual("Level 1a", noteCategory.CategoryPath); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ private void UpdateLanguageCombos() { ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); string userLocale = wsf.GetStrFromWs(wsf.UserWs); // Get the set of writing systems. Set <NamedWritingSystem> writingSystems = LangProject.GetAllNamedWritingSystemsFromLDFs(wsf, userLocale); NamedWritingSystem wsSaveVern = (NamedWritingSystem)m_cbVernWrtSys.SelectedItem; NamedWritingSystem wsSaveAnal = (NamedWritingSystem)m_cbAnalWrtSys.SelectedItem; m_cbAnalWrtSys.Items.Clear(); m_cbVernWrtSys.Items.Clear(); m_cbAnalWrtSys.BeginUpdate(); m_cbVernWrtSys.BeginUpdate(); foreach (NamedWritingSystem nws in writingSystems) { m_cbAnalWrtSys.Items.Add(nws); m_cbVernWrtSys.Items.Add(nws); } int i = (wsSaveVern == null ? 0 : m_cbVernWrtSys.FindString(wsSaveVern.Name)); m_cbVernWrtSys.SelectedIndex = (i >= 0 ? i : 0); m_cbVernWrtSys.EndUpdate(); i = (wsSaveAnal == null ? 0 : m_cbAnalWrtSys.FindString(wsSaveAnal.Name)); m_cbAnalWrtSys.SelectedIndex = (i >= 0 ? i : 0); m_cbAnalWrtSys.EndUpdate(); }
public void CategoryPath_Level3() { ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); XmlNoteCategory noteCategory = new XmlNoteCategory( m_possList.PossibilitiesOS[1].SubPossibilitiesOS[1].SubPossibilitiesOS[0], wsf); Assert.AreEqual("Level 1b" + StringUtils.kchObject + "Level 2b, parent is 1b" + StringUtils.kchObject + "Level 3, parent is 2b", noteCategory.CategoryPath); }
public void XmlNoteCategory_TopLevel() { ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); XmlNoteCategory noteCategory = new XmlNoteCategory(m_possList.PossibilitiesOS[0], wsf); Assert.AreEqual("Level 1a", noteCategory.CategoryName); Assert.AreEqual("es", noteCategory.IcuLocale); Assert.IsNull(noteCategory.SubCategory); }
public void Persistence() { ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); try { int wsEng = 1; int wsFrn = 2; int wsGer = 3; wsf.AddWritingSystem(wsEng, "en"); wsf.AddWritingSystem(wsFrn, "fr"); wsf.AddWritingSystem(wsGer, "de"); InterlinLineChoices choices = new InterlinLineChoices(wsFrn, wsEng); MakeStandardState(choices); string persist = choices.Persist(wsf); choices = InterlinLineChoices.Restore(persist, wsf, 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(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); } finally { // we must shutdown and marshal this or else it could mess up other tests. wsf.Shutdown(); System.Runtime.InteropServices.Marshal.ReleaseComObject(wsf); } }
public void SetUp() { CheckDisposed(); m_ISilDataAccess = VwCacheDaClass.Create(); // It must have a writing system factory: for testing, use the memory based one. ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); // For these tests we don't need to run InstallLanguage. wsf.BypassInstall = true; m_ISilDataAccess.WritingSystemFactory = wsf; }
public void Setup() { m_wsf = LgWritingSystemFactoryClass.Create(); // This is typically run during the build process before InstallLanguage.exe has // been built, so we want to disable InstallLanguage for this test. m_wsf.BypassInstall = true; m_wsEn = m_wsf.get_Engine("en"); m_wsIdEn = m_wsf.GetWsFromStr("en"); m_wsEn.set_Name(m_wsIdEn, "English"); m_wsEn.set_Abbr(m_wsIdEn, "ENG"); }
public void GetCategoryHierarchyFromXml() { ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); XmlNoteCategory noteCategory = new XmlNoteCategory( m_possList.PossibilitiesOS[1].SubPossibilitiesOS[1].SubPossibilitiesOS[0], wsf); string xmlCategoryPath = (string)ReflectionHelper.GetResult(noteCategory, "GetCategoryHierarchyFromXml", noteCategory); Assert.AreEqual("Level 1b" + StringUtils.kchObject + "Level 2b, parent is 1b" + StringUtils.kchObject + "Level 3, parent is 2b", xmlCategoryPath); }
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); }
public void XmlNoteCategory_SecondLevel() { ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); XmlNoteCategory noteCategory = new XmlNoteCategory( m_possList.PossibilitiesOS[1].SubPossibilitiesOS[1], wsf); Assert.AreEqual("Level 1b", noteCategory.CategoryName); Assert.AreEqual("es", noteCategory.IcuLocale); Assert.IsNotNull(noteCategory.SubCategory); Assert.AreEqual("Level 2b, parent is 1b", noteCategory.SubCategory.CategoryName); Assert.AreEqual("es", noteCategory.SubCategory.IcuLocale); Assert.IsNull(noteCategory.SubCategory.SubCategory); }
public void SetUp() { CheckDisposed(); if (m_ISilDataAccess != null && (m_ISilDataAccess is IDisposable)) { (m_ISilDataAccess as IDisposable).Dispose(); } m_ISilDataAccess = (ISilDataAccess) new CacheBase(null); // It must have a writing system factory: for testing, use the memory based one. ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); // For these tests we don't need to run InstallLanguage. wsf.BypassInstall = true; m_ISilDataAccess.WritingSystemFactory = wsf; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Set up a Chrp consistent with the current style sheet /// </summary> /// ------------------------------------------------------------------------------------ protected void MakeCharProps() { LangProject lp = m_Parent.LangProj; // Make a text property with the named style. ITsPropsBldr tsPropsBuilder = TsPropsBldrClass.Create(); tsPropsBuilder.SetStrPropValue((int)VwStyleProperty.kspNamedStyle, m_FieldSpec.Style); tsPropsBuilder.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, m_ws); ITsTextProps tsTextProps = tsPropsBuilder.GetTextProps(); // Fill out the LgCharRenderProps. ILgWritingSystemFactory lgEncFactory; IVwPropertyStore vwPropertyStore = VwPropertyStoreClass.Create(); IVwStylesheet vwStylesheet = DeStyleSheet; if (vwStylesheet != null) { vwPropertyStore.Stylesheet = vwStylesheet; } if (lp != null) { lgEncFactory = lp.Cache.LanguageWritingSystemFactoryAccessor; } else { // Get default registry-based factory. lgEncFactory = LgWritingSystemFactoryClass.Create(); } Debug.Assert(lgEncFactory != null); vwPropertyStore.WritingSystemFactory = lgEncFactory; m_CharacterRenderingProps = vwPropertyStore.get_ChrpFor(tsTextProps); IWritingSystem writingSystem = lgEncFactory.get_EngineOrNull(m_CharacterRenderingProps.ws); Debug.Assert(writingSystem != null); writingSystem.InterpretChrp(ref m_CharacterRenderingProps); // For our purposes here, we don't want transparent backgrounds. if ((int)m_CharacterRenderingProps.clrBack == (int)FwTextColor.kclrTransparent) { m_CharacterRenderingProps.clrBack = (uint)SystemColors.Window.ToArgb(); } // Make a brush for the background. m_BackgroundBrush = new SolidBrush(Color.FromArgb((int)m_CharacterRenderingProps.clrBack)); }
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(); } }
/// <summary></summary> public ConverterTest() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); if (DesignMode) { return; } InputArgsChanged(); // set the initial state of the Convert button // Set view properties. m_fHasOutput = false; m_svOutput = new SampleView(); m_svOutput.WritingSystemFactory = LgWritingSystemFactoryClass.Create(); m_svOutput.Dock = DockStyle.Fill; m_svOutput.Visible = true; m_svOutput.Enabled = false; m_svOutput.BackColor = OutputPanel.BackColor; m_svOutput.TabIndex = 1; m_svOutput.TabStop = true; OutputPanel.Controls.Add(m_svOutput); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="comboWS">Combo box containing the list of writing systems</param> /// ------------------------------------------------------------------------------------ private void RunWizard(ComboBox comboWS) { using (new WaitCursor(this)) { using (WritingSystemWizard wiz = new WritingSystemWizard()) { ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); try { wiz.Init(wsf, m_helpTopicProvider); if (comboWS == m_cbVernWrtSys) { wiz.PerformInitialSearch(m_txtName.Text.Trim()); } if (wiz.ShowDialog() == DialogResult.OK) { UpdateLanguageCombos(); string target = wiz.WritingSystem().IcuLocale; for (int i = 0; i < comboWS.Items.Count; ++i) { if (((NamedWritingSystem)comboWS.Items[i]).IcuLocale == target) { comboWS.SelectedIndex = i; break; } } } } finally { wsf.Shutdown(); } } } }
public void Setup() { // Create the following: // - part and layout inventories // - metadata cache // - DataAccess cache // - collection of columns to display. // We want a MetaDataCache that knows about // - LexEntry.Senses, Msas, CitationForm, Bibliography, Etymology // - LexSense.SemanticDomains, SenseType, Status, gloss // - CmPossibility Name, abbr // - MoMorphSynAnalysis // - MoStemMsa // - MoDerivationalMsa m_mdc = FwMetaDataCacheClass.Create(); string m_sTestPath = Path.Combine(DirectoryFinder.FwSourceDirectory, @"Common\Controls\XmlViews\XmlViewsTests\SampleCm.xml"); m_mdc.InitXml(m_sTestPath, true); // We want ISilDataAccess with: // - LexEntry (1) with no senses and one MSA (2) // - LexEntry (4) with one sense (5) and no MSA // - LexEntry (6) with three senses (7, 8, 9) and two MSAs (10, 11) // - sense(5) with no semantic domains // - senses with one SD (7->30, 8->31) // - sense with three SDs, one the same as the first (9->30, 31, 32) // - MoStemMsa (2, 11) // - MoDerivationalMsa (10) m_cda = VwCacheDaClass.Create(); m_sda = m_cda as ISilDataAccess; m_wsf = LgWritingSystemFactoryClass.Create(); m_sda.WritingSystemFactory = m_wsf; SimpleDataParser parser = new SimpleDataParser(m_mdc, m_cda); parser.Parse(Path.Combine(DirectoryFinder.FwSourceDirectory, @"Common\Controls\XmlViews\XmlViewsTests\SampleData.xml")); int wsEn = m_wsf.GetWsFromStr("en"); // These are mainly to check out the parser. Assert.AreEqual(3, m_sda.get_ObjectProp(2, 23011), "part of speech of an MoStemMsa"); Assert.AreEqual(2, m_sda.get_VecItem(1, 2009, 0), "owned msa"); Assert.AreEqual("noun", m_sda.get_MultiStringAlt(3, 7003, wsEn).Text, "got ms property"); Assert.AreEqual(9, m_sda.get_VecItem(6, 2010, 2), "3rd sense"); Assert.AreEqual(31, m_sda.get_VecItem(9, 21016, 1), "2nd semantic domain"); // Columns includes // - CitationForm (string inside span) // - Bibliography (string not in span) // - Sense glosses (string in para in seq, nested in column element) // - Semantic domains (pair of strings in para in seq in seq, using layout refs) // - MSAs (simplified, but polymorphic with one having <choice> and one <obj> to CmPossibility XmlDocument docColumns = new XmlDocument(); docColumns.Load(Path.Combine(DirectoryFinder.FwSourceDirectory, @"Common\Controls\XmlViews\XmlViewsTests\TestColumns.xml")); m_columnList = docColumns.DocumentElement.ChildNodes; // Parts just has what those columns need. string partDirectory = Path.Combine(DirectoryFinder.FwSourceDirectory, @"Common\Controls\XmlViews\XmlViewsTests"); Dictionary <string, string[]> keyAttrs = new Dictionary <string, string[]>(); keyAttrs["layout"] = new string[] { "class", "type", "name" }; keyAttrs["group"] = new string[] { "label" }; keyAttrs["part"] = new string[] { "ref" }; // Currently there are no specialized layout files that match. m_layoutInventory = new Inventory(new string[] { partDirectory }, "*Layouts.xml", "/LayoutInventory/*", keyAttrs); keyAttrs = new Dictionary <string, string[]>(); keyAttrs["part"] = new string[] { "id" }; m_partInventory = new Inventory(new string[] { partDirectory }, "TestParts.xml", "/PartInventory/bin/*", keyAttrs); if (m_layouts != null) { m_layouts.Dispose(); } m_layouts = new LayoutCache(m_mdc, m_layoutInventory, m_partInventory); }
public void PopulateFromLanguageClass() { //Extracts the locale filename from a given path int icuName = m_inputFilename.LastIndexOf("\\"); string icuPortion = m_inputFilename.Substring(icuName + 1); //Appears this maps the XML file to a LanguageDefinition class ///////////////// ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create(); LanguageDefinitionFactory langDefFactory = new LanguageDefinitionFactory(wsf, icuPortion); LanguageDefinition langDef = langDefFactory.InitializeFromXml(wsf, icuPortion) as LanguageDefinition; if (langDef == null) { throw new Exception("Unable to read and parse the input XML file " + m_inputFilename); } ///////////////// int i = 0; int cpua = langDef.PuaDefinitionCount; // if we have PUA characters in the LD file make an array of PUACharacters. But be careful // to handle invalid definitions gracefully. if (langDef.PuaDefinitions != null && cpua != 0) { puaChars = new PUACharacter[cpua]; foreach (CharDef charDef in langDef.PuaDefinitions) { try { puaChars[i] = new PUACharacter(charDef); ++i; } catch { } } } if (i < cpua) { if (i == 0) { puaChars = null; } else { PUACharacter[] puaGoodChars = new PUACharacter[i]; for (int ic = 0; ic < i; ++ic) { puaGoodChars[ic] = puaChars[ic]; } puaChars = puaGoodChars; } if (LogFile.IsLogging()) { LogFile.AddErrorLine("Warning, " + (cpua - i) + " out of " + cpua + " PUA character definitions are invalid."); } } baseLocale = langDef.BaseLocale; newLocale = langDef.XmlWritingSystem.WritingSystem.IcuLocale; localeResources = langDef.LocaleResources; // Get the collation elements, whether from the CollationElements element directly, // or from the WritingSystem element. collationElements = langDef.CollationElements; if (collationElements == null) { IWritingSystem lws = langDef.WritingSystem; int ccoll = lws.CollationCount; if (ccoll > 0) { collationElements = lws.get_Collation(0).IcuRules; } } localeWinLCID = langDef.XmlWritingSystem.WritingSystem.Locale.ToString(); // make sure the newlocale has the proper case for each property: // lang, country and variant InstallLanguage.LocaleParser lp = new LocaleParser(newLocale); newLocale = lp.Locale; // Make sure the display names [Name, Country & Variant] have Unicode characters // greater than 7F converted to the \uxxxx format where xxxx is the unicode // hex value of the character. localeName = ConvertToUnicodeNotation(langDef.LocaleName); localeScript = ConvertToUnicodeNotation(langDef.LocaleScript); localeCountry = ConvertToUnicodeNotation(langDef.LocaleCountry); localeVariant = ConvertToUnicodeNotation(langDef.LocaleVariant); // Save the multilingual names of the writing system, together with the // ICU locale for each name. NameMultiUnicode rgName = langDef.XmlWritingSystem.Name; int cws = rgName.Count; // If we don't have a name, use the IcuLocale rather than going without a name. // Otherwise it won't register as a language in en.txt/res. if (cws == 0) { StringWithWs sw = new StringWithWs(langDef.XmlWritingSystem.WritingSystem.IcuLocale, "en"); rgName.Add(sw); cws = 1; } m_rgNames = new System.Collections.ArrayList(cws); for (int iws = 0; iws < cws; ++iws) { StringWithWs x = rgName[iws]; m_rgNames.Add(x); } // TODO - dlh // Once collationElements are handled, something will have to be checked there // as the current implementation assumes that it's in the valid format. wsf.Shutdown(); // This is (always) needed to balance creating the factory. }
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(); } }
/// ------------------------------------------------------------------------------------- /// <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 = LgWritingSystemFactoryClass.Create(); m_wsf.BypassInstall = true; m_fUsingTempWsFactory = true; }