private void ParseKerningPair(ref ReadOnlySpan <char> line) { bool parsedFirst = false; bool parsedSecond = false; var kernPair = new BMFontKerningData(); while (line.Length > 0) { SkipWhitespace(ref line); var tagName = ParseIdentifier(ref line, "kerning"); if (CheckTag(tagName, "first")) { kernPair.FirstChar = ParseIntTag(ref line, "first"); parsedFirst = true; } else if (CheckTag(tagName, "second")) { kernPair.SecondChar = ParseIntTag(ref line, "second"); parsedSecond = true; } else if (CheckTag(tagName, "amount")) { kernPair.AmountX = ParseIntTag(ref line, "amount"); } else { throw new BMFontParseException( string.Format("Unsupported tag \"{0}\" on line \"{1}\".", tagName.ToString(), currentLine )); } } var pairVal = new RehashedValue <long> (BMFontInfo.GetKerningPairLong(kernPair.FirstChar, kernPair.SecondChar)); if (!parsedFirst) { throw new BMFontParseException($"Missing first char id on line {currentLine}."); } else if (!parsedSecond) { throw new BMFontParseException($"Missing second char id on line {currentLine}."); } else if (!kernPairs.TryAdd(pairVal, kernPair)) { throw new BMFontParseException($"Duplicate kerning pair ({kernPair.FirstChar}, {kernPair.SecondChar}) on line {currentLine}."); } }
public bool TryGetKerningPair(int first, int second, out BMFontKerningData kernData) { return(kernPairsList.TryGetValue(new RehashedValue <long> (GetKerningPairLong(first, second)), out kernData)); }