/// ------------------------------------------------------------------------------------ /// <summary> /// Updates a font /// </summary> /// ------------------------------------------------------------------------------------ public void UpdateFont(int i, string filename) { if (i < 0 || m_Fonts == null || i >= m_Fonts.Length) throw new IndexOutOfRangeException(); m_Fonts[i] = new FileName(filename); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds a font /// </summary> /// <param name="filename"></param> /// ------------------------------------------------------------------------------------ public void AddFont(string filename) { int newLength = 1; if (m_Fonts != null) newLength = m_Fonts.Length + 1; FileName[] newFonts = new FileName[newLength]; if (m_Fonts != null) m_Fonts.CopyTo(newFonts, 0); m_Fonts = newFonts; m_Fonts[newLength - 1] = new FileName(filename); }
public void SerializeAndDeserialize() { IWritingSystem ws = m_wsf.get_Engine("tl"); int wsIdTl = m_wsf.GetWsFromStr("tl"); ws.Locale = 13321; ws.DefaultMonospace = "Courier New"; ws.DefaultSansSerif = "Arial"; ws.DefaultBodyFont = "Charis SIL"; ws.DefaultSerif = "Times New Roman"; ws.set_Name(m_wsIdEn, "Tagalog"); ws.set_Name(wsIdTl, "Tagalog"); ws.set_Abbr(m_wsIdEn, "TGL"); ICollation coll = CollationClass.Create(); coll.WinLCID = 1033; coll.WinCollation = "Latin1_General_CI_AI"; coll.set_Name(m_wsIdEn, "Default Collation"); coll.WritingSystemFactory = m_wsf; ws.set_Collation(0, coll); LanguageDefinition langDef = new LanguageDefinition(ws); langDef.BaseLocale = "en_US"; langDef.XmlWritingSystem.WritingSystem.IcuLocale = "tl"; langDef.LocaleName = "Tagalog"; langDef.LocaleScript = ""; langDef.LocaleCountry = ""; langDef.LocaleVariant = ""; langDef.XmlWritingSystem.WritingSystem.Locale = 13321; langDef.CollationElements = "\"& B < ..."; langDef.ValidChars = "abcdefg"; langDef.LocaleResources = @" zoneStrings { { 'Europe/London', 'Greenwich Mean Time', } }"; CharDef[] charDefs = new CharDef[2]; charDefs[0] = new CharDef(0xF170, "COMBINING SNAKE BELOW;Mn;202;NSM;;;;"); charDefs[1] = new CharDef(0xF210, "LATIN SMALL LETTER P WITH STROKE;Ll;0;L;;;;"); langDef.PuaDefinitions = charDefs; FileName[] fonts = new FileName[4]; fonts[0] = new FileName("arial.ttf"); fonts[1] = new FileName("arialbd.ttf"); fonts[2] = new FileName("ariali.ttf"); fonts[3] = new FileName("arialbi.ttf"); langDef.Fonts = fonts; langDef.Keyboard = new FileName("Tagalog.kmx"); langDef.EncodingConverter = new EncodingConverter("SIL_IPA93.tec.vbs", "SIL-IPA93.tec"); string tmpFileName = Path.GetTempFileName(); langDef.Serialize(tmpFileName); LanguageDefinitionFactory otherIcuWs = new LanguageDefinitionFactory(); LanguageDefinitionFactory.WritingSystemFactory = m_wsf; otherIcuWs.Deserialize(tmpFileName); ILanguageDefinition newLangDef = otherIcuWs.LanguageDefinition; IWritingSystem deserializedWs = newLangDef.WritingSystem; ICollation deserializedColl = newLangDef.GetCollation(0); StreamReader reader = new StreamReader(tmpFileName); string line = reader.ReadLine(); while (line != null) { Console.WriteLine(line); line = reader.ReadLine(); } reader.Close(); File.Delete(tmpFileName); Assert.AreEqual(ws.Locale, deserializedWs.Locale); Assert.AreEqual(ws.IcuLocale, deserializedWs.IcuLocale); Assert.AreEqual(ws.DefaultSansSerif, deserializedWs.DefaultSansSerif); Assert.AreEqual(ws.DefaultBodyFont, deserializedWs.DefaultBodyFont); Assert.AreEqual(ws.get_Name(m_wsIdEn), deserializedWs.get_Name(m_wsIdEn)); Assert.AreEqual(coll.WinLCID, deserializedColl.WinLCID); Assert.AreEqual(coll.WinCollation, deserializedColl.WinCollation); // ENHANCE: Add ValidChars to the interface // Assert.AreEqual(ws.ValidChars, deserializedWs.ValidChars); Assert.AreEqual(coll.get_Name(m_wsIdEn), deserializedColl.get_Name(m_wsIdEn)); }