public bool PushToDictionaries() { int lastHash = 0; try { ClearDictionary(); for (int i = 0; i < fontData.Length; i++) { var count = fontData[i].chars.Length; for (int j = 0; j < count; j++) { TexChar c = GetChar(i, j); c.CheckValidity(); lastHash = c.ToHash(); if (!string.IsNullOrEmpty(c.symbolName)) { symbolData.Add(c.symbolName, lastHash); } if (!string.IsNullOrEmpty(c.symbolAlt)) { symbolData.Add(c.symbolAlt, lastHash); } if (c.characterMap > 0) { charMapData.Add(TexChar.possibleCharMaps[c.characterMap], lastHash); } } } } catch (System.Exception ex) { if (ex is System.ArgumentException) { int pair; try { pair = GetChar(GetChar(lastHash).symbolName).ToHash(); } catch { return(false); } Debug.LogErrorFormat("Duplicate Definitions Exist at {0:X3} and {1:X3}, Please fix it now.\nError: {2}", lastHash, pair, ex.Message); } else { Debug.LogErrorFormat("Unknown Error at {0:X3}: {1}\n{2}\n\nStackTrace:\n{3}", lastHash, ex.GetType().Name, ex.Message, ex.StackTrace); } return(false); } return(true); }
static public int CharToHash(TexChar ch) { return(ch.ToHash()); }
public bool PushToDictionaries() { int lastHash = 0; try { symbols.Clear(); charmaps.Clear(); fontnames.Clear(); for (int i = 0; i < fonts.Length; i++) { var font = fonts[i]; font.index = i; font.ImportDictionary(); fontnames.Add(font.name, font); var count = font.chars.Length; for (int j = 0; j < count; j++) { TexChar c = font.chars[j]; c.index = j; c.fontIndex = i; lastHash = c.ToHash(); if (!string.IsNullOrEmpty(c.symbolName)) { symbols.Add(c.symbolName, lastHash); } if (!string.IsNullOrEmpty(c.symbolAlt)) { symbols.Add(c.symbolAlt, lastHash); } if (c.characterMap > 0) { charmaps.Add(TexChar.possibleCharMaps[c.characterMap], lastHash); } } } // now check charmaps full for (int i = 1; i < TexChar.possibleCharMaps.Length; i++) { if (!charmaps.ContainsKey(TexChar.possibleCharMaps[i])) { Debug.LogWarning("TEXDraw: Charmap is missing: " + TexChar.possibleCharMaps[i].ToString()); } } } catch (System.Exception ex) { if (ex is System.ArgumentException) { int pair; try { pair = GetChar(GetChar(lastHash).symbolName).ToHash(); } catch { return(false); } Debug.LogErrorFormat("TEXDraw: Duplicate Definitions Exist at {0:X3} and {1:X3}, Please fix it now.\nError: {2}", lastHash, pair, ex.Message); } else { Debug.LogErrorFormat("TEXDraw: Unknown Error at {0:X3}: {1}\n{2}\n\nStackTrace:\n{3}", lastHash, ex.GetType().Name, ex.Message, ex.StackTrace); } return(false); } return(true); }