QuickFont.QFontData.GetKerningPairCorrection C# (CSharp) Метод

GetKerningPairCorrection() публичный Метод

Returns the kerning length correction for the character at the given index in the given string. Also, if the text is part of a textNode list, the nextNode is given so that the following node can be checked incase of two adjacent word nodes.
public GetKerningPairCorrection ( int index, string text, TextNode textNode ) : int
index int
text string
textNode TextNode
Результат int
        public int GetKerningPairCorrection(int index, string text, TextNode textNode)
        {
            if (KerningPairs == null)
                return 0;


            var chars = new char[2];

            if (index + 1 == text.Length)
            {
                if (textNode != null && textNode.Next != null && textNode.Next.Type == TextNodeType.Word)
                    chars[1] = textNode.Next.Text[0];
                else
                    return 0;
            }
            else
            {
                chars[1] = text[index + 1];
            }

            chars[0] = text[index];

            String str = new String(chars);


            if (KerningPairs.ContainsKey(str))
                return KerningPairs[str];

            return 0;
            
        }

Usage Example

        private float MeasureNextlineLength(string text)
        {
            var   isMonospacingActive = IsMonospacingActive();
            float xOffset             = 0;

            for (var i = 0; i < text.Length; i++)
            {
                var c = text[i];
                if (c == '\r' || c == '\n')
                {
                    break;
                }
                if (isMonospacingActive)
                {
                    xOffset += MonoSpaceWidth();
                }
                else
                {
                    QFontGlyph glyph;
                    if (c == ' ')
                    {
                        xOffset += (float)Math.Ceiling(Font.meanGlyphWidth * Options.WordSpacing);
                    }
                    else if (Font.CharSetMapping.TryGetValue(c, out glyph)) //normal character
                    {
                        xOffset +=
                            (float)
                            Math.Ceiling(glyph.rect.Width + Font.meanGlyphWidth * Options.CharacterSpacing +
                                         Font.GetKerningPairCorrection(i, text, null));
                    }
                }
            }

            return(xOffset);
        }
All Usage Examples Of QuickFont.QFontData::GetKerningPairCorrection