/** * @param lang * @param country * @param leftMin * @param rightMin */ public Hyphenator(String lang, String country, int leftMin, int rightMin) { hyphenTree = GetHyphenationTree(lang, country); remainCharCount = leftMin; pushCharCount = rightMin; }
/** * @param lang * @param country * @return the hyphenation tree */ public static HyphenationTree GetHyphenationTree(String lang, String country) { String key = lang; // check whether the country code has been used if (country != null && !country.Equals("none")) { key += "_" + country; } // first try to find it in the cache if (hyphenTrees.ContainsKey(key)) { return((HyphenationTree)hyphenTrees[key]); } if (hyphenTrees.ContainsKey(lang)) { return((HyphenationTree)hyphenTrees[lang]); } HyphenationTree hTree = GetResourceHyphenationTree(key); //if (hTree == null) // hTree = GetFileHyphenationTree(key); // put it into the pattern cache if (hTree != null) { hyphenTrees[key] = hTree; } return(hTree); }
public static HyphenationTree getFopHyphenationTree(string key) { HyphenationTree hTree = null; Stream istr = null; try { istr = getResourceStream(key); if (istr == null) { if (key.Length == 5) { istr = getResourceStream(key.Substring(0, 2)); if (istr != null) { Console.Error.WriteLine("Couldn't find hyphenation pattern " + key + "\nusing general language pattern " + key.Substring(0, 2) + " instead."); } else { if (errorDump) { Console.Error.WriteLine("Couldn't find precompiled " + "hyphenation pattern " + key + ".hyp"); } return(null); } } else { if (errorDump) { Console.Error.WriteLine("Couldn't find precompiled " + "hyphenation pattern " + key + ".hyp"); } return(null); } } hTree = new HyphenationTree(); hTree.loadInternalPatterns(istr); } catch (Exception e) { Console.Error.WriteLine(e.StackTrace); } finally { if (istr != null) { try { istr.Close(); } catch (IOException e) { e.GetType(); Console.Error.WriteLine("can't close hyphenation stream"); } } } return(hTree); }
/// <summary> /// </summary> /// <param name="lang"></param> /// <param name="country"></param> /// <param name="leftMin"></param> /// <param name="rightMin"></param> public Hyphenator(string lang, string country, int leftMin, int rightMin) { _hyphenTree = GetHyphenationTree(lang, country); _remainCharCount = leftMin; _pushCharCount = rightMin; }
/** * @param lang * @param country * @param word * @param offset * @param len * @param leftMin * @param rightMin * @return a hyphenation object */ public static Hyphenation Hyphenate(String lang, String country, char[] word, int offset, int len, int leftMin, int rightMin) { HyphenationTree hTree = GetHyphenationTree(lang, country); if (hTree == null) { //log.Error("Error building hyphenation tree for language " // + lang); return(null); } return(hTree.Hyphenate(word, offset, len, leftMin, rightMin)); }
public static Hyphenation hyphenate(string lang, string country, char[] word, int offset, int len, int leftMin, int rightMin) { HyphenationTree hTree = getHyphenationTree(lang, country); if (hTree == null) { Console.Error.WriteLine("Error building hyphenation tree for language " + lang); return(null); } return(hTree.hyphenate(word, offset, len, leftMin, rightMin)); }
public static HyphenationTree getHyphenationTree(string lang, string country) { string key = lang; // check whether the country code has been used if (country != null && !country.Equals("none")) { key += "_" + country; } // first try to find it in the cache if (hyphenTrees.ContainsKey(key)) { return((HyphenationTree)hyphenTrees[key]); } if (hyphenTrees.ContainsKey(lang)) { return((HyphenationTree)hyphenTrees[lang]); } HyphenationTree hTree = getFopHyphenationTree(key); if (hTree == null) { //string hyphenDir = "e:\\winprog2\\Fop-0.20.2\\hyph"; //Configuration.getstringValue("hyphenation-dir"); if (hyphenDir != null) { hTree = getUserHyphenationTree(key, hyphenDir); } } // put it into the pattern cache if (hTree != null) { hyphenTrees.Add(key, hTree); } else { Console.Error.WriteLine("Couldn't find hyphenation pattern " + key); } return(hTree); }
/** * @param key * @return a hyphenation tree */ public static HyphenationTree GetResourceHyphenationTree(String key) { try { Stream stream = BaseFont.GetResourceStream(defaultHyphLocation + key + ".xml"); if (stream == null && key.Length > 2) { stream = BaseFont.GetResourceStream(defaultHyphLocation + key.Substring(0, 2) + ".xml"); } if (stream == null) { return(null); } HyphenationTree hTree = new HyphenationTree(); hTree.LoadSimplePatterns(stream); return(hTree); } catch { return(null); } }
/** * @param key * @return a hyphenation tree */ public static HyphenationTree GetResourceHyphenationTree(String key) { try { Stream stream = StreamUtil.GetResourceStream(defaultHyphLocation + key + ".xml"); if (stream == null && key.Length > 2) stream = StreamUtil.GetResourceStream(defaultHyphLocation + key.Substring(0, 2) + ".xml"); if (stream == null) return null; HyphenationTree hTree = new HyphenationTree(); hTree.LoadSimplePatterns(stream); return hTree; } catch { return null; } }
/** * @param lang * @param country */ virtual public void SetLanguage(String lang, String country) { hyphenTree = GetHyphenationTree(lang, country); }
/** * @param lang * @param country */ public void SetLanguage(String lang, String country) { hyphenTree = GetHyphenationTree(lang, country); }
/// <summary> /// </summary> /// <param name="lang"></param> /// <param name="country"></param> public void SetLanguage(string lang, string country) => _hyphenTree = GetHyphenationTree(lang, country);
public void setLanguage(string lang, string country) { hyphenTree = getHyphenationTree(lang, country); }