public static int calcCharWidth(char c, FontInfo fontInfo) { if (c == ' ' || c == '\t') { return fontInfo.getSpaceSize(); } CharInfo charInfo = resolveCharInfo(c, fontInfo); if (charInfo == null) { return fontInfo.getSpaceSize(); } return charInfo.getWidth(); }
/* TODO special treatment of gamma * TODO rough breathing with rho * TODO docs * */ public static String[][] pronounce(String str) { WordInfo inf = new WordInfo(str); String[][] syls = inf.lettersSunacc; String[][] res = new String[inf.nWords][]; for (int i = 0; i < inf.nWords; i++) { res[i] = new String[inf.nSyllables[i]]; for (int j = 0; j < inf.nSyllables[i]; j++) { StringBuilder lett = new StringBuilder(); if (j == 0) { String lett1 = (String) Normalizer.normalize(inf.words[i].subSequence(0, 1), Normalizer.Form.NFD); // detect rough breathing mark 0x314 // System.out.println(" first letter: " + tmp); if (lett1.contains("\u0314") && !lett1.contains("ρ")) { lett.append("h"); } } for (int k = 0; k < syls[i][j].length(); k++) { char current = syls[i][j].charAt(k); if (!CharInfo.isVowel(current)) { if (current == 'ρ') { // *** } lett.append(consonants.get(Character.toString(current))); } else { int currv = inf.vowelnW[i][j]; lett.append(vowels.get(currv)); if (currv > 0x10) k++; // if diphthong, skip next letter } // System.out.print("\n" + i + " " + j + " " + " " + k + ": " + current + " ");// + // lett); } // int tmp = inf.accentW[i][j]; if (inf.accentW[i][j] > 1) { res[i][j] = lett.toString().toUpperCase(); } else { res[i][j] = lett.toString(); } // System.out.print(res[i][j]); // if (j < inf.nSyllables[i]-1) { System.out.print("-"); } } // System.out.print(" "); } // System.out.println(); return res; }
private void initBuffer() { CharInfo c; { c = new CharInfo(); c.cp = 0; c.str = "B3"; c.ctype = "O"; c.start = -1; c.end = -1; buffer[0] = c; c = new CharInfo(); c.cp = 0; c.str = "B2"; c.ctype = "O"; c.start = -1; c.end = -1; buffer[1] = c; c = new CharInfo(); c.cp = 0; c.str = "B1"; c.ctype = "O"; c.start = -1; c.end = -1; buffer[2] = c; } end = 3; position = 3; }
public CharInfo readChar() throws IOException { CharInfo c = new CharInfo(); if (eos) { c.start = -1; c.end = -1; c.cp = -1; } else { c.start = reader.getPosition(); c.cp = reader.read(); c.end = reader.getPosition(); } if (c.cp < 0) { eos = true; switch (eosCount) { case 0: c.str = "E1"; c.ctype = "O"; ++eosCount; break; case 1: c.str = "E2"; c.ctype = "O"; ++eosCount; break; case 2: c.str = "E3"; c.ctype = "O"; ++eosCount; break; default: return null; } } else { c.str = new String(Character.toChars(c.cp)); c.ctype = getCharType(c.cp); } return c; }